codepet 1.0.11 → 1.0.13
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/bin/codepet.js +16 -9
- package/package.json +1 -1
package/bin/codepet.js
CHANGED
|
@@ -482,17 +482,24 @@ function doPopup() {
|
|
|
482
482
|
const script = path.join(__dirname, '..', 'scripts', 'polaroid.py');
|
|
483
483
|
const escapedScript = script.replace(/'/g, "'\\''");
|
|
484
484
|
execSync(`osascript -e 'tell application "Terminal" to do script "export HISTFILE=/dev/null && export BASH_SILENCE_DEPRECATION_WARNING=1 && export PS1=\\\"\\\" && clear && ${PYTHON} \\\"${escapedScript}\\\" ${pet.character} ${scene} 40 2>/dev/null && printf \\\"\\\\033[?25l\\\" && cat > /dev/null"' -e 'tell application "Terminal" to activate' &`, { shell: true, stdio: 'ignore' });
|
|
485
|
+
} else if (process.platform === 'win32') {
|
|
486
|
+
// Windows: 弹新 PowerShell 窗口,自动开启 ANSI 彩色支持
|
|
487
|
+
const script = path.join(__dirname, '..', 'scripts', 'polaroid.py').replace(/\\/g, '/');
|
|
488
|
+
const enableAnsi = `[Console]::OutputEncoding=[Text.Encoding]::UTF8; $Host.UI.RawUI.WindowTitle='📸 Ai小蓝鲸照相馆'; Set-ItemProperty HKCU:\\\\Console VirtualTerminalLevel -Type DWORD -Value 1 -ErrorAction SilentlyContinue;`;
|
|
489
|
+
const psCmd = `${enableAnsi} ${PYTHON} '${script}' ${pet.character} ${scene} 40 2>$null; Read-Host '按回车关闭'`;
|
|
490
|
+
execSync(`start powershell -NoProfile -Command "${psCmd}"`, { shell: true, stdio: 'ignore' });
|
|
485
491
|
} else {
|
|
486
|
-
//
|
|
487
|
-
const script = path.join(__dirname, '..', 'scripts', '
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
execSync(`${openCmd} "${photoPath}"`, { stdio: 'ignore', shell: true });
|
|
492
|
+
// Linux: 尝试终端弹窗
|
|
493
|
+
const script = path.join(__dirname, '..', 'scripts', 'polaroid.py');
|
|
494
|
+
if (process.env.DISPLAY) {
|
|
495
|
+
try {
|
|
496
|
+
execSync(`gnome-terminal -- bash -c '${PYTHON} "${script}" ${pet.character} ${scene} 40; read' 2>/dev/null &`, { shell: true, stdio: 'ignore' });
|
|
497
|
+
} catch {
|
|
498
|
+
try { execSync(`${PYTHON} "${script}" ${pet.character} ${scene} 40`, { stdio: 'inherit' }); } catch {}
|
|
494
499
|
}
|
|
495
|
-
}
|
|
500
|
+
} else {
|
|
501
|
+
try { execSync(`${PYTHON} "${script}" ${pet.character} ${scene} 40`, { stdio: 'inherit' }); } catch {}
|
|
502
|
+
}
|
|
496
503
|
}
|
|
497
504
|
}
|
|
498
505
|
|