diff --git a/src/panes/SearchPane/SearchPane.vue b/src/panes/SearchPane/SearchPane.vue index 310a4fa..54f1683 100644 --- a/src/panes/SearchPane/SearchPane.vue +++ b/src/panes/SearchPane/SearchPane.vue @@ -3,19 +3,28 @@ import { computed, ref } from 'vue' import { SelectProps, useMessage } from 'naive-ui' import { PhMagnifyingGlass } from '@phosphor-icons/vue' import FloatLabelInput from '../../components/FloatLabelInput.vue' -import { commands, GetBangumiInfoParams, GetNormalInfoParams, SearchParams, SearchResult } from '../../bindings.ts' +import { + commands, + GetBangumiInfoParams, + GetCheeseInfoParams, + GetNormalInfoParams, + SearchParams, + SearchResult, +} from '../../bindings.ts' import NormalSeasonPanel from './components/NormalSeasonPanel.vue' import NormalSinglePanel from './components/NormalSinglePanel.vue' import { extractBvid, extractAid, extractEpId, extractSeasonId } from '../../utils.tsx' import { useStore } from '../../store.ts' import BangumiPanel from './components/BangumiPanel.vue' +import CheesePanel from './components/CheesePanel.vue' -export type SearchType = 'Auto' | 'Normal' | 'Bangumi' +export type SearchType = 'Auto' | 'Normal' | 'Bangumi' | 'Cheese' const searchTypeOptions: SelectProps['options'] = [ { label: '自动', value: 'Auto' }, { label: '视频', value: 'Normal' }, { label: '番剧', value: 'Bangumi' }, + { label: '课程', value: 'Cheese' }, ] const store = useStore() @@ -32,6 +41,8 @@ const searchLabel = computed(() => { return '链接 / av... / BV...' } else if (searchTypeSelected.value === 'Bangumi') { return '链接 / ep... / ss...' + } else if (searchTypeSelected.value === 'Cheese') { + return '链接 / ep... / ss...' } return '链接 / av... / BV... / ep... / ss...' }) @@ -54,6 +65,8 @@ async function search(input: string, searchType: SearchType) { await searchNormal(input, isUrl) } else if (searchType === 'Bangumi') { await searchBangumi(input, isUrl) + } else if (searchType === 'Cheese') { + await searchCheese(input, isUrl) } else { message.error('未知的搜索类型') } @@ -179,6 +192,42 @@ async function searchBangumi(input: string, isUrl: boolean) { searchResult.value = result.data } +async function searchCheese(input: string, isUrl: boolean) { + let params: GetCheeseInfoParams | undefined + + if (isUrl) { + const epId = extractEpId(input) + const seasonId = extractSeasonId(input) + if (epId !== undefined) { + params = { EpId: epId } + } else if (seasonId !== undefined) { + params = { SeasonId: seasonId } + } + } else if (input.toLowerCase().startsWith('ep')) { + const epId = parseInt(input.substring(2), 10) + if (!isNaN(epId)) { + params = { EpId: epId } + } + } else if (input.toLowerCase().startsWith('ss')) { + const seasonId = parseInt(input.substring(2), 10) + if (!isNaN(seasonId)) { + params = { SeasonId: seasonId } + } + } + + if (params === undefined) { + message.error('解析输入失败,请输入正确的链接或ID(如 ep... / ss...)') + return + } + + const result = await commands.search({ Cheese: params }) + if (result.status === 'error') { + console.error(result.error) + return + } + searchResult.value = result.data +} + defineExpose({ search }) @@ -217,6 +266,7 @@ defineExpose({ search }) :ugc-season="searchResult.Normal.ugc_season" /> + diff --git a/src/panes/SearchPane/components/CheesePanel.vue b/src/panes/SearchPane/components/CheesePanel.vue new file mode 100644 index 0000000..7f22e1d --- /dev/null +++ b/src/panes/SearchPane/components/CheesePanel.vue @@ -0,0 +1,190 @@ + + + + + + 左键拖动进行框选,右键打开菜单 + + + + + + + + {{ collectionCardShowing ? '隐藏合集' : '显示合集' }} + + 下载勾选视频 + + + + + + + + + + diff --git a/src/panes/SearchPane/components/EpisodeCard.vue b/src/panes/SearchPane/components/EpisodeCard.vue index 2d0c137..0cd9b83 100644 --- a/src/panes/SearchPane/components/EpisodeCard.vue +++ b/src/panes/SearchPane/components/EpisodeCard.vue @@ -1,6 +1,14 @@