diff --git a/mateclaw-server/src/main/java/vip/mate/wiki/model/WikiRawMaterialEntity.java b/mateclaw-server/src/main/java/vip/mate/wiki/model/WikiRawMaterialEntity.java index 5010712b..351d8c14 100644 --- a/mateclaw-server/src/main/java/vip/mate/wiki/model/WikiRawMaterialEntity.java +++ b/mateclaw-server/src/main/java/vip/mate/wiki/model/WikiRawMaterialEntity.java @@ -55,6 +55,18 @@ public class WikiRawMaterialEntity { /** 错误信息 */ private String errorMessage; + /** + * RFC-012 M2 v2 UI:当前处理阶段(null 未开始 / "route" / "phase-b" / "done")。 + * 供前端决定是否显示进度条以及显示"准备中"还是具体进度。 + */ + private String progressPhase; + + /** RFC-012 M2 v2 UI:本次处理计划的总页数(route 阶段确定后写入)。 */ + private Integer progressTotal; + + /** RFC-012 M2 v2 UI:已完成的页数(每个 phase B 页成功后 +1)。 */ + private Integer progressDone; + @TableField(fill = FieldFill.INSERT) private LocalDateTime createTime; diff --git a/mateclaw-server/src/main/java/vip/mate/wiki/service/WikiProcessingService.java b/mateclaw-server/src/main/java/vip/mate/wiki/service/WikiProcessingService.java index 3dfb92a6..b4550487 100644 --- a/mateclaw-server/src/main/java/vip/mate/wiki/service/WikiProcessingService.java +++ b/mateclaw-server/src/main/java/vip/mate/wiki/service/WikiProcessingService.java @@ -22,9 +22,11 @@ import vip.mate.wiki.model.WikiRawMaterialEntity; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Semaphore; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; /** @@ -50,6 +52,20 @@ public class WikiProcessingService { /** 并行 chunk / 材料处理执行器(JDK 21 虚拟线程);Listener 跨包需要引用,故 public */ public static final ExecutorService WIKI_EXECUTOR = Executors.newVirtualThreadPerTaskExecutor(); + /** + * RFC-012 M2 v2 UI v2:单 raw 的进度计数器,多个并行 chunk 的 {@code processChunkTwoPhase} + * 共享同一份 atomic 计数,避免 6 个 chunk 各写各的 progress 字段时互相覆盖(导致 UI 永远 preparing)。 + *
+ * 生命周期:{@code processRawMaterial} 入口 put,try/finally 出口 remove。
+ */
+ private static final class ProgressCounter {
+ final AtomicInteger total = new AtomicInteger(0);
+ final AtomicInteger done = new AtomicInteger(0);
+ final AtomicBoolean phaseBStarted = new AtomicBoolean(false);
+ }
+
+ private final ConcurrentHashMap
+ * 在 {@code WikiProcessingService.processChunkTwoPhase} 的四个节点被调用:
+ *
+ *
+ */
+ @Transactional
+ public void updateProgress(Long id, String phase, int done, int total) {
+ WikiRawMaterialEntity entity = rawMapper.selectById(id);
+ if (entity == null) return;
+ entity.setProgressPhase(phase);
+ entity.setProgressDone(done);
+ entity.setProgressTotal(total);
+ rawMapper.updateById(entity);
+ }
+
@Transactional
public void updateProcessingStatus(Long id, String status, String errorMessage) {
WikiRawMaterialEntity entity = rawMapper.selectById(id);
diff --git a/mateclaw-server/src/main/resources/db/migration/h2/V8__wiki_raw_progress.sql b/mateclaw-server/src/main/resources/db/migration/h2/V8__wiki_raw_progress.sql
new file mode 100644
index 00000000..d5c583aa
--- /dev/null
+++ b/mateclaw-server/src/main/resources/db/migration/h2/V8__wiki_raw_progress.sql
@@ -0,0 +1,6 @@
+-- V8: wiki raw material two-phase digest progress fields, for UI progress bar
+-- RFC-012 M2 v2 UI follow-up: expose per-raw progress (current phase + pages done / total planned)
+-- so the frontend can render a determinate progress bar instead of an opaque "处理中" badge.
+ALTER TABLE mate_wiki_raw_material ADD COLUMN IF NOT EXISTS progress_phase VARCHAR(32) DEFAULT NULL;
+ALTER TABLE mate_wiki_raw_material ADD COLUMN IF NOT EXISTS progress_total INT DEFAULT 0;
+ALTER TABLE mate_wiki_raw_material ADD COLUMN IF NOT EXISTS progress_done INT DEFAULT 0;
diff --git a/mateclaw-server/src/main/resources/db/migration/mysql/V8__wiki_raw_progress.sql b/mateclaw-server/src/main/resources/db/migration/mysql/V8__wiki_raw_progress.sql
new file mode 100644
index 00000000..d5c583aa
--- /dev/null
+++ b/mateclaw-server/src/main/resources/db/migration/mysql/V8__wiki_raw_progress.sql
@@ -0,0 +1,6 @@
+-- V8: wiki raw material two-phase digest progress fields, for UI progress bar
+-- RFC-012 M2 v2 UI follow-up: expose per-raw progress (current phase + pages done / total planned)
+-- so the frontend can render a determinate progress bar instead of an opaque "处理中" badge.
+ALTER TABLE mate_wiki_raw_material ADD COLUMN IF NOT EXISTS progress_phase VARCHAR(32) DEFAULT NULL;
+ALTER TABLE mate_wiki_raw_material ADD COLUMN IF NOT EXISTS progress_total INT DEFAULT 0;
+ALTER TABLE mate_wiki_raw_material ADD COLUMN IF NOT EXISTS progress_done INT DEFAULT 0;
diff --git a/mateclaw-ui/src/i18n/locales/en-US.ts b/mateclaw-ui/src/i18n/locales/en-US.ts
index 12b84e6c..847f5479 100644
--- a/mateclaw-ui/src/i18n/locales/en-US.ts
+++ b/mateclaw-ui/src/i18n/locales/en-US.ts
@@ -1196,6 +1196,9 @@ export default {
partial: 'PARTIAL',
failed: 'FAILED',
},
+ progress: {
+ preparing: 'Preparing…',
+ },
},
cronJobs: {
kicker: 'Automation',
diff --git a/mateclaw-ui/src/i18n/locales/zh-CN.ts b/mateclaw-ui/src/i18n/locales/zh-CN.ts
index 5c957f89..96b9adc6 100644
--- a/mateclaw-ui/src/i18n/locales/zh-CN.ts
+++ b/mateclaw-ui/src/i18n/locales/zh-CN.ts
@@ -1206,6 +1206,9 @@ export default {
partial: '部分完成',
failed: '失败',
},
+ progress: {
+ preparing: '准备中…',
+ },
},
cronJobs: {
kicker: '自动执行',
diff --git a/mateclaw-ui/src/stores/useWikiStore.ts b/mateclaw-ui/src/stores/useWikiStore.ts
index bdd6e903..afd37f30 100644
--- a/mateclaw-ui/src/stores/useWikiStore.ts
+++ b/mateclaw-ui/src/stores/useWikiStore.ts
@@ -26,6 +26,10 @@ export interface WikiRawMaterial {
lastProcessedAt: string | null
errorMessage: string | null
createTime: string
+ // RFC-012 M2 v2 UI:两阶段消化进度字段(后端在 route 后写 total,每页完成后 +1 done)
+ progressPhase: string | null
+ progressTotal: number
+ progressDone: number
}
export interface WikiPage {
diff --git a/mateclaw-ui/src/views/Wiki/components/RawMaterialPanel.vue b/mateclaw-ui/src/views/Wiki/components/RawMaterialPanel.vue
index 273ad122..e13ddc6a 100644
--- a/mateclaw-ui/src/views/Wiki/components/RawMaterialPanel.vue
+++ b/mateclaw-ui/src/views/Wiki/components/RawMaterialPanel.vue
@@ -56,35 +56,56 @@
{{ t('wiki.noRawMaterials') }}