feat(DownloadSettings): 更新下载器设置API,优化下载器加载逻辑

This commit is contained in:
jxxghp
2024-11-21 10:26:12 +08:00
parent 77cb817523
commit a097d89d68
4 changed files with 18 additions and 26 deletions

View File

@@ -11,17 +11,12 @@ const activeTab = ref(route.query.tab)
// 下载器
const downloaders = ref<DownloaderConf[]>([])
// 获取启用的下载器
const enabledDownloaders = computed(() => downloaders.value.filter(item => item.enabled))
// 调用API查询下载器设置
async function loadDownloaderSetting() {
try {
const result: { [key: string]: any } = await api.get('system/setting/Downloaders')
if (result.data?.value && result.data.value.length > 0) {
downloaders.value = result.data?.value ?? []
if (!activeTab.value) activeTab.value = downloaders.value[0].name
}
downloaders.value = await api.get('download/clients')
if (downloaders.value && downloaders.value.length > 0 && !activeTab.value)
activeTab.value = downloaders.value[0].name
} catch (error) {
console.log(error)
}
@@ -31,21 +26,21 @@ function jumpTab(tab: string) {
router.push('/subscribe/movie?tab=' + tab)
}
onMounted(() => {
loadDownloaderSetting()
onMounted(async () => {
await loadDownloaderSetting()
})
</script>
<template>
<div v-if="enabledDownloaders.length > 0">
<div v-if="downloaders.length > 0">
<VTabs v-model="activeTab">
<VTab v-for="item in enabledDownloaders" :value="item.name" @to="jumpTab(item.name)">
<VTab v-for="item in downloaders" :value="item.name" @to="jumpTab(item.name)">
<span class="mx-5">{{ item.name }}</span>
</VTab>
</VTabs>
<VWindow v-model="activeTab" class="mt-5 disable-tab-transition" :touch="false">
<VWindowItem v-for="item in enabledDownloaders" :value="item.name">
<VWindowItem v-for="item in downloaders" :value="item.name">
<transition name="fade-slide" appear>
<DownloadingListView :name="item.name" />
</transition>