@cloud411716/fancy-webnovel 0.1.88 → 0.1.90
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 +25 -4
package/package.json
CHANGED
|
@@ -154,7 +154,7 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
|
|
|
154
154
|
});
|
|
155
155
|
const answer = choice.answers[0]?.selected?.[0] ?? choice.answers[0]?.custom;
|
|
156
156
|
if (!answer || answer === '我自己安装') {
|
|
157
|
-
notify(session, '⚠️ 已取消。请手动安装 Chromium 后再次运行 /fancy-scan。\n安装命令:npm install -g @playwright/cli --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright-cli install
|
|
157
|
+
notify(session, '⚠️ 已取消。请手动安装 Chromium 后再次运行 /fancy-scan。\n安装命令:npm install -g @playwright/cli --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright-cli install-browser --with-deps');
|
|
158
158
|
return undefined;
|
|
159
159
|
}
|
|
160
160
|
|
|
@@ -163,12 +163,14 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
|
|
|
163
163
|
const installStop = startActivity(session);
|
|
164
164
|
|
|
165
165
|
const installProc = spawn('sh', ['-c',
|
|
166
|
-
'npm install -g @playwright/cli --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright-cli install
|
|
166
|
+
'npm install -g @playwright/cli --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright-cli install-browser --with-deps'
|
|
167
167
|
], {
|
|
168
|
-
stdio: ['
|
|
168
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
169
169
|
cwd: process.cwd(),
|
|
170
170
|
});
|
|
171
171
|
const installOut = [];
|
|
172
|
+
let sudoPrompted = false;
|
|
173
|
+
|
|
172
174
|
installProc.stdout.on('data', d => { installOut.push(d.toString()); });
|
|
173
175
|
installProc.stderr.on('data', d => { installOut.push(d.toString()); });
|
|
174
176
|
|
|
@@ -178,6 +180,25 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
|
|
|
178
180
|
installStop();
|
|
179
181
|
});
|
|
180
182
|
|
|
183
|
+
// 检测 sudo 密码提示
|
|
184
|
+
installProc.stderr.on('data', async (d) => {
|
|
185
|
+
if (sudoPrompted) return;
|
|
186
|
+
const text = d.toString();
|
|
187
|
+
if (/password|密码|sudo/i.test(text)) {
|
|
188
|
+
sudoPrompted = true;
|
|
189
|
+
installProc.pause?.(); // 暂停输出,防止刷屏
|
|
190
|
+
const pwdResult = await ctx.userQuestions.ask({
|
|
191
|
+
questions: [{
|
|
192
|
+
question: '🔐 安装过程需要 sudo 权限,请输入密码:',
|
|
193
|
+
hideCustomInput: false,
|
|
194
|
+
}],
|
|
195
|
+
});
|
|
196
|
+
const pwd = pwdResult.answers[0]?.custom ?? '';
|
|
197
|
+
installProc.stdin?.write(pwd + '\n');
|
|
198
|
+
installProc.resume?.(); // 恢复输出
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
|
|
181
202
|
return new Promise((resolve) => {
|
|
182
203
|
installProc.on('close', async (code) => {
|
|
183
204
|
stopCancel(); // 移除取消监听
|
|
@@ -195,7 +216,7 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
|
|
|
195
216
|
resolve('retry');
|
|
196
217
|
} else {
|
|
197
218
|
const out = installOut.join('').slice(-300);
|
|
198
|
-
notify(session, `❌ Chromium 安装失败(exit ${code})。\n请手动运行以下命令后重试:\n npm install -g @playwright/cli --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright-cli install
|
|
219
|
+
notify(session, `❌ Chromium 安装失败(exit ${code})。\n请手动运行以下命令后重试:\n npm install -g @playwright/cli --registry=https://registry.npmmirror.com && PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright-cli install-browser --with-deps\n\n安装日志末尾:\n${out}`);
|
|
199
220
|
resolve(undefined);
|
|
200
221
|
}
|
|
201
222
|
});
|