@aiyiran/myclaw 1.0.260 → 1.0.261

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.
Files changed (2) hide show
  1. package/index.js +13 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1348,12 +1348,24 @@ function showMachineMenu() {
1348
1348
  console.log(colors.green + ' → 已选择: ' + selected.name + ' (' + selected.claw + ')' + colors.nc);
1349
1349
  console.log(' ' + colors.dim + '→ 正在打开浏览器...' + colors.nc);
1350
1350
  const { exec } = require('child_process');
1351
+ const fs = require('fs');
1351
1352
  const machineUrl = 'https://' + selected.claw + '.kekouen.cn?token=aiyiran';
1352
1353
  const platform = os.platform();
1353
1354
  if (platform === 'darwin') {
1354
1355
  exec('open -a "Google Chrome" "' + machineUrl + '"');
1355
1356
  } else if (platform === 'win32') {
1356
- exec('start "" "' + machineUrl + '"', { shell: true });
1357
+ // 优先找 Chrome,找不到才用默认浏览器
1358
+ const chromeCandidates = [
1359
+ path.join(process.env.PROGRAMFILES || 'C:\\Program Files', 'Google', 'Chrome', 'Application', 'chrome.exe'),
1360
+ path.join(process.env['PROGRAMFILES(X86)'] || 'C:\\Program Files (x86)', 'Google', 'Chrome', 'Application', 'chrome.exe'),
1361
+ path.join(process.env.LOCALAPPDATA || path.join(os.homedir(), 'AppData', 'Local'), 'Google', 'Chrome', 'Application', 'chrome.exe'),
1362
+ ];
1363
+ const chromePath = chromeCandidates.find(function (p) { try { return fs.existsSync(p); } catch { return false; } });
1364
+ if (chromePath) {
1365
+ exec('"' + chromePath + '" "' + machineUrl + '"');
1366
+ } else {
1367
+ exec('start "" "' + machineUrl + '"', { shell: true });
1368
+ }
1357
1369
  } else {
1358
1370
  exec('xdg-open "' + machineUrl + '"');
1359
1371
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.260",
3
+ "version": "1.0.261",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {