|
|
@@ -45,10 +45,14 @@
|
|
|
<el-icon><Search /></el-icon>
|
|
|
搜索
|
|
|
</el-button>
|
|
|
- <el-button @click="refreshAllWorks" :loading="refreshing">
|
|
|
+ <el-button @click="refreshAllWorks" :loading="refreshing" v-if="!taskStore.runningSyncWorksTask">
|
|
|
<el-icon><Refresh /></el-icon>
|
|
|
同步作品
|
|
|
</el-button>
|
|
|
+ <el-button type="danger" @click="stopSyncWorks" v-else>
|
|
|
+ <el-icon><CircleCloseFilled /></el-icon>
|
|
|
+ 停止同步
|
|
|
+ </el-button>
|
|
|
<el-button type="success" @click="syncAllComments" :loading="syncingComments">
|
|
|
<el-icon><ChatDotSquare /></el-icon>
|
|
|
同步评论
|
|
|
@@ -590,6 +594,21 @@ async function refreshAllWorks() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// 停止正在运行的作品同步任务
|
|
|
+async function stopSyncWorks() {
|
|
|
+ const task = taskStore.runningSyncWorksTask;
|
|
|
+ if (!task) return;
|
|
|
+
|
|
|
+ try {
|
|
|
+ const ok = await taskStore.cancelTask(task.id);
|
|
|
+ if (ok) {
|
|
|
+ ElMessage.success('已发送取消请求,同步任务将停止');
|
|
|
+ }
|
|
|
+ } catch {
|
|
|
+ ElMessage.error('取消同步任务失败');
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
// WebSocket 连接用于接收同步结果
|
|
|
let ws: WebSocket | null = null;
|
|
|
let wsReconnectTimer: ReturnType<typeof setTimeout> | null = null;
|