Skip to content

Commit

Permalink
feat: bvid search
Browse files Browse the repository at this point in the history
  • Loading branch information
lovegaoshi committed Mar 18, 2024
1 parent 66e66b9 commit 78599a2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/components/playlist/SongList/SongMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import { CopiedPlaylistMenuItem } from '@components/buttons/CopiedPlaylistButton
import RenameSongButton from '@components/player/TrackInfo/RenameSong/RenameSongButton';
import useSongOperations from '@hooks/useSongOperations';
import { SearchRegex } from '@enums/Playlist';
import { SOURCE } from '@enums/MediaFetch';
import useBiliSearch from '@hooks/useBiliSearch';

enum ICONS {
SEND_TO = 'playlist-plus',
COPY_SONG_NAME = '',
SEARCH_IN_PLAYLIST = 'text-search',
SEARCH_BVID = 'search-web',
RELOAD = 'refresh',
REMOVE = 'delete',
REMOVE_AND_BAN_BVID = 'delete-forever',
Expand Down Expand Up @@ -46,6 +49,7 @@ export default ({ usePlaylist, prepareForLayoutAnimationRender }: Props) => {
state => state.setPlaylistSearchAutoFocus
);
const { startRadio, radioAvailable } = useSongOperations();
const { setSearchVal, handleSearch } = useBiliSearch({});

const closeMenu = React.useCallback(() => setSongMenuVisible(false), []);

Expand Down Expand Up @@ -126,6 +130,19 @@ export default ({ usePlaylist, prepareForLayoutAnimationRender }: Props) => {
disabled={checking}
title={t('SongOperations.songSearchInPlaylistTitle')}
/>
{selectedSongs()[0]?.source === SOURCE.bilivideo && (
<Menu.Item
leadingIcon={ICONS.SEARCH_BVID}
onPress={() => {
const song = selectedSongs()[0];
setSearchVal(song.bvid);
handleSearch(song.bvid);
closeMenu();
}}
disabled={checking}
title={t('SongOperations.BVIDSearchTitle')}
/>
)}
<Menu.Item
leadingIcon={ICONS.REMOVE}
onPress={() => removeSongs()}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useBiliSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useNoxSetting } from '../stores/useApp';
import { getDefaultSearch } from '@utils/ChromeStorage';

interface props {
onSearched: (val: any) => void;
onSearched?: (val: any) => void;
searchListTitle?: string;
}
export default ({
Expand Down
1 change: 1 addition & 0 deletions src/localization/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"songSendToTitle": "Send to...",
"songRenameTitle": "Rename...",
"songSearchInPlaylistTitle": "Search in Playlist",
"BVIDSearchTitle": "Search in Bilibili",
"songStartRadio": "Start Radio",
"songR128gain": "R128Gain",
"abrepeat": "ABrepeat",
Expand Down
1 change: 1 addition & 0 deletions src/localization/zhcn/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"songSendToTitle": "送往...",
"songRenameTitle": "改名...",
"songSearchInPlaylistTitle": "在歌单内搜索",
"BVIDSearchTitle": "bv号搜索",
"songStartRadio": "播放电台",
"songR128gain": "回放增益",
"abrepeat": "AB重复",
Expand Down

0 comments on commit 78599a2

Please sign in to comment.