@aiyiran/myclaw 1.1.36 → 1.1.38

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.
@@ -2387,6 +2387,33 @@
2387
2387
  var infoSpan = document.createElement('span');
2388
2388
  infoSpan.style.cssText = 'font-size:12px;color:#cdd6f4;font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;';
2389
2389
  infoSpan.textContent = tpl['系列'] + tpl['编号'] + ' ' + tpl['名称'];
2390
+ // 刷新按钮
2391
+ var refreshBtn = document.createElement('button');
2392
+ refreshBtn.textContent = '↺';
2393
+ refreshBtn.title = '刷新预览';
2394
+ refreshBtn.style.cssText = 'flex-shrink:0;padding:5px 10px;background:rgba(255,255,255,0.07);border:1px solid rgba(255,255,255,0.15);border-radius:4px;color:#cdd6f4;font-size:14px;font-family:monospace;cursor:pointer;transition:all 0.15s;white-space:nowrap;line-height:1;';
2395
+ refreshBtn.onmouseenter = function () { refreshBtn.style.background = 'rgba(255,255,255,0.14)'; };
2396
+ refreshBtn.onmouseleave = function () { refreshBtn.style.background = 'rgba(255,255,255,0.07)'; };
2397
+ refreshBtn.onclick = function () {
2398
+ var src = previewIframe.src;
2399
+ previewIframe.src = '';
2400
+ setTimeout(function () { previewIframe.src = src; }, 50);
2401
+ refreshBtn.style.transform = 'rotate(360deg)';
2402
+ refreshBtn.style.transition = 'transform 0.4s ease';
2403
+ setTimeout(function () { refreshBtn.style.transform = ''; refreshBtn.style.transition = 'all 0.15s'; }, 450);
2404
+ };
2405
+
2406
+ // 新窗口打开按钮
2407
+ var openNewBtn = document.createElement('button');
2408
+ openNewBtn.textContent = '↗';
2409
+ openNewBtn.title = '在新标签页打开';
2410
+ openNewBtn.style.cssText = 'flex-shrink:0;padding:5px 10px;background:rgba(255,255,255,0.07);border:1px solid rgba(255,255,255,0.15);border-radius:4px;color:#cdd6f4;font-size:14px;font-family:monospace;cursor:pointer;transition:all 0.15s;white-space:nowrap;line-height:1;';
2411
+ openNewBtn.onmouseenter = function () { openNewBtn.style.background = 'rgba(255,255,255,0.14)'; };
2412
+ openNewBtn.onmouseleave = function () { openNewBtn.style.background = 'rgba(255,255,255,0.07)'; };
2413
+ openNewBtn.onclick = function () {
2414
+ if (previewIframe.src) window.open(previewIframe.src, '_blank');
2415
+ };
2416
+
2390
2417
  var useBtn = document.createElement('button');
2391
2418
  useBtn.textContent = '✨ 使用模板';
2392
2419
  useBtn.style.cssText = 'flex-shrink:0;padding:5px 14px;background:#a78bfa;border:none;border-radius:4px;color:#fff;font-size:12px;font-family:monospace;cursor:pointer;transition:background 0.15s;white-space:nowrap;';
@@ -2401,6 +2428,8 @@
2401
2428
  });
2402
2429
  };
2403
2430
  rightHeader.appendChild(infoSpan);
2431
+ rightHeader.appendChild(refreshBtn);
2432
+ rightHeader.appendChild(openNewBtn);
2404
2433
  rightHeader.appendChild(useBtn);
2405
2434
  previewIframe.src = MYCLAW_API_BASE + '/api/file?path='
2406
2435
  + encodeURIComponent(TEMPLATE_ROOT + '/templates/' + tpl['文件夹名'] + '/__student-view__.html');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.1.36",
3
+ "version": "1.1.38",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1151,11 +1151,10 @@ class MyclawAPIHandler(BaseHTTPRequestHandler):
1151
1151
  for series, nums in cdn_templates.items():
1152
1152
  for num, record in nums.items():
1153
1153
  folder_name = record.get('文件夹名', '')
1154
- files = record.get('files', [])
1155
1154
  cdn_ua = record.get('updated_at', '')
1156
1155
  local_ua = local_templates.get(series, {}).get(num, {}).get('updated_at', '')
1157
1156
 
1158
- if not folder_name or not files:
1157
+ if not folder_name:
1159
1158
  continue
1160
1159
 
1161
1160
  is_new = series not in local_templates or num not in local_templates.get(series, {})
@@ -1164,18 +1163,18 @@ class MyclawAPIHandler(BaseHTTPRequestHandler):
1164
1163
  if not is_new and not is_changed:
1165
1164
  continue
1166
1165
 
1167
- # 下载该文件夹的所有文件
1166
+ # 从七牛列举该文件夹下所有文件,全量下载
1167
+ cdn_prefix = 'myclaw/live/yiran/skills/yiran-playground-template-use/templates/{}/'.format(folder_name)
1168
1168
  folder_dir = os.path.join(local_templates_dir, folder_name)
1169
1169
  os.makedirs(folder_dir, exist_ok=True)
1170
- for filename in files:
1171
- url = '{}/{}/{}'.format(CDN_TEMPLATE_BASE, folder_name, filename)
1170
+ cdn_files = _list_files_from_qiniu(cdn_prefix)
1171
+ for item in cdn_files:
1172
+ key = item.get('key', '')
1173
+ filename = key[len(cdn_prefix):]
1174
+ if not filename:
1175
+ continue
1172
1176
  dest = os.path.join(folder_dir, filename)
1173
- try:
1174
- with urllib.request.urlopen(url, timeout=15) as r:
1175
- with open(dest, 'wb') as out:
1176
- out.write(r.read())
1177
- except Exception as e:
1178
- print('[sync-templates] 下载失败 {}: {}'.format(url, e))
1177
+ _download_from_cdn(key, dest)
1179
1178
 
1180
1179
  if is_new:
1181
1180
  added.append(folder_name)
@@ -64,8 +64,7 @@ def main():
64
64
 
65
65
  entry = get_entry_file(folder)
66
66
 
67
- # 文件夹内所有文件列表 + 最新 mtime
68
- files = sorted(f.name for f in folder.iterdir() if f.is_file())
67
+ # 文件夹最新 mtime 作为变更标记
69
68
  folder_mtime = max((f.stat().st_mtime for f in folder.iterdir() if f.is_file()), default=0)
70
69
  updated_at = datetime.fromtimestamp(folder_mtime, tz=timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')
71
70
 
@@ -82,7 +81,6 @@ def main():
82
81
  '主能力标签': 能力标签,
83
82
  '任务类型标签': 类型标签,
84
83
  '关键词': keywords,
85
- 'files': files,
86
84
  'updated_at': updated_at,
87
85
  }
88
86
 
@@ -1,5 +1,5 @@
1
1
  {
2
- "index_updated_at": "2026-04-22T05:11:25Z",
2
+ "index_updated_at": "2026-04-22T05:27:04Z",
3
3
  "templates": {
4
4
  "A": {
5
5
  "100": {
@@ -27,14 +27,6 @@
27
27
  "表达构建",
28
28
  "视听表达"
29
29
  ],
30
- "files": [
31
- "__demo__.html",
32
- "__student-view__.html",
33
- "__student__.json",
34
- "__teacher-view__.html",
35
- "__teacher__.json",
36
- "index.html"
37
- ],
38
30
  "updated_at": "2026-04-22T04:32:31Z"
39
31
  },
40
32
  "101": {
@@ -61,13 +53,6 @@
61
53
  "表达构建",
62
54
  "视听表达"
63
55
  ],
64
- "files": [
65
- "__demo__.html",
66
- "__student-view__.html",
67
- "__student__.json",
68
- "__teacher-view__.html",
69
- "__teacher__.json"
70
- ],
71
56
  "updated_at": "2026-04-22T04:32:32Z"
72
57
  },
73
58
  "102": {
@@ -94,26 +79,6 @@
94
79
  "第二能力:表达构建",
95
80
  "视听表达"
96
81
  ],
97
- "files": [
98
- "__demo__.html",
99
- "__student-view__.html",
100
- "__student__.json",
101
- "__teacher-view__.html",
102
- "__teacher__.json",
103
- "index.html",
104
- "tmpsz_k5dxa.png",
105
- "努力学习的小朋友.png",
106
- "可爱机甲.png",
107
- "小组吉祥物第一版_1024x1024_20260421_173654.png",
108
- "小组吉祥物第二版-中等_1024x1024_20260421_175052.png",
109
- "小组图标第一版-中等-微调_1024x1024_20260421_184340.png",
110
- "小组图标第一版-中等_1024x1024_20260421_180057.png",
111
- "小组徽章第一版-简单_1024x1024_20260421_184717.png",
112
- "小组标志第一版-中等_1024x1024_20260421_175402.png",
113
- "搞笑小朋友.png",
114
- "搞笑小朋友_即梦.png",
115
- "班级小组徽章Logo优化版_1024x1024_20260421_185141.png"
116
- ],
117
82
  "updated_at": "2026-04-22T04:47:01Z"
118
83
  },
119
84
  "103": {
@@ -140,13 +105,6 @@
140
105
  "表达构建",
141
106
  "视听表达"
142
107
  ],
143
- "files": [
144
- "__demo__.html",
145
- "__student-view__.html",
146
- "__student__.json",
147
- "__teacher-view__.html",
148
- "__teacher__.json"
149
- ],
150
108
  "updated_at": "2026-04-22T04:32:34Z"
151
109
  },
152
110
  "104": {
@@ -175,17 +133,7 @@
175
133
  "迭代推进",
176
134
  "游戏机制"
177
135
  ],
178
- "files": [
179
- "__demo__.html",
180
- "__student-view__.html",
181
- "__student__.json",
182
- "__teacher-view__.html",
183
- "__teacher__.json",
184
- "bg_music.mp3",
185
- "index.html",
186
- "炫酷机甲_1024x1024_20260416_125127.png"
187
- ],
188
- "updated_at": "2026-04-22T04:32:35Z"
136
+ "updated_at": "2026-04-22T05:23:43Z"
189
137
  }
190
138
  },
191
139
  "B": {
@@ -213,13 +161,6 @@
213
161
  "表达构建",
214
162
  "游戏机制"
215
163
  ],
216
- "files": [
217
- "__demo__.html",
218
- "__student-view__.html",
219
- "__student__.json",
220
- "__teacher-view__.html",
221
- "__teacher__.json"
222
- ],
223
164
  "updated_at": "2026-04-22T04:32:36Z"
224
165
  }
225
166
  },
@@ -250,18 +191,6 @@
250
191
  "问题判断",
251
192
  "改编优化"
252
193
  ],
253
- "files": [
254
- "__demo__.html",
255
- "__student-view__.html",
256
- "__student__.json",
257
- "__teacher-view__.html",
258
- "__teacher__.json",
259
- "demo.html",
260
- "index.html",
261
- "小组吉祥物_26.png",
262
- "小组图形标志_83.png",
263
- "班级小组徽章_47.png"
264
- ],
265
194
  "updated_at": "2026-04-22T04:32:36Z"
266
195
  }
267
196
  }