From 33ab167e520591c192daaad35bd9e66a47af0716 Mon Sep 17 00:00:00 2001 From: imsyy Date: Sat, 22 Nov 2025 00:25:19 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E6=94=AF=E6=8C=81=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E5=88=86=E4=BA=AB=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auto-eslint.mjs | 3 +- auto-imports.d.ts | 2 ++ src/components/Search/SearchInp.vue | 5 +++ src/components/Search/SearchSuggest.vue | 46 +++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) diff --git a/auto-eslint.mjs b/auto-eslint.mjs index f3fad90..a9714ef 100644 --- a/auto-eslint.mjs +++ b/auto-eslint.mjs @@ -59,6 +59,7 @@ export default { "isRef": true, "isShallow": true, "makeDestructurable": true, + "manualResetRef": true, "markRaw": true, "nextTick": true, "onActivated": true, @@ -96,11 +97,11 @@ export default { "refAutoReset": true, "refDebounced": true, "refDefault": true, + "refManualReset": true, "refThrottled": true, "refWithControl": true, "resolveComponent": true, "resolveRef": true, - "resolveUnref": true, "shallowReactive": true, "shallowReadonly": true, "shallowRef": true, diff --git a/auto-imports.d.ts b/auto-imports.d.ts index b6c0a81..cf3a25f 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -48,6 +48,7 @@ declare global { const isRef: typeof import('vue').isRef const isShallow: typeof import('vue').isShallow const makeDestructurable: typeof import('@vueuse/core').makeDestructurable + const manualResetRef: typeof import('@vueuse/core').manualResetRef const markRaw: typeof import('vue').markRaw const nextTick: typeof import('vue').nextTick const onActivated: typeof import('vue').onActivated @@ -85,6 +86,7 @@ declare global { const refAutoReset: typeof import('@vueuse/core').refAutoReset const refDebounced: typeof import('@vueuse/core').refDebounced const refDefault: typeof import('@vueuse/core').refDefault + const refManualReset: typeof import('@vueuse/core').refManualReset const refThrottled: typeof import('@vueuse/core').refThrottled const refWithControl: typeof import('@vueuse/core').refWithControl const resolveComponent: typeof import('vue').resolveComponent diff --git a/src/components/Search/SearchInp.vue b/src/components/Search/SearchInp.vue index bec3677..acf81b5 100644 --- a/src/components/Search/SearchInp.vue +++ b/src/components/Search/SearchInp.vue @@ -150,6 +150,11 @@ const toSearch = async (key: any, type: string = "keyword") => { query: { id: key?.id }, }); break; + case "share": + if (key?.realType && key?.id) { + toSearch({ id: key.id }, key.realType); + } + break; default: break; } diff --git a/src/components/Search/SearchSuggest.vue b/src/components/Search/SearchSuggest.vue index bd49333..957119a 100644 --- a/src/components/Search/SearchSuggest.vue +++ b/src/components/Search/SearchSuggest.vue @@ -99,6 +99,10 @@ const searchSuggestionsType = { name: "歌单", icon: "MusicList", }, + share: { + name: "分享的内容", + icon: "Link", + }, }; // 获取搜索建议 @@ -126,11 +130,53 @@ const calcSearchSuggestHeights = () => { } }; +// 识别链接类型 +const getLinkType = (val: string) => { + const regex = /music\.163\.com\/(?:#\/)?(song|playlist|album|artist)\?id=(\d+)/; + const match = val.match(regex); + if (match) { + const typeMap: Record = { + song: "songs", + playlist: "playlists", + album: "albums", + artist: "artists", + }; + const nameMap: Record = { + song: "歌曲", + playlist: "歌单", + album: "专辑", + artist: "歌手", + }; + return { + type: typeMap[match[1]], + typeName: nameMap[match[1]], + id: match[2], + }; + } + return null; +}; + // 搜索框改变 watchDebounced( () => statusStore.searchInputValue, (val) => { if (!val || val === "" || !settingStore.useOnlineService) return; + // 识别链接 + const linkData = getLinkType(val); + if (linkData) { + searchSuggestData.value = { + order: ["share"], + share: [ + { + name: `前往分享的${linkData.typeName}`, + id: linkData.id, + realType: linkData.type, + }, + ], + }; + nextTick(calcSearchSuggestHeights); + return; + } getSearchSuggest(val); }, { debounce: 300 },