@cloud411716/fancy-webnovel 1.0.35 → 1.0.37
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/commands/scan/index.js +3 -3
- package/index.js +2 -2
- package/infra.js +6 -9
- package/package.json +1 -1
package/commands/scan/index.js
CHANGED
|
@@ -213,12 +213,12 @@ export function apply(ctx) {
|
|
|
213
213
|
const statusLine = new StatusLine(session);
|
|
214
214
|
let currentRankLabel = '';
|
|
215
215
|
|
|
216
|
-
disposers.push(ctx.events.on('fancy/scan:start', (_ctx,
|
|
216
|
+
disposers.push(ctx.events.on('fancy/scan:start', (_ctx, p, _ch, _ty, label) => {
|
|
217
217
|
currentRankLabel = label;
|
|
218
|
-
statusLine.update(`[${SPINNER[_spinnerIdx++ % 4]}] 正在采集:${platformLabel(
|
|
218
|
+
statusLine.update(`[${SPINNER[_spinnerIdx++ % 4]}] 正在采集:${platformLabel(p)} ${label} …`);
|
|
219
219
|
}));
|
|
220
220
|
|
|
221
|
-
disposers.push(ctx.events.on('fancy/scan:rank-done', (_ctx,
|
|
221
|
+
disposers.push(ctx.events.on('fancy/scan:rank-done', (_ctx, _p, _ch, _ty, ok, written) => {
|
|
222
222
|
statusLine.update(`[${SPINNER[_spinnerIdx++ % 4]}] ${currentRankLabel} ${ok ? `✓ 写入 ${written} 条` : '✗ 失败'}`);
|
|
223
223
|
}));
|
|
224
224
|
|
package/index.js
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* - File operations use Node.js fs (project roots may be outside workspace).
|
|
13
13
|
* - ctx.timer (via ctx.timeout()) handles all delays/timeouts.
|
|
14
14
|
*
|
|
15
|
-
* Required Cordis services: commands, userQuestions, timer
|
|
15
|
+
* Required Cordis services: commands, userQuestions, timer, events, fs
|
|
16
16
|
* (all are part of dsh-base, so this plugin works on dsh-tui, dsh-web, dsh-desktop).
|
|
17
17
|
*
|
|
18
18
|
* IMPORTANT: This plugin needs `danger-full-access` sandbox mode because it
|
|
@@ -27,7 +27,7 @@ import { apply as applyScan } from './commands/scan/index.js';
|
|
|
27
27
|
* Services this plugin requires from the Cordis context.
|
|
28
28
|
* All are provided by dsh-base, so this works on every DSH UI.
|
|
29
29
|
*/
|
|
30
|
-
export const inject = ['commands', 'userQuestions', 'timer'];
|
|
30
|
+
export const inject = ['commands', 'userQuestions', 'timer', 'events', 'fs'];
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Called once when the plugin is loaded into a Cordis context (fiber).
|
package/infra.js
CHANGED
|
@@ -12,9 +12,8 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
// --------------------------------------------------------------------------
|
|
15
|
-
// notify — return error result propagated through dsh-commands
|
|
15
|
+
// notify — return error/success result propagated through dsh-commands settle()
|
|
16
16
|
// --------------------------------------------------------------------------
|
|
17
|
-
//
|
|
18
17
|
|
|
19
18
|
/** Strip ANSI escape sequences from a string (defensive, prevents TTY leak). */
|
|
20
19
|
function stripAnsi(str) {
|
|
@@ -26,7 +25,7 @@ function stripAnsi(str) {
|
|
|
26
25
|
* @param {'error'|'success'} kind
|
|
27
26
|
* @param {string} text
|
|
28
27
|
* @returns {{ kind: 'error'|'success', text: string }} Result propagated through
|
|
29
|
-
* dsh-commands
|
|
28
|
+
* dsh-commands settle() → command/done → channel.notify() (TUI toast)
|
|
30
29
|
* and command/done (Web left-panel with real commandId prefix)
|
|
31
30
|
*/
|
|
32
31
|
export function notify(session, kind, text) {
|
|
@@ -122,18 +121,18 @@ export function scanProgress(ctx, phase, data) {
|
|
|
122
121
|
switch (phase) {
|
|
123
122
|
case 'start':
|
|
124
123
|
ctx.events.emit('fancy/scan:start', data.platform, data.channel, data.type, data.label);
|
|
125
|
-
break
|
|
124
|
+
break;
|
|
126
125
|
case 'book':
|
|
127
126
|
ctx.events.emit('fancy/scan:book', data.platform, data.channel, data.type,
|
|
128
127
|
data.index, data.total, data.title, data.rank);
|
|
129
|
-
break
|
|
128
|
+
break;
|
|
130
129
|
case 'rank-done':
|
|
131
130
|
ctx.events.emit('fancy/scan:rank-done', data.platform, data.channel, data.type,
|
|
132
131
|
data.ok, data.written, data.failed, data.errorMsg);
|
|
133
|
-
break
|
|
132
|
+
break;
|
|
134
133
|
case 'done':
|
|
135
134
|
ctx.events.emit('fancy/scan:done', data.platform, data.totalBooks, data.totalFiles, data.ok);
|
|
136
|
-
break
|
|
135
|
+
break;
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
138
|
|
|
@@ -156,5 +155,3 @@ export async function writeFile(filepath, content, encoding = 'utf-8') {
|
|
|
156
155
|
mkdirSync(dirname(filepath), { recursive: true });
|
|
157
156
|
writeFileSync(filepath, content, encoding);
|
|
158
157
|
}
|
|
159
|
-
|
|
160
|
-
|