From a46fedabb55556218e58a9350b1b89dc231a32ff Mon Sep 17 00:00:00 2001 From: Yuzhiran Dev Date: Mon, 18 May 2026 06:08:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=80=89=E9=A2=98=E9=A1=B5=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E8=BF=87=E6=BB=A4=E5=99=A8=E6=94=B9=E7=94=A8=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E8=BF=87=E6=BB=A4=EF=BC=8C=E7=A7=BB=E9=99=A4?= =?UTF-8?q?watch=E8=A6=86=E5=86=99URL=E5=8F=82=E6=95=B0=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E6=B8=85=E9=99=A4=E7=AD=9B=E9=80=89=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - fetchTopics 根据 filterStatus 发送 status/today 参数到后端,而非全量拉取后客户端过滤 - 移除 watch.topics 处理器,解决 URL 参数反复覆写用户筛选操作的问题 - 今日新增(?today=true)和服务端 status 参数均走 API 过滤 --- platform/frontend/topics.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/platform/frontend/topics.html b/platform/frontend/topics.html index e300698..74a7162 100644 --- a/platform/frontend/topics.html +++ b/platform/frontend/topics.html @@ -235,10 +235,16 @@ const TopicsApp = { async fetchTopics() { this.loadingTable = true; try { - const params = this.filterStatus === 'today' ? '?today=true' : ''; - const data = await this.api('/api/topics' + params); + const params = new URLSearchParams(); + if (this.filterStatus === 'today') { + params.set('today', 'true'); + } else if (this.filterStatus) { + params.set('status', this.filterStatus); + } + const qs = params.toString(); + const data = await this.api('/api/topics' + (qs ? '?' + qs : '')); this.topics = data || []; - this.$message.success('选题加载成功'); + if (qs) this.$message.success(`加载 ${this.filterStatus} 选题成功`); } catch (error) { console.error('获取选题失败:', error); this.$message.error(`获取选题失败: ${error.message}`); @@ -396,12 +402,6 @@ const TopicsApp = { .then(r => r.ok ? r.json() : Promise.reject()) .then(data => { this.currentUser = data.user; this.isAdmin = data.user.role === 'admin'; this.isLoggedIn = true; this.fetchTopics(); this.fetchTodayCount(); }) .catch(() => { localStorage.removeItem('authToken'); localStorage.removeItem('userRole'); localStorage.removeItem('currentUser'); window.location.href = '/login.html'; }); - }, - watch: { - topics() { - const urlFilter = new URLSearchParams(window.location.search).get('filter'); - if (urlFilter) this.filterStatus = urlFilter; - } } }; const app = Vue.createApp(TopicsApp);