@aiyiran/myclaw 1.0.250 → 1.0.251
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 +112 -65
- package/assets/myclaw-inject.js +20 -3
- package/package.json +1 -1
|
@@ -426,10 +426,18 @@
|
|
|
426
426
|
});
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
-
// ═══
|
|
429
|
+
// ═══ 预览弹框 ═══
|
|
430
|
+
var IMAGE_TYPES = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp', 'bmp', 'avif', 'ico'];
|
|
431
|
+
|
|
432
|
+
function isImageAsset(asset) {
|
|
433
|
+
return asset.type && IMAGE_TYPES.indexOf(asset.type.toLowerCase()) !== -1;
|
|
434
|
+
}
|
|
435
|
+
|
|
430
436
|
function openPreviewModal(data, asset) {
|
|
431
437
|
if (document.querySelector('#myclaw-artifacts-preview')) return;
|
|
432
438
|
|
|
439
|
+
var previewUrl = buildPreviewUrl(data, asset.path);
|
|
440
|
+
|
|
433
441
|
var overlay = document.createElement('div');
|
|
434
442
|
overlay.id = 'myclaw-artifacts-preview';
|
|
435
443
|
overlay.style.cssText = [
|
|
@@ -438,85 +446,124 @@
|
|
|
438
446
|
'left: 0',
|
|
439
447
|
'width: 100vw',
|
|
440
448
|
'height: 100vh',
|
|
441
|
-
'background: rgba(0, 0, 0, 0.
|
|
449
|
+
'background: rgba(0, 0, 0, 0.7)',
|
|
442
450
|
'z-index: 99999',
|
|
443
451
|
'display: flex',
|
|
444
452
|
'align-items: center',
|
|
445
453
|
'justify-content: center',
|
|
446
454
|
'animation: myclaw-fade-in 0.15s ease',
|
|
447
455
|
].join(';');
|
|
456
|
+
overlay.onclick = function (e) { if (e.target === overlay) closePreviewModal(); };
|
|
448
457
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
458
|
+
// 标题栏(共用)
|
|
459
|
+
function makeHeader(label) {
|
|
460
|
+
var header = document.createElement('div');
|
|
461
|
+
header.style.cssText = [
|
|
462
|
+
'display: flex',
|
|
463
|
+
'align-items: center',
|
|
464
|
+
'justify-content: space-between',
|
|
465
|
+
'padding: 8px 14px',
|
|
466
|
+
'background: #2d2d3f',
|
|
467
|
+
'color: #cdd6f4',
|
|
468
|
+
'font-size: 13px',
|
|
469
|
+
'font-family: monospace',
|
|
470
|
+
'user-select: none',
|
|
471
|
+
'flex-shrink: 0',
|
|
472
|
+
'border-radius: 8px 8px 0 0',
|
|
473
|
+
].join(';');
|
|
474
|
+
header.innerHTML = '<span>' + label + '</span>';
|
|
475
|
+
|
|
476
|
+
var right = document.createElement('span');
|
|
477
|
+
right.style.cssText = 'display:flex;align-items:center;gap:10px;';
|
|
478
|
+
|
|
479
|
+
var openBtn = document.createElement('span');
|
|
480
|
+
openBtn.textContent = '\u5728\u65B0\u9875\u9762\u6253\u5F00';
|
|
481
|
+
openBtn.style.cssText = 'cursor:pointer;padding:4px 10px;border-radius:4px;font-size:12px;background:rgba(255,255,255,0.08);transition:background 0.15s;';
|
|
482
|
+
openBtn.onmouseenter = function () { openBtn.style.background = 'rgba(255,255,255,0.18)'; };
|
|
483
|
+
openBtn.onmouseleave = function () { openBtn.style.background = 'rgba(255,255,255,0.08)'; };
|
|
484
|
+
openBtn.onclick = function () {
|
|
485
|
+
window.open(previewUrl, '_blank');
|
|
486
|
+
navigator.clipboard.writeText(previewUrl).then(function () {
|
|
487
|
+
openBtn.textContent = '\u2713 \u5DF2\u590D\u5236';
|
|
488
|
+
setTimeout(function () { openBtn.textContent = '\u5728\u65B0\u9875\u9762\u6253\u5F00'; }, 1500);
|
|
489
|
+
});
|
|
490
|
+
};
|
|
491
|
+
right.appendChild(openBtn);
|
|
492
|
+
|
|
493
|
+
var closeBtn = document.createElement('span');
|
|
494
|
+
closeBtn.textContent = '\u2715';
|
|
495
|
+
closeBtn.style.cssText = 'cursor:pointer;padding:4px 10px;border-radius:4px;font-size:18px;font-weight:bold;transition:background 0.15s;';
|
|
496
|
+
closeBtn.onmouseenter = function () { closeBtn.style.background = 'rgba(255,255,255,0.15)'; };
|
|
497
|
+
closeBtn.onmouseleave = function () { closeBtn.style.background = 'none'; };
|
|
498
|
+
closeBtn.onclick = function () { closePreviewModal(); };
|
|
499
|
+
right.appendChild(closeBtn);
|
|
500
|
+
header.appendChild(right);
|
|
501
|
+
return header;
|
|
502
|
+
}
|
|
460
503
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
'
|
|
474
|
-
].join(';');
|
|
475
|
-
header.innerHTML = '<span>\uD83C\uDFA8 ' + (asset.name || '预览') + '</span>';
|
|
504
|
+
if (isImageAsset(asset)) {
|
|
505
|
+
// ── 图片模式:img 弹框,自适应尺寸 ──
|
|
506
|
+
var imgBox = document.createElement('div');
|
|
507
|
+
imgBox.style.cssText = [
|
|
508
|
+
'display: flex',
|
|
509
|
+
'flex-direction: column',
|
|
510
|
+
'background: #1e1e2e',
|
|
511
|
+
'border-radius: 8px',
|
|
512
|
+
'box-shadow: 0 8px 32px rgba(0,0,0,0.6)',
|
|
513
|
+
'max-width: 92vw',
|
|
514
|
+
'max-height: 92vh',
|
|
515
|
+
'overflow: hidden',
|
|
516
|
+
].join(';');
|
|
476
517
|
|
|
477
|
-
|
|
478
|
-
|
|
518
|
+
imgBox.appendChild(makeHeader('\uD83D\uDDBC\uFE0F ' + (asset.name || asset.path)));
|
|
519
|
+
|
|
520
|
+
var img = document.createElement('img');
|
|
521
|
+
img.src = previewUrl;
|
|
522
|
+
img.alt = asset.name || asset.path;
|
|
523
|
+
img.style.cssText = [
|
|
524
|
+
'display: block',
|
|
525
|
+
'max-width: 92vw',
|
|
526
|
+
'max-height: calc(92vh - 44px)',
|
|
527
|
+
'width: auto',
|
|
528
|
+
'height: auto',
|
|
529
|
+
'object-fit: contain',
|
|
530
|
+
].join(';');
|
|
479
531
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
532
|
+
imgBox.appendChild(img);
|
|
533
|
+
overlay.appendChild(imgBox);
|
|
534
|
+
} else {
|
|
535
|
+
// ── 非图片:iframe 全屏模式 ──
|
|
536
|
+
var box = document.createElement('div');
|
|
537
|
+
box.style.cssText = [
|
|
538
|
+
'width: 98vw',
|
|
539
|
+
'height: 96vh',
|
|
540
|
+
'background: #1e1e2e',
|
|
541
|
+
'border-radius: 8px',
|
|
542
|
+
'overflow: hidden',
|
|
543
|
+
'display: flex',
|
|
544
|
+
'flex-direction: column',
|
|
545
|
+
'box-shadow: 0 8px 32px rgba(0,0,0,0.5)',
|
|
546
|
+
].join(';');
|
|
494
547
|
|
|
495
|
-
|
|
496
|
-
closeBtn.textContent = '\u2715';
|
|
497
|
-
closeBtn.style.cssText = 'cursor:pointer;padding:4px 10px;border-radius:4px;font-size:18px;font-weight:bold;transition:background 0.15s;';
|
|
498
|
-
closeBtn.onmouseenter = function () { closeBtn.style.background = 'rgba(255,255,255,0.15)'; };
|
|
499
|
-
closeBtn.onmouseleave = function () { closeBtn.style.background = 'none'; };
|
|
500
|
-
closeBtn.onclick = function () { closePreviewModal(); };
|
|
501
|
-
headerRight.appendChild(closeBtn);
|
|
502
|
-
header.appendChild(headerRight);
|
|
548
|
+
box.appendChild(makeHeader('\uD83C\uDFA8 ' + (asset.name || '预览')));
|
|
503
549
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
'
|
|
512
|
-
].join(';');
|
|
550
|
+
var iframe = document.createElement('iframe');
|
|
551
|
+
iframe.src = previewUrl + '?t=' + Date.now();
|
|
552
|
+
iframe.style.cssText = [
|
|
553
|
+
'flex: 1',
|
|
554
|
+
'width: 100%',
|
|
555
|
+
'border: none',
|
|
556
|
+
'background: #fff',
|
|
557
|
+
].join(';');
|
|
513
558
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
559
|
+
box.appendChild(iframe);
|
|
560
|
+
overlay.appendChild(box);
|
|
561
|
+
document.body.appendChild(overlay);
|
|
562
|
+
iframe.focus();
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
517
565
|
|
|
518
566
|
document.body.appendChild(overlay);
|
|
519
|
-
iframe.focus();
|
|
520
567
|
}
|
|
521
568
|
|
|
522
569
|
function closePreviewModal() {
|
package/assets/myclaw-inject.js
CHANGED
|
@@ -538,10 +538,27 @@ btn.addEventListener("click", function () {
|
|
|
538
538
|
" animation: myclaw-ring 1.5s ease-out infinite;",
|
|
539
539
|
" pointer-events: none;",
|
|
540
540
|
"}",
|
|
541
|
-
/*
|
|
541
|
+
/* 按钮处理中态:半透明 + 2秒红圈收缩动画 */
|
|
542
542
|
".myclaw-voice-stopping {",
|
|
543
|
-
" opacity: 0.
|
|
544
|
-
"
|
|
543
|
+
" opacity: 0.5 !important;",
|
|
544
|
+
" position: relative;",
|
|
545
|
+
"}",
|
|
546
|
+
".myclaw-voice-stopping::after {",
|
|
547
|
+
" content: '';",
|
|
548
|
+
" position: absolute;",
|
|
549
|
+
" top: 50%;",
|
|
550
|
+
" left: 50%;",
|
|
551
|
+
" width: 100%;",
|
|
552
|
+
" height: 100%;",
|
|
553
|
+
" border-radius: 50%;",
|
|
554
|
+
" border: 2px solid #ff4444;",
|
|
555
|
+
" transform: translate(-50%, -50%) scale(1.5);",
|
|
556
|
+
" animation: myclaw-countdown 2s linear forwards;",
|
|
557
|
+
" pointer-events: none;",
|
|
558
|
+
"}",
|
|
559
|
+
"@keyframes myclaw-countdown {",
|
|
560
|
+
" 0% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }",
|
|
561
|
+
" 100% { transform: translate(-50%, -50%) scale(0); opacity: 0; }",
|
|
545
562
|
"}",
|
|
546
563
|
/* textarea 录音态:左侧红色竖线 + 微弱红色背景 */
|
|
547
564
|
".myclaw-voice-active {",
|