@cloud411716/fancy-webnovel 0.1.97 → 0.1.98
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 +21 -26
package/package.json
CHANGED
|
@@ -162,12 +162,21 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
|
|
|
162
162
|
notify(session, '⏳ 正在下载 Chromium 浏览器(首次约 2-3 分钟),请耐心等待...\n');
|
|
163
163
|
const installStop = startActivity(session);
|
|
164
164
|
|
|
165
|
+
// 预先弹出密码框(不等 sudo 提示出现)
|
|
166
|
+
// 密码通过 stdin pipe 传入,用 sudo -S 确保 sudo 从 stdin 读
|
|
167
|
+
const pwdAskPromise = ctx.userQuestions.ask({
|
|
168
|
+
questions: [{
|
|
169
|
+
question: '🔐 安装 Chromium 需要 sudo 权限,请输入密码:',
|
|
170
|
+
hideCustomInput: false,
|
|
171
|
+
}],
|
|
172
|
+
});
|
|
173
|
+
|
|
165
174
|
const installProc = spawn('sh', ['-c',
|
|
166
|
-
'npm install -g playwright@1.40.0 --registry=https://registry.npmmirror.com &&
|
|
175
|
+
'sudo -S npm install -g playwright@1.40.0 --registry=https://registry.npmmirror.com && ' +
|
|
176
|
+
'sudo -S PLAYWRIGHT_DOWNLOAD_HOST=https://npmmirror.com/mirrors/playwright/ playwright install chromium --with-deps'
|
|
167
177
|
], {
|
|
168
178
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
169
179
|
cwd: process.cwd(),
|
|
170
|
-
setsid: true, // 创建新 session,无 controlling TTY,sudo 密码不会跑到输入框
|
|
171
180
|
});
|
|
172
181
|
const installOut = [];
|
|
173
182
|
|
|
@@ -180,33 +189,19 @@ async function runScanWithChromiumFix(ctx, session, invocation, { platform, leng
|
|
|
180
189
|
installStop();
|
|
181
190
|
});
|
|
182
191
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
if (
|
|
187
|
-
|
|
188
|
-
if (/password|密码|sudo/i.test(text)) {
|
|
189
|
-
sudoDialogPromise = ctx.userQuestions.ask({
|
|
190
|
-
questions: [{
|
|
191
|
-
question: '🔐 安装过程需要 sudo 权限,请输入密码:',
|
|
192
|
-
hideCustomInput: false,
|
|
193
|
-
}],
|
|
194
|
-
}).then(async (pwdResult) => {
|
|
195
|
-
const pwd = pwdResult.answers[0]?.custom ?? '';
|
|
196
|
-
installProc.stdin?.write(pwd + '\n');
|
|
197
|
-
}).catch(() => {});
|
|
198
|
-
}
|
|
199
|
-
});
|
|
192
|
+
// 预先弹出的密码框结果 → 写入子进程 stdin
|
|
193
|
+
pwdAskPromise.then(async (pwdResult) => {
|
|
194
|
+
const pwd = pwdResult.answers[0]?.custom ?? '';
|
|
195
|
+
if (pwd) installProc.stdin?.write(pwd + '\n');
|
|
196
|
+
}).catch(() => {});
|
|
200
197
|
|
|
201
198
|
return new Promise((resolve) => {
|
|
202
199
|
installProc.on('close', async (code) => {
|
|
203
|
-
//
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
]);
|
|
209
|
-
}
|
|
200
|
+
// 等预弹框完成
|
|
201
|
+
await Promise.race([
|
|
202
|
+
pwdAskPromise.catch(() => {}),
|
|
203
|
+
new Promise(r => setTimeout(r, 180000)),
|
|
204
|
+
]);
|
|
210
205
|
stopCancel(); // 移除取消监听
|
|
211
206
|
installStop();
|
|
212
207
|
if (code === 0) {
|