-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
在输入音频的 au 号或播放列表的 am 号时, 提供对应的跳转选项. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import type { LaunchBarActionProvider } from '@/components/launch-bar/launch-bar-action' | ||
import type { PluginMetadata } from '@/plugins/plugin' | ||
import { getJson } from '@/core/ajax' | ||
|
||
export const plugin: PluginMetadata = { | ||
name: 'launchBar.actions.audioSearch', | ||
displayName: '搜索栏 - 音频跳转', | ||
async setup({ addData }) { | ||
addData('launchBar.actions', (providers: LaunchBarActionProvider[]) => { | ||
providers.push({ | ||
name: 'audioSearchProvider', | ||
getActions: async input => { | ||
const match = input.match(/^(a[um])(\d+)$/) | ||
if (!match) { | ||
return [] | ||
} | ||
const type = match[1] | ||
const id = match[2] | ||
const indexer = `${type}${id}` | ||
const json = await getJson( | ||
type === 'am' | ||
? `https://www.bilibili.com/audio/music-service-c/web/menu/info?sid=${id}` | ||
: `https://www.bilibili.com/audio/music-service-c/web/song/info?sid=${id}`, | ||
) | ||
const { title } = lodash.get(json, 'data', {}) | ||
return [ | ||
{ | ||
name: title || indexer, | ||
icon: 'mdi-open-in-new', | ||
indexer, | ||
description: type === 'am' ? '播放列表跳转' : '音频跳转', | ||
action: () => { | ||
window.open(`https://www.bilibili.com/audio/${indexer}`, '_blank') | ||
}, | ||
order: 0, | ||
}, | ||
] | ||
}, | ||
}) | ||
}) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
在输入专栏的 cv 号或专栏文集的 rl 号时, 提供对应的跳转选项. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters