diff --git a/src/components/form/SubscribeEditForm.vue b/src/components/form/SubscribeEditForm.vue index a802af56..2226acac 100644 --- a/src/components/form/SubscribeEditForm.vue +++ b/src/components/form/SubscribeEditForm.vue @@ -7,6 +7,8 @@ import type { Site, Subscribe } from '@/api/types' // 输入参数 const props = defineProps({ subid: Number, + default_config: Boolean, + type: String, }) // 定义触发的自定义事件 @@ -63,6 +65,51 @@ async function updateSubscribeInfo() { } } +// 设置用户设置的默认订阅规则 +async function saveDefaultSubscribeConfig() { + try { + let subscribe_config_url = "" + if (props.type == "电影") { + subscribe_config_url = 'system/setting/DefaultMovieSubscribeConfig' + } else { + subscribe_config_url = 'system/setting/DefaultTvSubscribeConfig' + } + const result: { [key: string]: any } = await api.post( + subscribe_config_url, + subscribeForm.value) + if (result.success) { + $toast.success(props.type + '订阅默认规则保存成功') + } else { + $toast.error(props.type + '订阅默认规则保存失败!') + } + // 通知父组件刷新 + emit('default_config') + } + catch (error) { + console.log(error) + } +} + +// 查询用户设置的默认订阅规则 +async function queryDefaultSubscribeConfig() { + try { + let subscribe_config_url = "" + if (props.type == "电影") { + subscribe_config_url = 'system/setting/DefaultMovieSubscribeConfig' + } else { + subscribe_config_url = 'system/setting/DefaultTvSubscribeConfig' + } + const result: { [key: string]: any } = await api.get(subscribe_config_url) + + if (result.data.value) { + subscribeForm.value = result.data?.value ?? '' + } + } + catch (error) { + console.log(error) + } +} + // 获取站点列表数据 async function loadSites() { try { @@ -213,6 +260,9 @@ watchEffect(() => { getSiteList() getSubscribeInfo() } + if (props.default_config) { + queryDefaultSubscribeConfig() + } }) @@ -222,7 +272,7 @@ watchEffect(() => { max-width="60rem" > @@ -234,6 +284,7 @@ watchEffect(() => { md="8" > { - + 取消订阅 保存 diff --git a/src/views/subscribe/SubscribeListView.vue b/src/views/subscribe/SubscribeListView.vue index 094760fe..9c4ecb83 100644 --- a/src/views/subscribe/SubscribeListView.vue +++ b/src/views/subscribe/SubscribeListView.vue @@ -4,6 +4,7 @@ import api from '@/api' import type { Subscribe } from '@/api/types' import NoDataFound from '@/components/NoDataFound.vue' import SubscribeCard from '@/components/cards/SubscribeCard.vue' +import SubscribeEditForm from '@/components/form/SubscribeEditForm.vue' import store from '@/store' // 输入参数 @@ -17,6 +18,12 @@ const isRefreshed = ref(false) // 数据列表 const dataList = ref([]) +// 定义触发的自定义事件 +const emit = defineEmits(['default_config']) + +// 弹窗 +const subscribeEditDialog = ref(false) + // 获取订阅列表数据 async function fetchData() { try { @@ -88,6 +95,18 @@ const filteredDataList = computed(() => { error-description="请通过搜索添加电影、电视剧订阅。" /> + + + + + +