mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
feat(DownloadSettings): 更新下载器设置API,优化下载器加载逻辑
This commit is contained in:
@@ -13,6 +13,9 @@ const props = defineProps({
|
|||||||
torrent: Object as PropType<TorrentInfo>,
|
torrent: Object as PropType<TorrentInfo>,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 定义成功和失败事件
|
||||||
|
const emit = defineEmits(['done', 'error', 'close'])
|
||||||
|
|
||||||
// 提示框
|
// 提示框
|
||||||
const $toast = useToast()
|
const $toast = useToast()
|
||||||
|
|
||||||
@@ -22,8 +25,8 @@ const selectedDownloader = ref<string | null>(null)
|
|||||||
// 选择的保存目录
|
// 选择的保存目录
|
||||||
const selectedDirectory = ref<string | null>(null)
|
const selectedDirectory = ref<string | null>(null)
|
||||||
|
|
||||||
// 定义成功和失败事件
|
// 下载器
|
||||||
const emit = defineEmits(['done', 'error', 'close'])
|
const downloaders = ref<DownloaderConf[]>([])
|
||||||
|
|
||||||
// 所有目录设置
|
// 所有目录设置
|
||||||
const directories = ref<TransferDirectoryConf[]>([])
|
const directories = ref<TransferDirectoryConf[]>([])
|
||||||
@@ -53,14 +56,10 @@ const targetDirectories = computed(() => {
|
|||||||
return [...new Set(downloadDirectories)]
|
return [...new Set(downloadDirectories)]
|
||||||
})
|
})
|
||||||
|
|
||||||
// 下载器
|
|
||||||
const downloaders = ref<DownloaderConf[]>([])
|
|
||||||
|
|
||||||
// 调用API查询下载器设置
|
// 调用API查询下载器设置
|
||||||
async function loadDownloaderSetting() {
|
async function loadDownloaderSetting() {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.get('system/setting/Downloaders')
|
downloaders.value = await api.get('download/clients')
|
||||||
downloaders.value = result.data?.value ?? []
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useToast } from 'vue-toast-notification'
|
import { useToast } from 'vue-toast-notification'
|
||||||
import type { Site } from '@/api/types'
|
import type { DownloaderConf, Site } from '@/api/types'
|
||||||
import { doneNProgress, startNProgress } from '@/api/nprogress'
|
import { doneNProgress, startNProgress } from '@/api/nprogress'
|
||||||
import { numberValidator, requiredValidator } from '@/@validators'
|
import { numberValidator, requiredValidator } from '@/@validators'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
@@ -65,8 +65,7 @@ const downloaderOptions = ref<{ title: string; value: string }[]>([])
|
|||||||
|
|
||||||
async function loadDownloaderSetting() {
|
async function loadDownloaderSetting() {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.get('system/setting/Downloaders')
|
const downloaders: DownloaderConf[] = await api.get('download/clients')
|
||||||
const downloaders = result.data?.value ?? []
|
|
||||||
downloaderOptions.value = [
|
downloaderOptions.value = [
|
||||||
{ title: '默认', value: null },
|
{ title: '默认', value: null },
|
||||||
...downloaders.map((item: { name: any }) => ({
|
...downloaders.map((item: { name: any }) => ({
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { useToast } from 'vue-toast-notification'
|
import { useToast } from 'vue-toast-notification'
|
||||||
import { numberValidator } from '@/@validators'
|
import { numberValidator } from '@/@validators'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import type { FilterRuleGroup, Site, Subscribe, TransferDirectoryConf } from '@/api/types'
|
import type { DownloaderConf, FilterRuleGroup, Site, Subscribe, TransferDirectoryConf } from '@/api/types'
|
||||||
import { useDisplay } from 'vuetify'
|
import { useDisplay } from 'vuetify'
|
||||||
import { useConfirm } from 'vuetify-use-dialog'
|
import { useConfirm } from 'vuetify-use-dialog'
|
||||||
import { VTextarea, VTextField } from 'vuetify/lib/components/index.mjs'
|
import { VTextarea, VTextField } from 'vuetify/lib/components/index.mjs'
|
||||||
@@ -63,8 +63,7 @@ const downloaderOptions = ref<{ title: string; value: string }[]>([])
|
|||||||
|
|
||||||
async function loadDownloaderSetting() {
|
async function loadDownloaderSetting() {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.get('system/setting/Downloaders')
|
const downloaders: DownloaderConf[] = await api.get('download/clients')
|
||||||
const downloaders = result.data?.value ?? []
|
|
||||||
downloaderOptions.value = [
|
downloaderOptions.value = [
|
||||||
{ title: '默认', value: '' },
|
{ title: '默认', value: '' },
|
||||||
...downloaders.map((item: { name: any }) => ({
|
...downloaders.map((item: { name: any }) => ({
|
||||||
|
|||||||
@@ -11,17 +11,12 @@ const activeTab = ref(route.query.tab)
|
|||||||
// 下载器
|
// 下载器
|
||||||
const downloaders = ref<DownloaderConf[]>([])
|
const downloaders = ref<DownloaderConf[]>([])
|
||||||
|
|
||||||
// 获取启用的下载器
|
|
||||||
const enabledDownloaders = computed(() => downloaders.value.filter(item => item.enabled))
|
|
||||||
|
|
||||||
// 调用API查询下载器设置
|
// 调用API查询下载器设置
|
||||||
async function loadDownloaderSetting() {
|
async function loadDownloaderSetting() {
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.get('system/setting/Downloaders')
|
downloaders.value = await api.get('download/clients')
|
||||||
if (result.data?.value && result.data.value.length > 0) {
|
if (downloaders.value && downloaders.value.length > 0 && !activeTab.value)
|
||||||
downloaders.value = result.data?.value ?? []
|
activeTab.value = downloaders.value[0].name
|
||||||
if (!activeTab.value) activeTab.value = downloaders.value[0].name
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
}
|
}
|
||||||
@@ -31,21 +26,21 @@ function jumpTab(tab: string) {
|
|||||||
router.push('/subscribe/movie?tab=' + tab)
|
router.push('/subscribe/movie?tab=' + tab)
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(async () => {
|
||||||
loadDownloaderSetting()
|
await loadDownloaderSetting()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div v-if="enabledDownloaders.length > 0">
|
<div v-if="downloaders.length > 0">
|
||||||
<VTabs v-model="activeTab">
|
<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>
|
<span class="mx-5">{{ item.name }}</span>
|
||||||
</VTab>
|
</VTab>
|
||||||
</VTabs>
|
</VTabs>
|
||||||
|
|
||||||
<VWindow v-model="activeTab" class="mt-5 disable-tab-transition" :touch="false">
|
<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>
|
<transition name="fade-slide" appear>
|
||||||
<DownloadingListView :name="item.name" />
|
<DownloadingListView :name="item.name" />
|
||||||
</transition>
|
</transition>
|
||||||
|
|||||||
Reference in New Issue
Block a user