fix: 今日新增筛选filteredTopics未处理'today'导致始终为空,状态筛选改为全量拉取保统计准确

- filteredTopics 对 filterStatus='today' 直接返回 this.topics(服务器已按日期过滤),避免按不存在的 status 再次过滤导致空列表
- fetchTopics 改为只有 'today' 走服务端 ?today=true;其他状态仍然全量拉取后客户端过滤,保证 statusStats 统计按钮数字准确
- 保留 watch 移除(用户能自由清除筛选)
This commit is contained in:
Yuzhiran Dev
2026-05-18 06:14:15 +08:00
parent a46fedabb5
commit bb50d5d925
+3 -10
View File
@@ -190,7 +190,7 @@ const TopicsApp = {
},
computed: {
filteredTopics() {
if (!this.filterStatus) return this.topics;
if (!this.filterStatus || this.filterStatus === 'today') return this.topics;
const map = { 'pending': ['pending','待处理'], 'review': ['review','待审查'], 'ready': ['ready','待发布'], 'published': ['published','已发布'] };
const allowed = map[this.filterStatus] || [this.filterStatus];
return this.topics.filter(t => allowed.includes(t.status));
@@ -235,16 +235,9 @@ const TopicsApp = {
async fetchTopics() {
this.loadingTable = true;
try {
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 : ''));
const params = this.filterStatus === 'today' ? '?today=true' : '';
const data = await this.api('/api/topics' + params);
this.topics = data || [];
if (qs) this.$message.success(`加载 ${this.filterStatus} 选题成功`);
} catch (error) {
console.error('获取选题失败:', error);
this.$message.error(`获取选题失败: ${error.message}`);