@cloud411716/fancy-webnovel 1.0.36 → 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.
@@ -55,7 +55,7 @@ const scan = {
55
55
  detail: opts.map(o => o.label).join('、'),
56
56
  hideCustomInput: true,
57
57
  multiSelect: true,
58
- options: [...opts, { id: 'cancel', label: '取消' }],
58
+ options: opts,
59
59
  };
60
60
  },
61
61
 
@@ -173,11 +173,6 @@ export function apply(ctx) {
173
173
  const selected = rankResult.answers[0]?.selected ?? [];
174
174
  const custom = rankResult.answers[0]?.custom?.trim();
175
175
 
176
- // "取消" is an explicit option — treat it as cancelled like bootstrap
177
- if (selected.includes('取消')) {
178
- return notify(session, 'error', scan.notify({ type: 'cancelled' }));
179
- }
180
-
181
176
  const rawChoices = selected.length > 0 ? selected : (custom ? [custom] : []);
182
177
  if (rawChoices.length === 0) {
183
178
  return notify(session, 'error', scan.notify({ type: 'cancelled' }));
@@ -218,12 +213,12 @@ export function apply(ctx) {
218
213
  const statusLine = new StatusLine(session);
219
214
  let currentRankLabel = '';
220
215
 
221
- disposers.push(ctx.events.on('fancy/scan:start', (_ctx, platform, _channel, _type, label) => {
216
+ disposers.push(ctx.events.on('fancy/scan:start', (_ctx, p, _ch, _ty, label) => {
222
217
  currentRankLabel = label;
223
- statusLine.update(`[${SPINNER[_spinnerIdx++ % 4]}] 正在采集:${platformLabel(platform)} ${label} …`);
218
+ statusLine.update(`[${SPINNER[_spinnerIdx++ % 4]}] 正在采集:${platformLabel(p)} ${label} …`);
224
219
  }));
225
220
 
226
- disposers.push(ctx.events.on('fancy/scan:rank-done', (_ctx, _platform, _channel, _type, ok, written) => {
221
+ disposers.push(ctx.events.on('fancy/scan:rank-done', (_ctx, _p, _ch, _ty, ok, written) => {
227
222
  statusLine.update(`[${SPINNER[_spinnerIdx++ % 4]}] ${currentRankLabel} ${ok ? `✓ 写入 ${written} 条` : '✗ 失败'}`);
228
223
  }));
229
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 settleThrown()
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 settleThrown() → command/done → channel.notify() (TUI toast)
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
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "1.0.36",
3
+ "version": "1.0.37",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {