更新样式

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

View File

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

View File

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