From 367f4236ad7767e1136c955f6016d9affce2e964 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 2 Apr 2024 08:26:58 +0800 Subject: [PATCH] fix #92 --- src/components/form/SubscribeEditForm.vue | 70 +++++++++++------------ src/views/subscribe/SubscribeListView.vue | 18 +++--- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/components/form/SubscribeEditForm.vue b/src/components/form/SubscribeEditForm.vue index 2226acac..875aca44 100644 --- a/src/components/form/SubscribeEditForm.vue +++ b/src/components/form/SubscribeEditForm.vue @@ -7,7 +7,7 @@ import type { Site, Subscribe } from '@/api/types' // 输入参数 const props = defineProps({ subid: Number, - default_config: Boolean, + default: Boolean, type: String, }) @@ -68,42 +68,41 @@ 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) - } + 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('save') + } + catch (error) { + console.log(error) + } } // 查询用户设置的默认订阅规则 async function queryDefaultSubscribeConfig() { try { - let subscribe_config_url = "" - if (props.type == "电影") { + let subscribe_config_url = '' + if (props.type === '电影') subscribe_config_url = 'system/setting/DefaultMovieSubscribeConfig' - } else { + else subscribe_config_url = 'system/setting/DefaultTvSubscribeConfig' - } + const result: { [key: string]: any } = await api.get(subscribe_config_url) - if (result.data.value) { + if (result.data.value) subscribeForm.value = result.data?.value ?? '' - } } catch (error) { console.log(error) @@ -256,13 +255,12 @@ const effectOptions = ref([ ]) watchEffect(() => { - if (props.subid) { - getSiteList() + getSiteList() + if (props.subid) getSubscribeInfo() - } - if (props.default_config) { + + if (props.default) queryDefaultSubscribeConfig() - } }) @@ -272,7 +270,7 @@ watchEffect(() => { max-width="60rem" > @@ -284,7 +282,7 @@ watchEffect(() => { md="8" > { - + 取消订阅 保存 diff --git a/src/views/subscribe/SubscribeListView.vue b/src/views/subscribe/SubscribeListView.vue index 9c4ecb83..c4c418b4 100644 --- a/src/views/subscribe/SubscribeListView.vue +++ b/src/views/subscribe/SubscribeListView.vue @@ -18,9 +18,6 @@ const isRefreshed = ref(false) // 数据列表 const dataList = ref([]) -// 定义触发的自定义事件 -const emit = defineEmits(['default_config']) - // 弹窗 const subscribeEditDialog = ref(false) @@ -97,14 +94,17 @@ const filteredDataList = computed(() => { - - - + + + +