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) => {
|
||||
const match = input.match(pattern)
|
||||
if (!match) {
|
||||
@ -16,13 +18,15 @@ export const matchInput = (input: string, pattern: RegExp) => {
|
||||
|
||||
export const createLinkAction = (input: {
|
||||
name: string
|
||||
displayName?: string
|
||||
description?: string
|
||||
indexer: string
|
||||
link: string
|
||||
}) => {
|
||||
const { name, description, indexer, link } = input
|
||||
}): LaunchBarAction => {
|
||||
const { name, displayName, description, indexer, link } = input
|
||||
return {
|
||||
name: name || indexer,
|
||||
displayName,
|
||||
icon: 'mdi-open-in-new',
|
||||
indexer,
|
||||
description,
|
||||
|
||||
@ -15,25 +15,44 @@ export const plugin: PluginMetadata = {
|
||||
if (!match) {
|
||||
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 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: articleName } = lodash.get(cvJson, 'data', {})
|
||||
const { name: userName } = lodash.get(uidJson, 'data.card', {})
|
||||
const prefix = (name: string) => (name ? `numberSearchAction.${name}` : name)
|
||||
return [
|
||||
createLinkAction({
|
||||
name: videoName,
|
||||
name: prefix(videoName),
|
||||
displayName: videoName,
|
||||
description: '视频跳转',
|
||||
link: `https://www.bilibili.com/av${id}`,
|
||||
indexer,
|
||||
}),
|
||||
createLinkAction({
|
||||
name: articleName,
|
||||
name: prefix(id),
|
||||
displayName: id,
|
||||
description: '直播间跳转',
|
||||
link: `https://live.bilibili.com/${id}`,
|
||||
indexer,
|
||||
}),
|
||||
createLinkAction({
|
||||
name: prefix(articleName),
|
||||
displayName: articleName,
|
||||
description: '专栏跳转',
|
||||
link: `https://www.bilibili.com/read/cv${id}`,
|
||||
indexer,
|
||||
}),
|
||||
createLinkAction({
|
||||
name: prefix(userName),
|
||||
displayName: userName,
|
||||
description: '用户跳转',
|
||||
link: `https://space.bilibili.com/${id}`,
|
||||
indexer,
|
||||
}),
|
||||
]
|
||||
},
|
||||
})
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
:name="action.name"
|
||||
></component>
|
||||
<div v-else class="suggest-item-name">
|
||||
{{ action.title || action.name }}
|
||||
{{ action.displayName || action.name }}
|
||||
</div>
|
||||
<div v-if="action.description" class="suggest-item-description">
|
||||
{{ action.description }}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user