From b048308c46abe5b56593ef674fdaf600ee86b000 Mon Sep 17 00:00:00 2001 From: yutent Date: Thu, 20 Apr 2023 14:34:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/header.vue | 14 +++++++------- src/lib/fetch.js | 2 +- src/views/home.vue | 38 +++++++++++++++++++++++++++++++------- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/components/header.vue b/src/components/header.vue index 5d4018a..0504cc1 100644 --- a/src/components/header.vue +++ b/src/components/header.vue @@ -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 { diff --git a/src/lib/fetch.js b/src/lib/fetch.js index 03dd34a..3d63521 100644 --- a/src/lib/fetch.js +++ b/src/lib/fetch.js @@ -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') diff --git a/src/views/home.vue b/src/views/home.vue index 9b682cc..f767c54 100644 --- a/src/views/home.vue +++ b/src/views/home.vue @@ -1,6 +1,6 @@