From ddc5320f713d7b5f59436fb6ba79455a3662065e Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 8 May 2025 10:35:07 +0800 Subject: [PATCH] =?UTF-8?q?fix=20https://github.com/jxxghp/MoviePilot/issu?= =?UTF-8?q?es/4211#issuecomment-2858674237=20=E8=AE=A2=E9=98=85=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E7=9B=B8=E4=BA=92=E5=B9=B2=E6=89=B0=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/subscribe/SubscribeListView.vue | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/views/subscribe/SubscribeListView.vue b/src/views/subscribe/SubscribeListView.vue index 7db603cd..56e5cc30 100644 --- a/src/views/subscribe/SubscribeListView.vue +++ b/src/views/subscribe/SubscribeListView.vue @@ -34,10 +34,6 @@ const props = defineProps({ // 是否刷新过 let isRefreshed = ref(false) -// 顺序存储键值 -const localOrderKey = props.type === t('media.movie') ? 'MP_SUBSCRIBE_MOVIE_ORDER' : 'MP_SUBSCRIBE_TV_ORDER' -const orderRequestKey = props.type === t('media.movie') ? 'SubscribeMovieOrder' : 'SubscribeTvOrder' - // 刷新状态 const loading = ref(false) @@ -53,6 +49,10 @@ const orderConfig = ref<{ id: number }[]>([]) // 显示的订阅列表 const displayList = ref([]) +// 顺序存储键值(计算属性) +const localOrderKey = computed(() => (props.type === '电影' ? 'MP_SUBSCRIBE_MOVIE_ORDER' : 'MP_SUBSCRIBE_TV_ORDER')) +const orderRequestKey = computed(() => (props.type === '电影' ? 'SubscribeMovieOrder' : 'SubscribeTvOrder')) + // 监听dataList变化,同步更新displayList watch([dataList, () => props.keyword], () => { if (superUser) @@ -74,26 +74,27 @@ watch([dataList, () => props.keyword], () => { // 加载顺序 async function loadSubscribeOrderConfig() { // 顺序配置 - const local_order = localStorage.getItem(localOrderKey) + const local_order = localStorage.getItem(localOrderKey.value) if (local_order) { orderConfig.value = JSON.parse(local_order) } else { const response = await api.get(`/user/config/${orderRequestKey}`) if (response && response.data && response.data.value) { orderConfig.value = response.data.value - localStorage.setItem(localOrderKey, JSON.stringify(orderConfig.value)) + localStorage.setItem(localOrderKey.value, JSON.stringify(orderConfig.value)) } } } // 按order的顺序排序 -function sortSubscribeOrder() { +async function sortSubscribeOrder() { if (!orderConfig.value) { return } if (displayList.value.length === 0) { return } + await loadSubscribeOrderConfig() displayList.value.sort((a, b) => { const aIndex = orderConfig.value.findIndex((item: { id: number }) => item.id === a.id) const bIndex = orderConfig.value.findIndex((item: { id: number }) => item.id === b.id) @@ -107,7 +108,7 @@ async function saveSubscribeOrder() { const orderObj = displayList.value.map(item => ({ id: item.id })) orderConfig.value = orderObj const orderString = JSON.stringify(orderObj) - localStorage.setItem(localOrderKey, orderString) + localStorage.setItem(localOrderKey.value, orderString) // 保存到服务端 try { @@ -136,7 +137,6 @@ function historyDone() { } onMounted(async () => { - await loadSubscribeOrderConfig() await fetchData() if (props.subid) { // 找到这个订阅