@aiyiran/myclaw 1.1.92 → 1.1.94
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.
|
@@ -791,6 +791,10 @@
|
|
|
791
791
|
var assetExt = (asset.path || '').split('.').pop().toLowerCase();
|
|
792
792
|
var isCSV = assetExt === 'csv';
|
|
793
793
|
var isPDF = assetExt === 'pdf';
|
|
794
|
+
var CODE_EXTS = ['js', 'jsx', 'ts', 'tsx', 'py', 'sh', 'bash', 'go', 'java', 'c', 'cpp', 'h', 'rs', 'rb', 'php', 'swift', 'kt', 'vue'];
|
|
795
|
+
var isCode = CODE_EXTS.indexOf(assetExt) !== -1;
|
|
796
|
+
var OFFICE_EXTS = ['ppt', 'pptx', 'doc', 'docx', 'xls', 'xlsx'];
|
|
797
|
+
var isOffice = OFFICE_EXTS.indexOf(assetExt) !== -1;
|
|
794
798
|
|
|
795
799
|
if (isImageAsset(asset)) {
|
|
796
800
|
// ── 图片模式:先显示固定大小的容器,img 异步加载渐显 ──
|
|
@@ -1017,6 +1021,134 @@
|
|
|
1017
1021
|
pdfIframe.focus();
|
|
1018
1022
|
return;
|
|
1019
1023
|
|
|
1024
|
+
} else if (isCode) {
|
|
1025
|
+
// ── 代码/文本模式:fetch 内容 → 带行号的代码查看器 ──
|
|
1026
|
+
var codeBox = document.createElement('div');
|
|
1027
|
+
codeBox.style.cssText = [
|
|
1028
|
+
'display: flex',
|
|
1029
|
+
'flex-direction: column',
|
|
1030
|
+
'background: #1e1e2e',
|
|
1031
|
+
'border-radius: 8px',
|
|
1032
|
+
'box-shadow: 0 8px 32px rgba(0,0,0,0.6)',
|
|
1033
|
+
'width: min(96vw, 1100px)',
|
|
1034
|
+
'height: min(90vh, 860px)',
|
|
1035
|
+
'overflow: hidden',
|
|
1036
|
+
].join(';');
|
|
1037
|
+
|
|
1038
|
+
codeBox.appendChild(makeHeader('📝 ' + (asset.name || asset.path)));
|
|
1039
|
+
|
|
1040
|
+
var codeBody = document.createElement('div');
|
|
1041
|
+
codeBody.style.cssText = [
|
|
1042
|
+
'flex: 1',
|
|
1043
|
+
'overflow: auto',
|
|
1044
|
+
'background: #13131f',
|
|
1045
|
+
'display: flex',
|
|
1046
|
+
].join(';');
|
|
1047
|
+
|
|
1048
|
+
var loadingMsgCode = document.createElement('div');
|
|
1049
|
+
loadingMsgCode.textContent = '加载中…';
|
|
1050
|
+
loadingMsgCode.style.cssText = 'color:#666;font-size:13px;font-family:monospace;padding:24px;';
|
|
1051
|
+
codeBody.appendChild(loadingMsgCode);
|
|
1052
|
+
codeBox.appendChild(codeBody);
|
|
1053
|
+
overlay.appendChild(codeBox);
|
|
1054
|
+
document.body.appendChild(overlay);
|
|
1055
|
+
|
|
1056
|
+
var codeApiUrl = MYCLAW_API_BASE + '/api/file?path=' + encodeURIComponent(getWorkspaceId() + '/' + asset.path) + '&t=' + Date.now();
|
|
1057
|
+
fetch(codeApiUrl)
|
|
1058
|
+
.then(function (r) { return r.text(); })
|
|
1059
|
+
.then(function (text) {
|
|
1060
|
+
codeBody.innerHTML = '';
|
|
1061
|
+
|
|
1062
|
+
// 行号列
|
|
1063
|
+
var lines = text.split('\n');
|
|
1064
|
+
// 去掉末尾空行
|
|
1065
|
+
if (lines.length > 0 && lines[lines.length - 1] === '') lines.pop();
|
|
1066
|
+
|
|
1067
|
+
var lineNums = document.createElement('div');
|
|
1068
|
+
lineNums.style.cssText = [
|
|
1069
|
+
'padding: 16px 0',
|
|
1070
|
+
'min-width: 48px',
|
|
1071
|
+
'text-align: right',
|
|
1072
|
+
'font-size: 13px',
|
|
1073
|
+
'font-family: monospace',
|
|
1074
|
+
'line-height: 1.6',
|
|
1075
|
+
'color: #444466',
|
|
1076
|
+
'background: #0e0e1a',
|
|
1077
|
+
'user-select: none',
|
|
1078
|
+
'flex-shrink: 0',
|
|
1079
|
+
'border-right: 1px solid #2a2a3e',
|
|
1080
|
+
].join(';');
|
|
1081
|
+
for (var n = 1; n <= lines.length; n++) {
|
|
1082
|
+
var numDiv = document.createElement('div');
|
|
1083
|
+
numDiv.textContent = n;
|
|
1084
|
+
numDiv.style.cssText = 'padding: 0 10px;';
|
|
1085
|
+
lineNums.appendChild(numDiv);
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
// 代码内容
|
|
1089
|
+
var codePre = document.createElement('pre');
|
|
1090
|
+
codePre.style.cssText = [
|
|
1091
|
+
'margin: 0',
|
|
1092
|
+
'padding: 16px 20px',
|
|
1093
|
+
'font-size: 13px',
|
|
1094
|
+
'font-family: monospace',
|
|
1095
|
+
'line-height: 1.6',
|
|
1096
|
+
'color: #cdd6f4',
|
|
1097
|
+
'flex: 1',
|
|
1098
|
+
'white-space: pre',
|
|
1099
|
+
'tab-size: 2',
|
|
1100
|
+
].join(';');
|
|
1101
|
+
|
|
1102
|
+
var codeEl = document.createElement('code');
|
|
1103
|
+
codeEl.textContent = text;
|
|
1104
|
+
codePre.appendChild(codeEl);
|
|
1105
|
+
|
|
1106
|
+
codeBody.appendChild(lineNums);
|
|
1107
|
+
codeBody.appendChild(codePre);
|
|
1108
|
+
|
|
1109
|
+
// 同步滚动行号
|
|
1110
|
+
codePre.parentElement.addEventListener('scroll', function () {
|
|
1111
|
+
lineNums.style.marginTop = '-' + codeBody.scrollTop + 'px';
|
|
1112
|
+
});
|
|
1113
|
+
codeBody.addEventListener('scroll', function () {
|
|
1114
|
+
lineNums.scrollTop = codeBody.scrollTop;
|
|
1115
|
+
});
|
|
1116
|
+
})
|
|
1117
|
+
.catch(function () { loadingMsgCode.textContent = '加载失败'; });
|
|
1118
|
+
return;
|
|
1119
|
+
|
|
1120
|
+
} else if (isOffice) {
|
|
1121
|
+
// ── Office 文档模式:Microsoft Office Online Viewer ──
|
|
1122
|
+
var officeBox = document.createElement('div');
|
|
1123
|
+
officeBox.style.cssText = [
|
|
1124
|
+
'width: 98vw',
|
|
1125
|
+
'height: 96vh',
|
|
1126
|
+
'background: #1e1e2e',
|
|
1127
|
+
'border-radius: 8px',
|
|
1128
|
+
'overflow: hidden',
|
|
1129
|
+
'display: flex',
|
|
1130
|
+
'flex-direction: column',
|
|
1131
|
+
'box-shadow: 0 8px 32px rgba(0,0,0,0.5)',
|
|
1132
|
+
].join(';');
|
|
1133
|
+
|
|
1134
|
+
var officeIcon = { ppt: '📊', pptx: '📊', doc: '📃', docx: '📃', xls: '📈', xlsx: '📈' };
|
|
1135
|
+
officeBox.appendChild(makeHeader((officeIcon[assetExt] || '📎') + ' ' + (asset.name || asset.path)));
|
|
1136
|
+
|
|
1137
|
+
var officeIframe = document.createElement('iframe');
|
|
1138
|
+
officeIframe.style.cssText = [
|
|
1139
|
+
'flex: 1',
|
|
1140
|
+
'width: 100%',
|
|
1141
|
+
'border: none',
|
|
1142
|
+
'background: #fff',
|
|
1143
|
+
].join(';');
|
|
1144
|
+
officeIframe.src = 'https://view.officeapps.live.com/op/embed.aspx?src=' + encodeURIComponent(previewUrl);
|
|
1145
|
+
|
|
1146
|
+
officeBox.appendChild(officeIframe);
|
|
1147
|
+
overlay.appendChild(officeBox);
|
|
1148
|
+
document.body.appendChild(overlay);
|
|
1149
|
+
officeIframe.focus();
|
|
1150
|
+
return;
|
|
1151
|
+
|
|
1020
1152
|
} else {
|
|
1021
1153
|
// ── 非图片:iframe 全屏模式 ──
|
|
1022
1154
|
var box = document.createElement('div');
|
|
@@ -2553,9 +2685,9 @@
|
|
|
2553
2685
|
|
|
2554
2686
|
var copyLocalBtn = document.createElement('button');
|
|
2555
2687
|
copyLocalBtn.textContent = '⚡ 立刻使用';
|
|
2556
|
-
copyLocalBtn.style.cssText = _btnBase + 'background:rgba(
|
|
2557
|
-
copyLocalBtn.onmouseenter = function () { copyLocalBtn.style.background = 'rgba(
|
|
2558
|
-
copyLocalBtn.onmouseleave = function () { copyLocalBtn.style.background = 'rgba(
|
|
2688
|
+
copyLocalBtn.style.cssText = _btnBase + 'background:rgba(239,68,68,0.2);border:1.5px solid rgba(239,68,68,0.7);color:#fca5a5;font-size:14px;font-weight:700;padding:7px 18px;letter-spacing:1px;';
|
|
2689
|
+
copyLocalBtn.onmouseenter = function () { copyLocalBtn.style.background = 'rgba(239,68,68,0.35)'; };
|
|
2690
|
+
copyLocalBtn.onmouseleave = function () { copyLocalBtn.style.background = 'rgba(239,68,68,0.2)'; };
|
|
2559
2691
|
|
|
2560
2692
|
var promptBtn = document.createElement('button');
|
|
2561
2693
|
promptBtn.textContent = '复制提示词';
|
package/package.json
CHANGED
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
|
|
32
32
|
你的任务需要用最快的速度完成:
|
|
33
33
|
|
|
34
|
-
1. 阅读 `
|
|
35
|
-
2.
|
|
36
|
-
3.
|
|
34
|
+
1. 阅读 `__student__.json`,了解任务步骤和评价目标
|
|
35
|
+
2. 阅读 `__teacher__.json`,了解训练重点和常见卡点
|
|
36
|
+
3. 用一两句话告诉我:这次任务的第一步是什么,我应该先做什么
|