mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-05-28 03:39:46 +08:00
feat:支持探索扩展
This commit is contained in:
@@ -1204,3 +1204,17 @@ export interface TransferQueue {
|
||||
state: string
|
||||
}[]
|
||||
}
|
||||
|
||||
// 探索的数据源
|
||||
export interface DiscoverSource {
|
||||
// 数据源名称
|
||||
name: string
|
||||
// 媒体ID的前缀,不含:
|
||||
mediaid_prefix: string
|
||||
// 媒体数据源API地址
|
||||
api_path: string
|
||||
// 过滤参数
|
||||
filter_params: { [key: string]: any }
|
||||
// 过滤参数UI配置
|
||||
filter_ui: RenderProps[]
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ import router from '@/router'
|
||||
import TheMovieDbView from '@/views/discover/TheMovieDbView.vue'
|
||||
import DoubanView from '@/views/discover/DoubanView.vue'
|
||||
import BangumiView from '@/views/discover/BangumiView.vue'
|
||||
import ExtraSourceView from '@/views/discover/ExtraSourceView.vue'
|
||||
import { DiscoverSource } from '@/api/types'
|
||||
import api from '@/api'
|
||||
|
||||
const route = useRoute()
|
||||
const activeTab = ref(route.query.tab)
|
||||
@@ -11,6 +14,22 @@ const activeTab = ref(route.query.tab)
|
||||
function jumpTab(tab: string) {
|
||||
router.push('/subscribe/discover?tab=' + tab)
|
||||
}
|
||||
|
||||
// 额外的数据源
|
||||
const extraDiscoverSources = ref<DiscoverSource[]>([])
|
||||
|
||||
// 加载额外的发现数据源
|
||||
async function loadExtraDiscoverSources() {
|
||||
try {
|
||||
extraDiscoverSources.value = await api.get('discover/source')
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadExtraDiscoverSources()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -21,6 +40,16 @@ function jumpTab(tab: string) {
|
||||
{{ item.title }}
|
||||
</div>
|
||||
</VTab>
|
||||
<VTab
|
||||
v-for="item in extraDiscoverSources"
|
||||
:key="item.mediaid_prefix"
|
||||
:value="item.mediaid_prefix"
|
||||
@to="jumpTab(item.mediaid_prefix)"
|
||||
>
|
||||
<div class="min-w-24">
|
||||
{{ item.name }}
|
||||
</div>
|
||||
</VTab>
|
||||
</VTabs>
|
||||
|
||||
<VWindow v-model="activeTab" class="mt-5 disable-tab-transition" :touch="false">
|
||||
@@ -45,6 +74,13 @@ function jumpTab(tab: string) {
|
||||
</div>
|
||||
</transition>
|
||||
</VWindowItem>
|
||||
<VWindowItem v-for="item in extraDiscoverSources" :key="item.mediaid_prefix" :value="item.mediaid_prefix">
|
||||
<transition name="fade-slide" appear>
|
||||
<div>
|
||||
<ExtraSourceView :source="item" />
|
||||
</div>
|
||||
</transition>
|
||||
</VWindowItem>
|
||||
</VWindow>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
30
src/views/discover/ExtraSourceView.vue
Normal file
30
src/views/discover/ExtraSourceView.vue
Normal file
@@ -0,0 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
import { DiscoverSource } from '@/api/types'
|
||||
import MediaCardListView from '@/views/discover/MediaCardListView.vue'
|
||||
import FormRender from '@/components/render/FormRender.vue'
|
||||
|
||||
// 输入参数
|
||||
const props = defineProps<{
|
||||
source: DiscoverSource
|
||||
}>()
|
||||
|
||||
// 过滤参数
|
||||
const filterParams = reactive(props.source.filter_params)
|
||||
|
||||
// 当前Key
|
||||
const currentKey = ref(0)
|
||||
|
||||
// 类型和过滤参数变化后重新刷新列表
|
||||
watch([filterParams], () => {
|
||||
currentKey.value++
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="px-3">
|
||||
<FormRender v-for="(element, index) in source.filter_ui" :key="index" :config="element" :model="filterParams" />
|
||||
</div>
|
||||
<div>
|
||||
<MediaCardListView :key="currentKey" :apipath="source.api_path" :params="filterParams" />
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user