From 4f1c40af12c90daaa2d0e7c5df3c448a6e353757 Mon Sep 17 00:00:00 2001 From: sokouu87 <160479016+sokouu87@users.noreply.github.com> Date: Fri, 21 Aug 2026 06:21:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=B0=E4=BD=8F=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=BB=93=E6=9E=9C=E7=9A=84=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E9=80=89=E6=8B=A9=20(#691)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/resource.vue | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/pages/resource.vue b/src/pages/resource.vue index 3507dbc5..37b456ec 100644 --- a/src/pages/resource.vue +++ b/src/pages/resource.vue @@ -283,6 +283,18 @@ const isSubtitleSearch = computed(() => resultType.value === 'subtitle') // 视图类型,从localStorage中读取 const viewType = ref(normalizeTorrentViewType(localStorage.getItem('MPTorrentsViewType'))) +// 排序条件与方向,从localStorage中读取,让上次的选择在下次进入结果页时继续生效 +const torrentSortFieldStorageKey = 'MPTorrentsSortField' +const torrentSortTypeStorageKey = 'MPTorrentsSortType' +const savedSortField = localStorage.getItem(torrentSortFieldStorageKey) +if (savedSortField && Object.prototype.hasOwnProperty.call(torrentFilter.sortTitles, savedSortField)) { + torrentFilter.sortField.value = savedSortField +} +const savedSortType = localStorage.getItem(torrentSortTypeStorageKey) +if (savedSortType === 'asc' || savedSortType === 'desc') { + torrentFilter.sortType.value = savedSortType +} + // 智能推荐相关 // 从全局设置中获取 AI_RECOMMEND_ENABLED 状态 const aiRecommendEnabled = computed(() => { @@ -434,6 +446,12 @@ watch( { deep: true }, ) +// 记住排序选择 +watch([() => torrentFilter.sortField.value, () => torrentFilter.sortType.value], ([field, type]) => { + localStorage.setItem(torrentSortFieldStorageKey, field) + localStorage.setItem(torrentSortTypeStorageKey, type) +}) + // 应用筛选 function applyFilter() { if (isSubtitleSearch.value) return