@cloud411716/fancy-webnovel 4.27.0 → 4.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/plugins/fancy-scan/index.js +29 -5
package/package.json
CHANGED
|
@@ -128,6 +128,9 @@ export async function runVisionRecognition({
|
|
|
128
128
|
manifestPath,
|
|
129
129
|
date,
|
|
130
130
|
signal,
|
|
131
|
+
// 视觉识别在任务表里的下标(生产是第 3 步,下标 2)。
|
|
132
|
+
// 不传时退回“改当前步骤”,保持测试与旧调用兼容。
|
|
133
|
+
taskIndex = null,
|
|
131
134
|
// 测试注入点:生产调用不传,默认就是真实的 LLM 派活与等待。
|
|
132
135
|
followup = llmFollowup,
|
|
133
136
|
waitTurn = waitForAnalysisTurn,
|
|
@@ -149,6 +152,20 @@ export async function runVisionRecognition({
|
|
|
149
152
|
const failed = [];
|
|
150
153
|
let recognisableIndex = 0;
|
|
151
154
|
|
|
155
|
+
// 不能直接用 tasks.progress():采集和视觉识别是交错进行的,当前步骤
|
|
156
|
+
// 可能还停在“采集榜单并截图”上。直接改当前步骤会把第二行也改成
|
|
157
|
+
// “LLM 视觉识别截图”,和第三行重复。这里锁定视觉步骤的下标。
|
|
158
|
+
const setProgress = (text) => {
|
|
159
|
+
if (tasks && Number.isInteger(taskIndex) && typeof tasks.progressAt === 'function') {
|
|
160
|
+
tasks.progressAt(taskIndex, text);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (tasks && typeof tasks.progress === 'function') tasks.progress(text);
|
|
164
|
+
};
|
|
165
|
+
if (tasks && Number.isInteger(taskIndex) && typeof tasks.activate === 'function') {
|
|
166
|
+
tasks.activate(taskIndex);
|
|
167
|
+
}
|
|
168
|
+
|
|
152
169
|
for (let manifestIndex = 0; manifestIndex < allCategories.length; manifestIndex += 1) {
|
|
153
170
|
if (signal?.aborted) {
|
|
154
171
|
return { ok: false, aborted: true, error: '操作已取消' };
|
|
@@ -240,7 +257,7 @@ export async function runVisionRecognition({
|
|
|
240
257
|
if (!parsed) {
|
|
241
258
|
results.push({ name: catName, error: lastError || '模型没有返回可解析的识别结果' });
|
|
242
259
|
failed.push({ name: catName, error: lastError || '模型没有返回可解析的识别结果' });
|
|
243
|
-
|
|
260
|
+
setProgress(`LLM 视觉识别截图(${recognisableIndex}/${recognisable.length} 题材)`);
|
|
244
261
|
continue;
|
|
245
262
|
}
|
|
246
263
|
|
|
@@ -258,7 +275,7 @@ export async function runVisionRecognition({
|
|
|
258
275
|
// “部分识别成功”写进 md,否则整篇都是占位书名。
|
|
259
276
|
results.push({ name: catName, error: '识别结果与截图清单无法对应' });
|
|
260
277
|
failed.push({ name: catName, error: '识别结果与截图清单无法对应' });
|
|
261
|
-
|
|
278
|
+
setProgress(`LLM 视觉识别截图(${recognisableIndex}/${recognisable.length} 题材)`);
|
|
262
279
|
continue;
|
|
263
280
|
}
|
|
264
281
|
results.push({ name: catName, books: merged.books });
|
|
@@ -268,7 +285,7 @@ export async function runVisionRecognition({
|
|
|
268
285
|
error: `${merged.missing.length} 本没有识别到:${merged.missing.join('、')}`,
|
|
269
286
|
});
|
|
270
287
|
}
|
|
271
|
-
|
|
288
|
+
setProgress(`LLM 视觉识别截图(${recognisableIndex}/${recognisable.length} 题材)`);
|
|
272
289
|
}
|
|
273
290
|
|
|
274
291
|
// 一个题材都没识别成功时不要写空 md —— 让上层按失败处理,
|
|
@@ -562,7 +579,10 @@ export async function apply(ctx) {
|
|
|
562
579
|
const rankRow = RANK_LISTS[platform]?.find(r => r.id === rankId);
|
|
563
580
|
const rankLabel = rankRow ? rankRow.label : rankId;
|
|
564
581
|
processedRanks += 1;
|
|
565
|
-
tasks.progress(
|
|
582
|
+
// 采集步骤固定是下标 1。不能走 tasks.progress():视觉识别与采集
|
|
583
|
+
// 交错进行,当前步骤可能已经被切到别处。
|
|
584
|
+
tasks.progressAt(
|
|
585
|
+
1,
|
|
566
586
|
`${scanMode === SCAN_MODE_VISION ? '采集榜单并截图' : '采集榜单数据'}` +
|
|
567
587
|
`(${processedRanks}/${rankIds.length}:${rankLabel})`
|
|
568
588
|
);
|
|
@@ -649,7 +669,10 @@ export async function apply(ctx) {
|
|
|
649
669
|
if (signal?.aborted) {
|
|
650
670
|
return notify(session, 'error', scan.notify({ type: 'cancelled' }));
|
|
651
671
|
}
|
|
652
|
-
|
|
672
|
+
// 视觉识别固定是下标 2。先激活它,再单独更新它的文案,
|
|
673
|
+
// 这样第二行“采集榜单并截图”不会被覆盖成同名步骤。
|
|
674
|
+
tasks.activate(2);
|
|
675
|
+
tasks.progressAt(2, `LLM 视觉识别截图(准备中:${rankLabel})`);
|
|
653
676
|
const vr = await runVisionRecognition({
|
|
654
677
|
invocation,
|
|
655
678
|
tasks,
|
|
@@ -657,6 +680,7 @@ export async function apply(ctx) {
|
|
|
657
680
|
manifestPath,
|
|
658
681
|
date: receipt.date || lastDate,
|
|
659
682
|
signal,
|
|
683
|
+
taskIndex: 2,
|
|
660
684
|
});
|
|
661
685
|
if (vr.aborted) {
|
|
662
686
|
return notify(session, 'error', scan.notify({ type: 'cancelled' }));
|