mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Support uid & live search (#677)
This commit is contained in:
parent
9f2a3bf8eb
commit
adb4975573
@ -1,3 +1,5 @@
|
|||||||
|
import type { LaunchBarAction } from '@/components/launch-bar/launch-bar-action'
|
||||||
|
|
||||||
export const matchInput = (input: string, pattern: RegExp) => {
|
export const matchInput = (input: string, pattern: RegExp) => {
|
||||||
const match = input.match(pattern)
|
const match = input.match(pattern)
|
||||||
if (!match) {
|
if (!match) {
|
||||||
@ -16,13 +18,15 @@ export const matchInput = (input: string, pattern: RegExp) => {
|
|||||||
|
|
||||||
export const createLinkAction = (input: {
|
export const createLinkAction = (input: {
|
||||||
name: string
|
name: string
|
||||||
|
displayName?: string
|
||||||
description?: string
|
description?: string
|
||||||
indexer: string
|
indexer: string
|
||||||
link: string
|
link: string
|
||||||
}) => {
|
}): LaunchBarAction => {
|
||||||
const { name, description, indexer, link } = input
|
const { name, displayName, description, indexer, link } = input
|
||||||
return {
|
return {
|
||||||
name: name || indexer,
|
name: name || indexer,
|
||||||
|
displayName,
|
||||||
icon: 'mdi-open-in-new',
|
icon: 'mdi-open-in-new',
|
||||||
indexer,
|
indexer,
|
||||||
description,
|
description,
|
||||||
|
|||||||
@ -15,25 +15,44 @@ export const plugin: PluginMetadata = {
|
|||||||
if (!match) {
|
if (!match) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
const [aidJson, cvJson] = await Promise.all([
|
const [aidJson, cvJson, uidJson] = await Promise.all([
|
||||||
await getJsonWithCredentials(`https://api.bilibili.com/x/web-interface/view?aid=${id}`),
|
await getJsonWithCredentials(`https://api.bilibili.com/x/web-interface/view?aid=${id}`),
|
||||||
await getJson(`https://api.bilibili.com/x/article/viewinfo?id=${id}`),
|
await getJson(`https://api.bilibili.com/x/article/viewinfo?id=${id}`),
|
||||||
|
await getJson(`https://api.bilibili.com/x/web-interface/card?mid=${id}`),
|
||||||
])
|
])
|
||||||
const { title: videoName } = lodash.get(aidJson, 'data', {})
|
const { title: videoName } = lodash.get(aidJson, 'data', {})
|
||||||
const { title: articleName } = lodash.get(cvJson, 'data', {})
|
const { title: articleName } = lodash.get(cvJson, 'data', {})
|
||||||
|
const { name: userName } = lodash.get(uidJson, 'data.card', {})
|
||||||
|
const prefix = (name: string) => (name ? `numberSearchAction.${name}` : name)
|
||||||
return [
|
return [
|
||||||
createLinkAction({
|
createLinkAction({
|
||||||
name: videoName,
|
name: prefix(videoName),
|
||||||
|
displayName: videoName,
|
||||||
description: '视频跳转',
|
description: '视频跳转',
|
||||||
link: `https://www.bilibili.com/av${id}`,
|
link: `https://www.bilibili.com/av${id}`,
|
||||||
indexer,
|
indexer,
|
||||||
}),
|
}),
|
||||||
createLinkAction({
|
createLinkAction({
|
||||||
name: articleName,
|
name: prefix(id),
|
||||||
|
displayName: id,
|
||||||
|
description: '直播间跳转',
|
||||||
|
link: `https://live.bilibili.com/${id}`,
|
||||||
|
indexer,
|
||||||
|
}),
|
||||||
|
createLinkAction({
|
||||||
|
name: prefix(articleName),
|
||||||
|
displayName: articleName,
|
||||||
description: '专栏跳转',
|
description: '专栏跳转',
|
||||||
link: `https://www.bilibili.com/read/cv${id}`,
|
link: `https://www.bilibili.com/read/cv${id}`,
|
||||||
indexer,
|
indexer,
|
||||||
}),
|
}),
|
||||||
|
createLinkAction({
|
||||||
|
name: prefix(userName),
|
||||||
|
displayName: userName,
|
||||||
|
description: '用户跳转',
|
||||||
|
link: `https://space.bilibili.com/${id}`,
|
||||||
|
indexer,
|
||||||
|
}),
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
:name="action.name"
|
:name="action.name"
|
||||||
></component>
|
></component>
|
||||||
<div v-else class="suggest-item-name">
|
<div v-else class="suggest-item-name">
|
||||||
{{ action.title || action.name }}
|
{{ action.displayName || action.name }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="action.description" class="suggest-item-description">
|
<div v-if="action.description" class="suggest-item-description">
|
||||||
{{ action.description }}
|
{{ action.description }}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user