@aiyiran/myclaw 1.0.190 → 1.0.192

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.
@@ -94,7 +94,9 @@
94
94
  document.body.appendChild(btn);
95
95
  }
96
96
 
97
- // ═══ 1.2 右下角 CMD 按钮 ═══
97
+ // ═══ 1.2 右下角 CMD 按钮(弹框 iframe) ═══
98
+ var cmdOpen = false;
99
+
98
100
  function createCmdButton() {
99
101
  if (document.querySelector("#myclaw-cmd-btn")) return;
100
102
 
@@ -104,29 +106,131 @@
104
106
  "position: fixed",
105
107
  "bottom: 8px",
106
108
  "right: 130px",
107
- "padding: 2px 8px",
108
- "background: none",
109
- "color: rgba(150, 150, 150, 0.4)",
110
- "font-size: 10px",
109
+ "padding: 3px 10px",
110
+ "background: rgba(59, 130, 246, 0.85)",
111
+ "color: #fff",
112
+ "font-size: 11px",
113
+ "font-weight: bold",
111
114
  "font-family: monospace",
115
+ "border-radius: 4px",
112
116
  "z-index: 99999",
113
117
  "user-select: none",
114
118
  "cursor: pointer",
115
- "transition: color 0.2s",
119
+ "transition: all 0.2s",
120
+ "letter-spacing: 0.5px",
116
121
  ].join(";");
117
122
  btn.textContent = "\u2328 CMD";
118
123
  btn.title = "\u6253\u5F00\u547D\u4EE4\u884C";
119
124
 
120
- btn.onmouseenter = function () { btn.style.color = "rgba(150, 150, 150, 0.8)"; };
121
- btn.onmouseleave = function () { btn.style.color = "rgba(150, 150, 150, 0.4)"; };
125
+ btn.onmouseenter = function () { btn.style.background = "rgba(37, 99, 235, 1)"; btn.style.transform = "scale(1.05)"; };
126
+ btn.onmouseleave = function () { if (!cmdOpen) { btn.style.background = "rgba(59, 130, 246, 0.85)"; } btn.style.transform = "scale(1)"; };
122
127
  btn.onclick = function (e) {
123
128
  e.stopPropagation();
124
- window.location.href = window.location.origin + "/cmd";
129
+ if (cmdOpen) {
130
+ closeCmdModal();
131
+ } else {
132
+ openCmdModal();
133
+ }
125
134
  };
126
135
 
127
136
  document.body.appendChild(btn);
128
137
  }
129
138
 
139
+ function openCmdModal() {
140
+ if (document.querySelector("#myclaw-cmd-modal")) return;
141
+ cmdOpen = true;
142
+
143
+ // 按钮 active 态
144
+ var btn = document.querySelector("#myclaw-cmd-btn");
145
+ if (btn) btn.style.background = "rgba(37, 99, 235, 1)";
146
+
147
+ // 遮罩
148
+ var overlay = document.createElement("div");
149
+ overlay.id = "myclaw-cmd-modal";
150
+ overlay.style.cssText = [
151
+ "position: fixed",
152
+ "top: 0",
153
+ "left: 0",
154
+ "width: 100vw",
155
+ "height: 100vh",
156
+ "background: rgba(0, 0, 0, 0.3)",
157
+ "z-index: 99998",
158
+ "display: flex",
159
+ "align-items: center",
160
+ "justify-content: center",
161
+ "animation: myclaw-fade-in 0.15s ease",
162
+ ].join(";");
163
+
164
+ // 弹框容器 — 尽可能大,只留小边距
165
+ var box = document.createElement("div");
166
+ box.style.cssText = [
167
+ "width: 98vw",
168
+ "height: 96vh",
169
+ "background: #1e1e2e",
170
+ "border-radius: 8px",
171
+ "overflow: hidden",
172
+ "display: flex",
173
+ "flex-direction: column",
174
+ "box-shadow: 0 8px 32px rgba(0,0,0,0.4)",
175
+ ].join(";");
176
+
177
+ // 标题栏
178
+ var header = document.createElement("div");
179
+ header.style.cssText = [
180
+ "display: flex",
181
+ "align-items: center",
182
+ "justify-content: space-between",
183
+ "padding: 8px 14px",
184
+ "background: #2d2d3f",
185
+ "color: #cdd6f4",
186
+ "font-size: 13px",
187
+ "font-family: monospace",
188
+ "user-select: none",
189
+ ].join(";");
190
+ header.innerHTML = '<span>\u2328 Terminal</span>';
191
+
192
+ var closeBtn = document.createElement("span");
193
+ closeBtn.textContent = "\u2715";
194
+ closeBtn.style.cssText = "cursor:pointer;padding:2px 6px;border-radius:3px;font-size:14px;transition:background 0.15s;";
195
+ closeBtn.onmouseenter = function () { closeBtn.style.background = "rgba(255,255,255,0.1)"; };
196
+ closeBtn.onmouseleave = function () { closeBtn.style.background = "none"; };
197
+ closeBtn.onclick = function () { closeCmdModal(); };
198
+ header.appendChild(closeBtn);
199
+
200
+ // 新标签页打开 /cmd
201
+ window.open(window.location.origin + "/cmd", "_blank");
202
+
203
+ // iframe 占位(保持弹框结构)
204
+ var iframe = document.createElement("iframe");
205
+ iframe.src = "about:blank";
206
+ iframe.style.cssText = [
207
+ "flex: 1",
208
+ "width: 100%",
209
+ "border: none",
210
+ "background: #1e1e2e",
211
+ ].join(";");
212
+
213
+ box.appendChild(header);
214
+ box.appendChild(iframe);
215
+ overlay.appendChild(box);
216
+
217
+ // 点击遮罩关闭
218
+ overlay.onclick = function (e) {
219
+ if (e.target === overlay) closeCmdModal();
220
+ };
221
+
222
+ document.body.appendChild(overlay);
223
+ }
224
+
225
+ function closeCmdModal() {
226
+ var modal = document.querySelector("#myclaw-cmd-modal");
227
+ if (modal) modal.remove();
228
+ cmdOpen = false;
229
+
230
+ var btn = document.querySelector("#myclaw-cmd-btn");
231
+ if (btn) btn.style.background = "rgba(59, 130, 246, 0.85)";
232
+ }
233
+
130
234
  // \u6D4B\u8BD5\u9EA6\u514B\u98CE\u51FD\u6570
131
235
  function testMicrophone() {
132
236
  console.log("[myclaw] \u5F00\u59CB\u6D4B\u8BD5\u9EA6\u514B\u98CE...");
@@ -411,6 +515,11 @@
411
515
  " 0% { transform: scale(0.8); opacity: 0.8; }",
412
516
  " 100% { transform: scale(1.6); opacity: 0; }",
413
517
  "}",
518
+ /* CMD 弹框淡入 */
519
+ "@keyframes myclaw-fade-in {",
520
+ " from { opacity: 0; }",
521
+ " to { opacity: 1; }",
522
+ "}",
414
523
  ].join("\n");
415
524
  document.head.appendChild(style);
416
525
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.0.190",
3
+ "version": "1.0.192",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {