更新样式

master
yutent 2023-04-20 14:34:35 +08:00
parent 6174ae8099
commit b048308c46
3 changed files with 39 additions and 15 deletions

View File

@ -54,20 +54,20 @@ export default {
let id = this.input.trim()
if (id) {
fetch('/package/search/' + encodeURIComponent(id)).then(r => {
// let list = r.data.map(it => it.split('/'))
let dict = { versions: [], id }
let last = null
for (let it of r.data) {
let tmp = it.split('/')
if (tmp.length === 1) {
last = it
dict.versions.push(last)
dict[last] = []
let v = tmp.shift()
let n = tmp.join('/')
if (last === v) {
dict[last].push(n)
} else {
dict[last].push(it)
last = v
dict.versions.push(last)
dict[last] = [n]
}
}
console.log(dict)
this.$store.result = dict
})
} else {

View File

@ -1,6 +1,6 @@
import fetch from 'fetch'
fetch.BASE_URL = '//api.jscdn.ink'
fetch.BASE_URL = 'https://api.jscdn.ink'
fetch.inject.request(function (conf) {
var token = localStorage.getItem('token')

View File

@ -1,6 +1,6 @@
<template>
<main class="home" @click="copy">
<dl class="card" v-if="version">
<dl class="card noselect" v-if="version">
<dt class="title">
{{ $store.result.id }} -
<wc-dropdown v-model="version">
@ -14,15 +14,19 @@
</dt>
<dd class="list">
<section class="link" v-for="f in $store.result[version]">
//jscdn.ink/{{ $store.result.id }}/{{ f }}
//jscdn.ink/<b>{{ $store.result.id }}</b
>/<i>{{ version }}</i
>/<q>{{ f }}</q>
</section>
</dd>
</dl>
<dl class="card" v-else v-for="it in libs" :key="it.name">
<dl class="card noselect" v-else v-for="it in libs" :key="it.name">
<dt class="title">{{ it.name }} - v{{ it.version }}</dt>
<dd class="list">
<section class="link" v-for="f in it.files">
//jscdn.ink/{{ it.name }}/{{ it.version }}/{{ f }}
//jscdn.ink/<b>{{ it.name }}</b
>/<i>{{ it.version }}</i
>/<q>{{ f }}</q>
</section>
</dd>
</dl>
@ -81,8 +85,12 @@ export default {
methods: {
copy(ev) {
if (ev.target.tagName === 'SECTION') {
navigator.clipboard.writeText(ev.target.textContent.trim())
let elem = ev.target
if (elem.tagName === 'SECTION' || elem.parentNode.tagName === 'SECTION') {
if (elem.parentNode.tagName === 'SECTION') {
elem = elem.parentNode
}
navigator.clipboard.writeText(elem.textContent.trim())
layer.toast('复制成功', 'success')
}
}
@ -114,9 +122,25 @@ export default {
}
.link {
padding: 0 6px;
border-radius: 4px;
transition: background 0.1s ease;
b,
i,
q {
padding: 0 2px;
}
b {
color: var(--color-teal-1);
}
i {
color: var(--color-blue-1);
}
q {
}
&:hover {
text-decoration: underline;
background: var(--color-plain-1);
}
&:active {
background: var(--color-plain-a);