@aiyiran/myclaw 1.0.255 → 1.0.256

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.
@@ -193,6 +193,19 @@
193
193
  var headerRight = document.createElement('span');
194
194
  headerRight.style.cssText = 'display:flex;align-items:center;gap:10px;';
195
195
 
196
+ // 展示间跳转(发布按钮左边)
197
+ var showcaseLink = document.createElement('a');
198
+ var _scEnv = detectEnvironment();
199
+ var _scClaw = _scEnv.remote ? _scEnv.clawName : (lastKnownClawName || '');
200
+ var _scWs = getWorkspaceId();
201
+ showcaseLink.href = 'https://www.yiranlaoshi.com/showcase?claw=' + _scClaw + '&workspace=' + _scWs;
202
+ showcaseLink.target = '_blank';
203
+ showcaseLink.textContent = '\uD83D\uDC41 \u9879\u76EE\u96C6';
204
+ showcaseLink.style.cssText = 'cursor:pointer;padding:2px 10px;border-radius:3px;font-size:12px;background:rgba(255,255,255,0.08);transition:background 0.15s;color:#cdd6f4;text-decoration:none;';
205
+ showcaseLink.onmouseenter = function () { showcaseLink.style.background = 'rgba(255,255,255,0.18)'; };
206
+ showcaseLink.onmouseleave = function () { showcaseLink.style.background = 'rgba(255,255,255,0.08)'; };
207
+ headerRight.appendChild(showcaseLink);
208
+
196
209
  var publishBtn = document.createElement('span');
197
210
  publishBtn.textContent = '\u53D1\u5E03';
198
211
  publishBtn.style.cssText = 'cursor:pointer;padding:2px 10px;border-radius:3px;font-size:12px;background:rgba(255,255,255,0.08);transition:background 0.15s;';
@@ -418,6 +431,26 @@
418
431
  fname.appendChild(badge);
419
432
  }
420
433
 
434
+ // 复制相对路径按钮
435
+ var copyPathBtn = document.createElement('span');
436
+ copyPathBtn.textContent = '[复制]';
437
+ copyPathBtn.style.cssText = 'color:#6c6caa;font-size:10px;font-weight:bold;flex-shrink:0;cursor:pointer;transition:color 0.15s;';
438
+ copyPathBtn.onmouseenter = function () { copyPathBtn.style.color = '#a78bfa'; };
439
+ copyPathBtn.onmouseleave = function () { copyPathBtn.style.color = '#6c6caa'; };
440
+ copyPathBtn.onclick = function (e) {
441
+ e.stopPropagation();
442
+ var relativePath = getWorkspaceId() + '/' + (asset.path || '');
443
+ navigator.clipboard.writeText(relativePath).then(function () {
444
+ copyPathBtn.textContent = '[已复制]';
445
+ copyPathBtn.style.color = '#10b981';
446
+ setTimeout(function () {
447
+ copyPathBtn.textContent = '[复制]';
448
+ copyPathBtn.style.color = '#6c6caa';
449
+ }, 1500);
450
+ });
451
+ };
452
+ fname.appendChild(copyPathBtn);
453
+
421
454
  fname.appendChild(nameSpan);
422
455
 
423
456
  row.appendChild(time);
@@ -848,6 +881,16 @@
848
881
  'animation: myclaw-success-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1)',
849
882
  ].join(';');
850
883
 
884
+ // 右上角关闭按钮
885
+ var successCloseX = document.createElement('span');
886
+ successCloseX.textContent = '\u2715';
887
+ successCloseX.style.cssText = 'position:absolute;top:12px;right:14px;cursor:pointer;font-size:16px;color:#888;padding:4px 6px;border-radius:3px;transition:background 0.15s;z-index:1;';
888
+ successCloseX.onmouseenter = function () { successCloseX.style.background = 'rgba(255,255,255,0.1)'; successCloseX.style.color = '#cdd6f4'; };
889
+ successCloseX.onmouseleave = function () { successCloseX.style.background = 'none'; successCloseX.style.color = '#888'; };
890
+ successCloseX.onclick = function () { var m = document.querySelector('#myclaw-publish-success'); if (m) m.remove(); };
891
+ box.style.position = 'relative';
892
+ box.appendChild(successCloseX);
893
+
851
894
  // 头部:庆祝动画区
852
895
  var hero = document.createElement('div');
853
896
  hero.style.cssText = [
@@ -986,15 +1029,10 @@
986
1029
  var qrSection = document.createElement('div');
987
1030
  qrSection.style.cssText = 'display:flex;flex-direction:column;align-items:center;gap:6px;padding-top:4px;';
988
1031
 
989
- var qrCanvas = document.createElement('canvas');
990
- qrCanvas.style.cssText = 'width:140px;height:140px;border-radius:6px;';
991
- try {
992
- generateQR(qrCanvas, data.permanent_url, 280);
993
- } catch (e) {
994
- console.warn('[myclaw-artifacts] QR generate error:', e);
995
- qrCanvas.style.display = 'none';
996
- }
997
- qrSection.appendChild(qrCanvas);
1032
+ var qrDiv = document.createElement('div');
1033
+ qrDiv.style.cssText = 'width:140px;height:140px;border-radius:6px;overflow:hidden;background:#fff;display:flex;align-items:center;justify-content:center;';
1034
+ loadAndGenerateQR(qrDiv, data.permanent_url, 140);
1035
+ qrSection.appendChild(qrDiv);
998
1036
 
999
1037
  var qrHint = document.createElement('div');
1000
1038
  qrHint.style.cssText = 'font-size:11px;color:#888;font-family:monospace;';
@@ -1035,7 +1073,7 @@
1035
1073
  footer.appendChild(showcaseBtn);
1036
1074
 
1037
1075
  var closeSuccessBtn = document.createElement('button');
1038
- closeSuccessBtn.textContent = '\u5F00\u5FC3\uFF01';
1076
+ closeSuccessBtn.textContent = '\u6211\u8981\u518D\u6539\u6539\uFF01';
1039
1077
  closeSuccessBtn.style.cssText = [
1040
1078
  'padding: 10px 40px',
1041
1079
  'background: #4a4a7a',
@@ -1074,8 +1112,38 @@
1074
1112
  return row;
1075
1113
  }
1076
1114
 
1077
- // ═══ 轻量 QR 码生成(纯 JS,无依赖) ═══
1078
- // 基于 qrcode-generator (MIT) 的核心算法精简版
1115
+ // ═══ QR 码生成(qrcodejs,按需从 CDN 加载) ═══
1116
+ function loadAndGenerateQR(container, text, size) {
1117
+ function doGenerate() {
1118
+ try {
1119
+ new window.QRCode(container, {
1120
+ text: text,
1121
+ width: size,
1122
+ height: size,
1123
+ colorDark: '#000000',
1124
+ colorLight: '#ffffff',
1125
+ correctLevel: window.QRCode.CorrectLevel.M,
1126
+ });
1127
+ } catch (e) {
1128
+ console.warn('[myclaw-artifacts] QR generate error:', e);
1129
+ container.style.display = 'none';
1130
+ }
1131
+ }
1132
+ if (window.QRCode) {
1133
+ doGenerate();
1134
+ return;
1135
+ }
1136
+ var script = document.createElement('script');
1137
+ script.src = 'https://cdn.bootcdn.net/ajax/libs/qrcodejs/1.0.0/qrcode.min.js';
1138
+ script.onload = function () { doGenerate(); };
1139
+ script.onerror = function () {
1140
+ console.warn('[myclaw-artifacts] Failed to load qrcodejs');
1141
+ container.style.display = 'none';
1142
+ };
1143
+ document.head.appendChild(script);
1144
+ }
1145
+
1146
+ // 以下为废弃的旧版手写 QR 实现(已不使用,保留以备回滚)
1079
1147
  function generateQR(canvas, text, size) {
1080
1148
  // 使用 Google Charts API 的轻量替代:用 img 加载 QR 码
1081
1149
  // 但为了避免外部依赖,这里使用内嵌的极简 QR 生成
package/index.js CHANGED
@@ -334,6 +334,10 @@ function runNew() {
334
334
  console.log(colors.dim + '如果唤醒失败,可手动发送命令:' + NC);
335
335
  console.log(' ' + Y + 'openclaw agent --agent ' + agentId + ' --message "你好"' + NC);
336
336
  console.log('');
337
+
338
+ // 在桌面创建/覆盖浏览器快捷图标
339
+ createDesktopShortcut('http://127.0.0.1:18789?token=' + TOKEN);
340
+
337
341
  process.exit(0);
338
342
  }
339
343
  }
@@ -813,6 +817,50 @@ function runOpen() {
813
817
  console.log('');
814
818
  }
815
819
 
820
+ // ============================================================================
821
+ // 桌面快捷方式(浏览器入口图标)
822
+ // ============================================================================
823
+
824
+ function createDesktopShortcut(url) {
825
+ const fs = require('fs');
826
+ const platform = os.platform();
827
+ const desktopPath = path.join(os.homedir(), 'Desktop');
828
+
829
+ if (!fs.existsSync(desktopPath)) {
830
+ console.log('[shortcut] ⚠ 未找到桌面目录,跳过');
831
+ return;
832
+ }
833
+
834
+ if (platform === 'darwin') {
835
+ // macOS: .webloc 文件,双击用默认浏览器打开
836
+ const webloc = path.join(desktopPath, 'OpenClaw.webloc');
837
+ const content = `<?xml version="1.0" encoding="UTF-8"?>
838
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
839
+ <plist version="1.0">
840
+ <dict>
841
+ <key>URL</key>
842
+ <string>${url}</string>
843
+ </dict>
844
+ </plist>`;
845
+ fs.writeFileSync(webloc, content, 'utf8');
846
+ console.log('[shortcut] ✅ 桌面快捷方式已更新: OpenClaw.webloc');
847
+ } else if (platform === 'linux') {
848
+ // Linux / WSL: .desktop 文件
849
+ const desktop = path.join(desktopPath, 'OpenClaw.desktop');
850
+ const content = `[Desktop Entry]
851
+ Type=Link
852
+ Name=OpenClaw
853
+ URL=${url}
854
+ Icon=text-html
855
+ `;
856
+ fs.writeFileSync(desktop, content, 'utf8');
857
+ try { execSync('chmod +x "' + desktop + '"', { stdio: 'pipe' }); } catch {}
858
+ console.log('[shortcut] ✅ 桌面快捷方式已更新: OpenClaw.desktop');
859
+ } else {
860
+ console.log('[shortcut] ⚠ Windows 请使用 mc bat 创建桌面快捷方式');
861
+ }
862
+ }
863
+
816
864
  // ============================================================================
817
865
  // Patch / Unpatch / Restart
818
866
  // ============================================================================
@@ -1215,7 +1263,9 @@ function showMachineMenu() {
1215
1263
  console.log(colors.green + ' → 已选择: ' + selected.name + ' (' + selected.claw + ')' + colors.nc);
1216
1264
  console.log(' ' + colors.dim + '→ 正在用 Chrome 打开...' + colors.nc);
1217
1265
  const { execSync } = require('child_process');
1218
- execSync('open -a "Google Chrome" "https://' + selected.claw + '.kekouen.cn?token=aiyiran"', { stdio: 'ignore' });
1266
+ const machineUrl = 'https://' + selected.claw + '.kekouen.cn?token=aiyiran';
1267
+ execSync('open -a "Google Chrome" "' + machineUrl + '"', { stdio: 'ignore' });
1268
+ createDesktopShortcut(machineUrl);
1219
1269
  } else {
1220
1270
  console.log('[' + colors.red + '错误' + colors.nc + '] 无效选择');
1221
1271
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.255",
3
+ "version": "1.0.256",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {