codepet 1.0.17 → 1.0.19
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 +9 -13
- package/package.json +1 -1
package/bin/codepet.js
CHANGED
|
@@ -16,9 +16,11 @@ const { execSync } = require('child_process');
|
|
|
16
16
|
|
|
17
17
|
// 跨平台 Python 命令检测
|
|
18
18
|
function getPython() {
|
|
19
|
-
|
|
19
|
+
// Windows 优先 python,Mac/Linux 优先 python3
|
|
20
|
+
const order = process.platform === 'win32' ? ['python', 'python3'] : ['python3', 'python'];
|
|
21
|
+
for (const cmd of order) {
|
|
20
22
|
try {
|
|
21
|
-
execSync(`${cmd}
|
|
23
|
+
execSync(`${cmd} -c "print(1)"`, { stdio: 'ignore' });
|
|
22
24
|
return cmd;
|
|
23
25
|
} catch {}
|
|
24
26
|
}
|
|
@@ -485,17 +487,11 @@ function doPopup() {
|
|
|
485
487
|
} else if (process.platform === 'win32') {
|
|
486
488
|
// Windows: 弹新 PowerShell 窗口,自动开启 ANSI 彩色支持
|
|
487
489
|
const script = path.join(__dirname, '..', 'scripts', 'polaroid.py').replace(/\\/g, '/');
|
|
488
|
-
//
|
|
489
|
-
const
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
$
|
|
493
|
-
try { Set-ItemProperty HKCU:\\Console VirtualTerminalLevel -Type DWORD -Value 1 -ErrorAction SilentlyContinue } catch {}
|
|
494
|
-
& ${PYTHON} "${script}" ${pet.character} ${scene} 40
|
|
495
|
-
Read-Host
|
|
496
|
-
`;
|
|
497
|
-
fs.writeFileSync(tmpPs1, ps1Content, 'utf-8');
|
|
498
|
-
execSync(`start powershell -NoProfile -ExecutionPolicy Bypass -File "${tmpPs1}"`, { shell: true, stdio: 'ignore' });
|
|
490
|
+
// 写 .bat 文件调用 PowerShell(最可靠的弹窗方式)
|
|
491
|
+
const tmpBat = path.join(os.tmpdir(), 'codepet_photo.bat');
|
|
492
|
+
const batContent = `@echo off\r\ntitle 📸 Ai小蓝鲸照相馆\r\n${PYTHON} "${script}" ${pet.character} ${scene} 40\r\nif errorlevel 1 (echo. & echo 出错了,请确认已安装 Pillow: pip install Pillow wcwidth)\r\npause >nul\r\n`;
|
|
493
|
+
fs.writeFileSync(tmpBat, batContent, 'utf-8');
|
|
494
|
+
execSync(`start "" "${tmpBat}"`, { shell: true, stdio: 'ignore' });
|
|
499
495
|
} else {
|
|
500
496
|
// Linux: 尝试终端弹窗
|
|
501
497
|
const script = path.join(__dirname, '..', 'scripts', 'polaroid.py');
|