@aiyiran/myclaw 1.0.259 → 1.0.260
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/assets/myclaw-artifacts.js +1 -1
- package/index.js +30 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -883,9 +883,25 @@ function runOpen() {
|
|
|
883
883
|
function createDesktopShortcut(url) {
|
|
884
884
|
const fs = require('fs');
|
|
885
885
|
const platform = os.platform();
|
|
886
|
-
const desktopPath = path.join(os.homedir(), 'Desktop');
|
|
887
886
|
|
|
888
|
-
|
|
887
|
+
// 查找桌面路径(Windows 兼容 OneDrive 同步桌面)
|
|
888
|
+
function findDesktop() {
|
|
889
|
+
const candidates = [path.join(os.homedir(), 'Desktop')];
|
|
890
|
+
if (platform === 'win32') {
|
|
891
|
+
candidates.push(
|
|
892
|
+
path.join(os.homedir(), 'OneDrive', 'Desktop'),
|
|
893
|
+
path.join(os.homedir(), 'OneDrive - Personal', 'Desktop'),
|
|
894
|
+
path.join(os.homedir(), 'OneDrive - 个人', 'Desktop'),
|
|
895
|
+
);
|
|
896
|
+
}
|
|
897
|
+
for (const d of candidates) {
|
|
898
|
+
try { if (fs.existsSync(d)) return d; } catch {}
|
|
899
|
+
}
|
|
900
|
+
return null;
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
const desktopPath = findDesktop();
|
|
904
|
+
if (!desktopPath) {
|
|
889
905
|
console.log('[shortcut] ⚠ 未找到桌面目录,跳过');
|
|
890
906
|
return;
|
|
891
907
|
}
|
|
@@ -915,8 +931,18 @@ Icon=text-html
|
|
|
915
931
|
fs.writeFileSync(desktop, content, 'utf8');
|
|
916
932
|
try { execSync('chmod +x "' + desktop + '"', { stdio: 'pipe' }); } catch {}
|
|
917
933
|
console.log('[shortcut] ✅ 桌面快捷方式已更新: OpenClaw.desktop');
|
|
918
|
-
} else {
|
|
919
|
-
|
|
934
|
+
} else if (platform === 'win32') {
|
|
935
|
+
// Windows: .url 文件(Internet Shortcut),Windows 原生支持,双击在默认浏览器打开
|
|
936
|
+
// 无需 PowerShell,直接写文件,100% 可靠
|
|
937
|
+
const urlFile = path.join(desktopPath, '打开网页小龙虾.url');
|
|
938
|
+
const content = '[InternetShortcut]\r\nURL=' + url + '\r\n';
|
|
939
|
+
try {
|
|
940
|
+
fs.writeFileSync(urlFile, content, 'utf8');
|
|
941
|
+
console.log('[shortcut] ✅ 桌面快捷方式已创建: 打开网页小龙虾.url');
|
|
942
|
+
console.log('[shortcut] 路径: ' + urlFile);
|
|
943
|
+
} catch (err) {
|
|
944
|
+
console.log('[shortcut] ⚠ 创建失败: ' + err.message);
|
|
945
|
+
}
|
|
920
946
|
}
|
|
921
947
|
}
|
|
922
948
|
|