@aiyiran/myclaw 1.0.256 → 1.0.257

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.
@@ -237,8 +237,35 @@
237
237
 
238
238
  content.innerHTML = '<div style="text-align:center;padding:32px;color:#888;">加载中...</div>';
239
239
 
240
+ // Fork 按钮底部栏
241
+ var panelFooter = document.createElement('div');
242
+ panelFooter.style.cssText = [
243
+ 'padding: 8px 10px',
244
+ 'background: #252536',
245
+ 'border-top: 1px solid #3d3d5c',
246
+ 'flex-shrink: 0',
247
+ ].join(';');
248
+ var forkPanelBtn = document.createElement('div');
249
+ forkPanelBtn.textContent = '\uD83D\uDD00 fork\u4ED6\u4EBA\u4F5C\u54C1';
250
+ forkPanelBtn.style.cssText = [
251
+ 'cursor: pointer',
252
+ 'padding: 6px 10px',
253
+ 'border-radius: 4px',
254
+ 'font-size: 12px',
255
+ 'font-family: monospace',
256
+ 'color: #cdd6f4',
257
+ 'background: rgba(255,255,255,0.06)',
258
+ 'text-align: center',
259
+ 'transition: background 0.15s',
260
+ ].join(';');
261
+ forkPanelBtn.onmouseenter = function () { forkPanelBtn.style.background = 'rgba(255,255,255,0.14)'; };
262
+ forkPanelBtn.onmouseleave = function () { forkPanelBtn.style.background = 'rgba(255,255,255,0.06)'; };
263
+ forkPanelBtn.onclick = function () { openForkModal(); };
264
+ panelFooter.appendChild(forkPanelBtn);
265
+
240
266
  panel.appendChild(header);
241
267
  panel.appendChild(content);
268
+ panel.appendChild(panelFooter);
242
269
  document.body.appendChild(panel);
243
270
 
244
271
  // 立即拉一次,后续由轮询更新
@@ -1505,6 +1532,179 @@
1505
1532
  if (modal) modal.remove();
1506
1533
  }
1507
1534
 
1535
+ // ═══ Fork 他人作品弹框 ═══
1536
+ function openForkModal() {
1537
+ if (document.querySelector('#myclaw-fork-modal')) return;
1538
+
1539
+ var overlay = document.createElement('div');
1540
+ overlay.id = 'myclaw-fork-modal';
1541
+ overlay.style.cssText = [
1542
+ 'position: fixed',
1543
+ 'top: 0',
1544
+ 'left: 0',
1545
+ 'width: 100vw',
1546
+ 'height: 100vh',
1547
+ 'background: rgba(0, 0, 0, 0.4)',
1548
+ 'z-index: 99999',
1549
+ 'display: flex',
1550
+ 'align-items: center',
1551
+ 'justify-content: center',
1552
+ 'animation: myclaw-fade-in 0.15s ease',
1553
+ ].join(';');
1554
+ overlay.onclick = function (e) { if (e.target === overlay) closeForkModal(); };
1555
+
1556
+ var box = document.createElement('div');
1557
+ box.style.cssText = [
1558
+ 'width: 480px',
1559
+ 'background: #1e1e2e',
1560
+ 'border-radius: 8px',
1561
+ 'overflow: hidden',
1562
+ 'display: flex',
1563
+ 'flex-direction: column',
1564
+ 'box-shadow: 0 8px 32px rgba(0,0,0,0.5)',
1565
+ ].join(';');
1566
+
1567
+ // 标题栏
1568
+ var forkHeader = document.createElement('div');
1569
+ forkHeader.style.cssText = [
1570
+ 'display: flex',
1571
+ 'align-items: center',
1572
+ 'justify-content: space-between',
1573
+ 'padding: 10px 14px',
1574
+ 'background: #2d2d3f',
1575
+ 'color: #cdd6f4',
1576
+ 'font-size: 13px',
1577
+ 'font-family: monospace',
1578
+ 'user-select: none',
1579
+ 'flex-shrink: 0',
1580
+ ].join(';');
1581
+ forkHeader.innerHTML = '<span>\uD83D\uDD00 Fork \u4ED6\u4EBA\u4F5C\u54C1</span>';
1582
+ var forkCloseBtn = document.createElement('span');
1583
+ forkCloseBtn.textContent = '\u2715';
1584
+ forkCloseBtn.style.cssText = 'cursor:pointer;padding:2px 6px;border-radius:3px;font-size:14px;transition:background 0.15s;';
1585
+ forkCloseBtn.onmouseenter = function () { forkCloseBtn.style.background = 'rgba(255,255,255,0.1)'; };
1586
+ forkCloseBtn.onmouseleave = function () { forkCloseBtn.style.background = 'none'; };
1587
+ forkCloseBtn.onclick = function () { closeForkModal(); };
1588
+ forkHeader.appendChild(forkCloseBtn);
1589
+
1590
+ // 表单
1591
+ var forkForm = document.createElement('div');
1592
+ forkForm.style.cssText = 'padding: 20px;display:flex;flex-direction:column;gap:10px;color:#cdd6f4;font-family:monospace;font-size:13px;';
1593
+
1594
+ var urlLabel = document.createElement('label');
1595
+ urlLabel.textContent = '\u4F5C\u54C1 URL';
1596
+ urlLabel.style.cssText = 'font-size:12px;color:#888;';
1597
+
1598
+ var urlInput = document.createElement('input');
1599
+ urlInput.type = 'text';
1600
+ urlInput.placeholder = 'https://cdn.yiranlaoshi.com/...';
1601
+ urlInput.style.cssText = [
1602
+ 'padding: 8px 10px',
1603
+ 'background: #252536',
1604
+ 'border: 1px solid #3d3d5c',
1605
+ 'border-radius: 4px',
1606
+ 'color: #cdd6f4',
1607
+ 'font-size: 13px',
1608
+ 'font-family: monospace',
1609
+ 'outline: none',
1610
+ ].join(';');
1611
+ urlInput.onfocus = function () { urlInput.style.borderColor = '#6c6caa'; };
1612
+ urlInput.onblur = function () { urlInput.style.borderColor = errVisible ? '#ff4444' : '#3d3d5c'; };
1613
+
1614
+ var errVisible = false;
1615
+ var errMsg = document.createElement('div');
1616
+ errMsg.style.cssText = 'font-size:12px;color:#ff4444;display:none;';
1617
+ errMsg.textContent = '\u8BF7\u8F93\u5165\u5B8C\u6574\u7684 URL\uFF08\u9700\u4EE5 http:// \u6216 https:// \u5F00\u5934\uFF09';
1618
+
1619
+ forkForm.appendChild(urlLabel);
1620
+ forkForm.appendChild(urlInput);
1621
+ forkForm.appendChild(errMsg);
1622
+
1623
+ // 确认按钮
1624
+ var forkSubmitBtn = document.createElement('button');
1625
+ forkSubmitBtn.textContent = '\u786E\u8BA4 Fork';
1626
+ forkSubmitBtn.style.cssText = [
1627
+ 'margin: 0 20px 20px',
1628
+ 'padding: 10px',
1629
+ 'background: #4a4a7a',
1630
+ 'border: none',
1631
+ 'border-radius: 4px',
1632
+ 'color: #cdd6f4',
1633
+ 'font-size: 13px',
1634
+ 'font-family: monospace',
1635
+ 'cursor: pointer',
1636
+ 'transition: background 0.15s',
1637
+ ].join(';');
1638
+ forkSubmitBtn.onmouseenter = function () { if (!forkSubmitBtn.disabled) forkSubmitBtn.style.background = '#5a5a9a'; };
1639
+ forkSubmitBtn.onmouseleave = function () { if (!forkSubmitBtn.disabled) forkSubmitBtn.style.background = '#4a4a7a'; };
1640
+
1641
+ forkSubmitBtn.onclick = function () {
1642
+ var url = urlInput.value.trim();
1643
+
1644
+ // 校验 URL 完整性
1645
+ var valid = false;
1646
+ try {
1647
+ var parsed = new URL(url);
1648
+ valid = parsed.protocol === 'http:' || parsed.protocol === 'https:';
1649
+ } catch (e) { valid = false; }
1650
+
1651
+ if (!valid) {
1652
+ urlInput.style.borderColor = '#ff4444';
1653
+ errMsg.style.display = 'block';
1654
+ errVisible = true;
1655
+ return;
1656
+ }
1657
+ urlInput.style.borderColor = '#3d3d5c';
1658
+ errMsg.style.display = 'none';
1659
+ errVisible = false;
1660
+
1661
+ forkSubmitBtn.disabled = true;
1662
+ forkSubmitBtn.textContent = '\u23F3 \u7B49\u5F85\u4E2D...';
1663
+ forkSubmitBtn.style.background = '#3a3a5a';
1664
+ forkSubmitBtn.style.cursor = 'default';
1665
+ urlInput.disabled = true;
1666
+
1667
+ fetch('https://claw.kekouen.cn/sync', {
1668
+ method: 'POST',
1669
+ headers: { 'Content-Type': 'application/json' },
1670
+ body: JSON.stringify({ url: url }),
1671
+ })
1672
+ .then(function (res) {
1673
+ if (!res.ok) throw new Error('HTTP ' + res.status);
1674
+ return res.json();
1675
+ })
1676
+ .then(function () {
1677
+ forkSubmitBtn.textContent = '\u2705 Fork \u6210\u529F\uFF01';
1678
+ forkSubmitBtn.style.background = '#10b981';
1679
+ setTimeout(function () { closeForkModal(); }, 2000);
1680
+ })
1681
+ .catch(function (err) {
1682
+ console.error('[myclaw-fork]', err);
1683
+ forkSubmitBtn.disabled = false;
1684
+ urlInput.disabled = false;
1685
+ forkSubmitBtn.textContent = '\u274C \u8BF7\u6C42\u5931\u8D25\uFF0C\u70B9\u51FB\u91CD\u8BD5';
1686
+ forkSubmitBtn.style.background = '#7a2a2a';
1687
+ forkSubmitBtn.style.cursor = 'pointer';
1688
+ setTimeout(function () {
1689
+ forkSubmitBtn.textContent = '\u786E\u8BA4 Fork';
1690
+ forkSubmitBtn.style.background = '#4a4a7a';
1691
+ }, 2500);
1692
+ });
1693
+ };
1694
+
1695
+ box.appendChild(forkHeader);
1696
+ box.appendChild(forkForm);
1697
+ box.appendChild(forkSubmitBtn);
1698
+ overlay.appendChild(box);
1699
+ document.body.appendChild(overlay);
1700
+ urlInput.focus();
1701
+ }
1702
+
1703
+ function closeForkModal() {
1704
+ var modal = document.querySelector('#myclaw-fork-modal');
1705
+ if (modal) modal.remove();
1706
+ }
1707
+
1508
1708
  // ═══ 注入样式 ═══
1509
1709
  function injectStyles() {
1510
1710
  if (document.querySelector('#myclaw-artifacts-styles')) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.256",
3
+ "version": "1.0.257",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {