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);