-
+
+
+ 共 {{ allTasks.length }} 条
+ { currentPage = p; }">
+
@@ -183,14 +184,20 @@ const TasksApp = {
const STATUS_NAMES = { 'pending': '等待中', 'running': '进行中', 'completed': '已完成', 'failed': '失败', 'cancelled': '已取消' };
return {
currentUser: { username: '' }, isAdmin: false, isLoggedIn: false,
- tasks: [], loading: false, filterStatus: '',
+ allTasks: [], tasks: [], loading: false, filterStatus: '',
showDetailDialog: false, detailTask: null,
schedulerJobs: [], schedulerLoading: false,
- totalTasks: 0, currentPage: 1, pageSize: 20,
+ currentPage: 1, pageSize: 10,
pollTimer: null,
SCHEDULER_JOBS,
}
},
+ computed: {
+ paginatedTasks() {
+ const start = (this.currentPage - 1) * this.pageSize;
+ return this.allTasks.slice(start, start + this.pageSize);
+ }
+ },
methods: {
getToken() { return localStorage.getItem('authToken'); },
async api(url, opts = {}) {
@@ -239,19 +246,20 @@ const TasksApp = {
},
startPolling() {
this.stopPolling();
- this.pollTimer = setInterval(() => this.loadTasks(), 5000);
+ this.pollTimer = setInterval(() => this.loadTasks(false), 5000);
},
stopPolling() {
if (this.pollTimer) { clearInterval(this.pollTimer); this.pollTimer = null; }
},
- async loadTasks() {
+ async loadTasks(resetPage = true) {
this.loading = true;
try {
- let url = `/api/tasks?limit=${this.pageSize}&offset=${(this.currentPage - 1) * this.pageSize}`;
+ let url = '/api/tasks?limit=200';
if (this.filterStatus) url += '&status=' + this.filterStatus;
const data = await this.api(url) || [];
- this.tasks = data;
- this.totalTasks = data.length < this.pageSize ? (this.currentPage - 1) * this.pageSize + data.length : this.currentPage * this.pageSize + 1;
+ const oldId = this.allTasks.length > 0 && this.allTasks[0] ? this.allTasks[0].task_id : null;
+ this.allTasks = data;
+ if (resetPage) this.currentPage = 1;
const hasRunning = data.some(t => t.status === 'running');
if (hasRunning) { this.startPolling(); } else { this.stopPolling(); }
} catch (e) { console.error(e); this.$message.error('加载任务列表失败: ' + e.message); }
diff --git a/platform/frontend/topics.html b/platform/frontend/topics.html
index 623fd87..b82e5c2 100644
--- a/platform/frontend/topics.html
+++ b/platform/frontend/topics.html
@@ -77,7 +77,8 @@
-
+
+ 共 {{ filteredTopics.length }} 条
@@ -197,7 +198,7 @@ const TopicsApp = {
publishPlatforms: { zhihu: true, wechat: true, xiaohongshu: true },
publishing: false,
savingContent: false,
- currentPage: 1, pageSize: 20
+ currentPage: 1, pageSize: 10
}
},
computed: {