mirror of
https://github.com/imsyy/SPlayer.git
synced 2025-11-25 03:14:57 +08:00
✨ feat: 支持识别分享链接
This commit is contained in:
@@ -59,6 +59,7 @@ export default {
|
|||||||
"isRef": true,
|
"isRef": true,
|
||||||
"isShallow": true,
|
"isShallow": true,
|
||||||
"makeDestructurable": true,
|
"makeDestructurable": true,
|
||||||
|
"manualResetRef": true,
|
||||||
"markRaw": true,
|
"markRaw": true,
|
||||||
"nextTick": true,
|
"nextTick": true,
|
||||||
"onActivated": true,
|
"onActivated": true,
|
||||||
@@ -96,11 +97,11 @@ export default {
|
|||||||
"refAutoReset": true,
|
"refAutoReset": true,
|
||||||
"refDebounced": true,
|
"refDebounced": true,
|
||||||
"refDefault": true,
|
"refDefault": true,
|
||||||
|
"refManualReset": true,
|
||||||
"refThrottled": true,
|
"refThrottled": true,
|
||||||
"refWithControl": true,
|
"refWithControl": true,
|
||||||
"resolveComponent": true,
|
"resolveComponent": true,
|
||||||
"resolveRef": true,
|
"resolveRef": true,
|
||||||
"resolveUnref": true,
|
|
||||||
"shallowReactive": true,
|
"shallowReactive": true,
|
||||||
"shallowReadonly": true,
|
"shallowReadonly": true,
|
||||||
"shallowRef": true,
|
"shallowRef": true,
|
||||||
|
|||||||
2
auto-imports.d.ts
vendored
2
auto-imports.d.ts
vendored
@@ -48,6 +48,7 @@ declare global {
|
|||||||
const isRef: typeof import('vue').isRef
|
const isRef: typeof import('vue').isRef
|
||||||
const isShallow: typeof import('vue').isShallow
|
const isShallow: typeof import('vue').isShallow
|
||||||
const makeDestructurable: typeof import('@vueuse/core').makeDestructurable
|
const makeDestructurable: typeof import('@vueuse/core').makeDestructurable
|
||||||
|
const manualResetRef: typeof import('@vueuse/core').manualResetRef
|
||||||
const markRaw: typeof import('vue').markRaw
|
const markRaw: typeof import('vue').markRaw
|
||||||
const nextTick: typeof import('vue').nextTick
|
const nextTick: typeof import('vue').nextTick
|
||||||
const onActivated: typeof import('vue').onActivated
|
const onActivated: typeof import('vue').onActivated
|
||||||
@@ -85,6 +86,7 @@ declare global {
|
|||||||
const refAutoReset: typeof import('@vueuse/core').refAutoReset
|
const refAutoReset: typeof import('@vueuse/core').refAutoReset
|
||||||
const refDebounced: typeof import('@vueuse/core').refDebounced
|
const refDebounced: typeof import('@vueuse/core').refDebounced
|
||||||
const refDefault: typeof import('@vueuse/core').refDefault
|
const refDefault: typeof import('@vueuse/core').refDefault
|
||||||
|
const refManualReset: typeof import('@vueuse/core').refManualReset
|
||||||
const refThrottled: typeof import('@vueuse/core').refThrottled
|
const refThrottled: typeof import('@vueuse/core').refThrottled
|
||||||
const refWithControl: typeof import('@vueuse/core').refWithControl
|
const refWithControl: typeof import('@vueuse/core').refWithControl
|
||||||
const resolveComponent: typeof import('vue').resolveComponent
|
const resolveComponent: typeof import('vue').resolveComponent
|
||||||
|
|||||||
@@ -150,6 +150,11 @@ const toSearch = async (key: any, type: string = "keyword") => {
|
|||||||
query: { id: key?.id },
|
query: { id: key?.id },
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case "share":
|
||||||
|
if (key?.realType && key?.id) {
|
||||||
|
toSearch({ id: key.id }, key.realType);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,6 +99,10 @@ const searchSuggestionsType = {
|
|||||||
name: "歌单",
|
name: "歌单",
|
||||||
icon: "MusicList",
|
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<string, string> = {
|
||||||
|
song: "songs",
|
||||||
|
playlist: "playlists",
|
||||||
|
album: "albums",
|
||||||
|
artist: "artists",
|
||||||
|
};
|
||||||
|
const nameMap: Record<string, string> = {
|
||||||
|
song: "歌曲",
|
||||||
|
playlist: "歌单",
|
||||||
|
album: "专辑",
|
||||||
|
artist: "歌手",
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
type: typeMap[match[1]],
|
||||||
|
typeName: nameMap[match[1]],
|
||||||
|
id: match[2],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
// 搜索框改变
|
// 搜索框改变
|
||||||
watchDebounced(
|
watchDebounced(
|
||||||
() => statusStore.searchInputValue,
|
() => statusStore.searchInputValue,
|
||||||
(val) => {
|
(val) => {
|
||||||
if (!val || val === "" || !settingStore.useOnlineService) return;
|
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);
|
getSearchSuggest(val);
|
||||||
},
|
},
|
||||||
{ debounce: 300 },
|
{ debounce: 300 },
|
||||||
|
|||||||
Reference in New Issue
Block a user