vite-plugin-opencode-assistant 1.0.4 → 1.0.6
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/es/client/index.d.ts +1 -0
- package/es/client/index.js +328 -0
- package/es/core/api.d.ts +14 -0
- package/es/core/api.js +294 -0
- package/es/core/injector.d.ts +2 -0
- package/es/core/injector.js +11 -0
- package/es/core/service.d.ts +18 -0
- package/es/core/service.js +163 -0
- package/es/endpoints/context.d.ts +3 -0
- package/es/endpoints/context.js +114 -0
- package/es/endpoints/index.d.ts +4 -0
- package/es/endpoints/index.js +16 -0
- package/es/endpoints/sessions.d.ts +3 -0
- package/es/endpoints/sessions.js +79 -0
- package/es/endpoints/sse.d.ts +3 -0
- package/es/endpoints/sse.js +56 -0
- package/es/endpoints/start.d.ts +3 -0
- package/es/endpoints/start.js +35 -0
- package/es/endpoints/types.d.ts +13 -0
- package/es/endpoints/widget.d.ts +3 -0
- package/es/endpoints/widget.js +57 -0
- package/{dist/vite → es}/index.d.ts +1 -1
- package/es/index.js +168 -0
- package/es/utils/paths.d.ts +3 -0
- package/es/utils/paths.js +38 -0
- package/es/utils/system.js +241 -0
- package/lib/client/index.d.ts +1 -0
- package/lib/client/index.js +328 -0
- package/lib/client.js +5597 -0
- package/lib/core/api.d.ts +14 -0
- package/lib/core/api.js +321 -0
- package/lib/core/injector.d.ts +2 -0
- package/lib/core/injector.js +34 -0
- package/lib/core/service.d.ts +18 -0
- package/lib/core/service.js +180 -0
- package/lib/endpoints/context.d.ts +3 -0
- package/lib/endpoints/context.js +137 -0
- package/lib/endpoints/index.d.ts +4 -0
- package/lib/endpoints/index.js +41 -0
- package/lib/endpoints/sessions.d.ts +3 -0
- package/lib/endpoints/sessions.js +102 -0
- package/lib/endpoints/sse.d.ts +3 -0
- package/lib/endpoints/sse.js +79 -0
- package/lib/endpoints/start.d.ts +3 -0
- package/lib/endpoints/start.js +58 -0
- package/lib/endpoints/types.d.ts +13 -0
- package/lib/endpoints/types.js +15 -0
- package/lib/endpoints/widget.d.ts +3 -0
- package/lib/endpoints/widget.js +90 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +190 -0
- package/lib/style.css +1 -0
- package/lib/utils/paths.d.ts +3 -0
- package/lib/utils/paths.js +73 -0
- package/lib/utils/system.d.ts +5 -0
- package/lib/utils/system.js +274 -0
- package/package.json +28 -33
- package/README.md +0 -287
- package/dist/constants.d.ts +0 -74
- package/dist/constants.js +0 -75
- package/dist/constants.js.map +0 -1
- package/dist/logger.d.ts +0 -64
- package/dist/logger.js +0 -311
- package/dist/logger.js.map +0 -1
- package/dist/opencode/plugins/page-context.d.ts +0 -7
- package/dist/opencode/plugins/page-context.js +0 -372
- package/dist/opencode/plugins/page-context.js.map +0 -1
- package/dist/opencode/web.d.ts +0 -3
- package/dist/opencode/web.js +0 -81
- package/dist/opencode/web.js.map +0 -1
- package/dist/types.d.ts +0 -126
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/vite/client.js +0 -2468
- package/dist/vite/client.js.map +0 -1
- package/dist/vite/index.js +0 -697
- package/dist/vite/index.js.map +0 -1
- package/dist/vite/injector.d.ts +0 -2
- package/dist/vite/injector.js +0 -6
- package/dist/vite/injector.js.map +0 -1
- package/dist/vite/utils.js +0 -206
- package/dist/vite/utils.js.map +0 -1
- /package/{dist/vite/client.d.ts → es/endpoints/types.js} +0 -0
- /package/{dist/vite/utils.d.ts → es/utils/system.d.ts} +0 -0
package/dist/vite/client.js
DELETED
|
@@ -1,2468 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview OpenCode 挂件客户端脚本
|
|
4
|
-
* @description 用于在浏览器中显示 OpenCode AI 助手挂件
|
|
5
|
-
*/
|
|
6
|
-
(function () {
|
|
7
|
-
"use strict";
|
|
8
|
-
/** @type {string} 初始化标记 */
|
|
9
|
-
const INIT_MARKER = "__OPENCODE_INITIALIZED__";
|
|
10
|
-
/** @type {string} 选中元素存储键 */
|
|
11
|
-
const SELECTED_ELEMENTS_KEY = "__opencode_selected_elements__";
|
|
12
|
-
/** @type {number} 服务器同步间隔(毫秒) */
|
|
13
|
-
const SERVER_SYNC_INTERVAL = 2000;
|
|
14
|
-
/** @type {number} 检查 Vue Inspector 间隔(毫秒) */
|
|
15
|
-
const INSPECTOR_CHECK_INTERVAL = 500;
|
|
16
|
-
/** @type {number} 自动打开延迟(毫秒) */
|
|
17
|
-
const AUTO_OPEN_DELAY = 1000;
|
|
18
|
-
/** @type {number} 通知显示时间(毫秒) */
|
|
19
|
-
const NOTIFICATION_DURATION = 3000;
|
|
20
|
-
/**
|
|
21
|
-
* @typedef {Object} HotkeyConfig
|
|
22
|
-
* @property {boolean} ctrl - 是否需要 Ctrl/Meta 键
|
|
23
|
-
* @property {boolean} shift - 是否需要 Shift 键
|
|
24
|
-
* @property {boolean} alt - 是否需要 Alt 键
|
|
25
|
-
* @property {string} key - 主键
|
|
26
|
-
*/
|
|
27
|
-
/**
|
|
28
|
-
* @typedef {Object} SelectedElement
|
|
29
|
-
* @property {string|null} filePath - 文件路径
|
|
30
|
-
* @property {number|null} line - 行号
|
|
31
|
-
* @property {number|null} column - 列号
|
|
32
|
-
* @property {string} innerText - 元素内部文本
|
|
33
|
-
* @property {string} description - 元素描述(标签名+选择器)
|
|
34
|
-
*/
|
|
35
|
-
/**
|
|
36
|
-
* @typedef {Object} WidgetConfig
|
|
37
|
-
* @property {string} webUrl - Web 服务 URL
|
|
38
|
-
* @property {string} position - 挂件位置
|
|
39
|
-
* @property {string} theme - 主题模式
|
|
40
|
-
* @property {boolean} open - 是否自动打开
|
|
41
|
-
* @property {string} sessionUrl - 会话 URL
|
|
42
|
-
* @property {boolean} lazy - 是否懒加载
|
|
43
|
-
* @property {string} hotkey - 快捷键配置
|
|
44
|
-
*/
|
|
45
|
-
/**
|
|
46
|
-
* 初始化 OpenCode 挂件
|
|
47
|
-
* @param {WidgetConfig} config - 挂件配置
|
|
48
|
-
*/
|
|
49
|
-
function initOpenCodeWidget(config) {
|
|
50
|
-
if (window[INIT_MARKER])
|
|
51
|
-
return;
|
|
52
|
-
window[INIT_MARKER] = true;
|
|
53
|
-
const { webUrl, position, theme, open, sessionUrl: initialSessionUrl, lazy, hotkey, cwd, } = config;
|
|
54
|
-
/** @type {string|undefined} 会话 URL */
|
|
55
|
-
let sessionUrl = initialSessionUrl;
|
|
56
|
-
/** @type {string|null} 当前会话 ID */
|
|
57
|
-
let currentSessionId = null;
|
|
58
|
-
/**
|
|
59
|
-
* 从 URL 中提取会话 ID
|
|
60
|
-
*/
|
|
61
|
-
function extractSessionId(url) {
|
|
62
|
-
if (!url)
|
|
63
|
-
return null;
|
|
64
|
-
const match = url.match(/\/session\/([^/?]+)/);
|
|
65
|
-
return match ? match[1] : null;
|
|
66
|
-
}
|
|
67
|
-
// 从初始 URL 中提取会话 ID
|
|
68
|
-
currentSessionId = extractSessionId(sessionUrl);
|
|
69
|
-
/** @type {string} 当前页面 URL */
|
|
70
|
-
let currentPageUrl = "";
|
|
71
|
-
/** @type {string} 当前页面标题 */
|
|
72
|
-
let currentPageTitle = "";
|
|
73
|
-
/** @type {boolean} 服务是否已启动 */
|
|
74
|
-
let servicesStarted = !lazy;
|
|
75
|
-
/** @type {boolean} 挂件是否打开 */
|
|
76
|
-
let isOpen = false;
|
|
77
|
-
/**
|
|
78
|
-
* 解析快捷键字符串
|
|
79
|
-
* @param {string} hotkeyStr - 快捷键字符串,如 'ctrl+k'
|
|
80
|
-
* @returns {HotkeyConfig} 快捷键配置
|
|
81
|
-
*/
|
|
82
|
-
function parseHotkey(hotkeyStr) {
|
|
83
|
-
if (!hotkeyStr)
|
|
84
|
-
return { ctrl: true, shift: false, alt: false, key: "k" };
|
|
85
|
-
const parts = hotkeyStr.toLowerCase().split("+");
|
|
86
|
-
const key = parts.pop();
|
|
87
|
-
return {
|
|
88
|
-
ctrl: parts.includes("ctrl") ||
|
|
89
|
-
parts.includes("cmd") ||
|
|
90
|
-
parts.includes("meta"),
|
|
91
|
-
shift: parts.includes("shift"),
|
|
92
|
-
alt: parts.includes("alt"),
|
|
93
|
-
key: key || "k",
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
/** @type {HotkeyConfig} 主快捷键配置 */
|
|
97
|
-
const mainHotkey = parseHotkey(hotkey);
|
|
98
|
-
/** @type {HotkeyConfig} 选择模式快捷键配置 */
|
|
99
|
-
const selectHotkey = parseHotkey("ctrl+p");
|
|
100
|
-
/**
|
|
101
|
-
* 检查键盘事件是否匹配快捷键
|
|
102
|
-
* @param {KeyboardEvent} e - 键盘事件
|
|
103
|
-
* @param {HotkeyConfig} hotkeyConfig - 快捷键配置
|
|
104
|
-
* @returns {boolean} 是否匹配
|
|
105
|
-
*/
|
|
106
|
-
function matchHotkey(e, hotkeyConfig) {
|
|
107
|
-
const ctrlMatch = hotkeyConfig.ctrl
|
|
108
|
-
? e.ctrlKey || e.metaKey
|
|
109
|
-
: !(e.ctrlKey || e.metaKey);
|
|
110
|
-
const shiftMatch = hotkeyConfig.shift ? e.shiftKey : !e.shiftKey;
|
|
111
|
-
const altMatch = hotkeyConfig.alt ? e.altKey : !e.altKey;
|
|
112
|
-
const keyMatch = e.key.toLowerCase() === hotkeyConfig.key.toLowerCase();
|
|
113
|
-
return ctrlMatch && shiftMatch && altMatch && keyMatch;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* 从 sessionStorage 加载选中的元素
|
|
117
|
-
* @returns {SelectedElement[]} 选中的元素列表
|
|
118
|
-
*/
|
|
119
|
-
function loadSelectedElements() {
|
|
120
|
-
try {
|
|
121
|
-
const stored = sessionStorage.getItem(SELECTED_ELEMENTS_KEY);
|
|
122
|
-
if (stored) {
|
|
123
|
-
return JSON.parse(stored);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
catch (e) {
|
|
127
|
-
// 忽略错误
|
|
128
|
-
}
|
|
129
|
-
return [];
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* 保存选中的元素到 sessionStorage
|
|
133
|
-
* @param {SelectedElement[]} elements - 选中的元素列表
|
|
134
|
-
*/
|
|
135
|
-
function saveSelectedElements(elements) {
|
|
136
|
-
try {
|
|
137
|
-
sessionStorage.setItem(SELECTED_ELEMENTS_KEY, JSON.stringify(elements));
|
|
138
|
-
}
|
|
139
|
-
catch (e) {
|
|
140
|
-
// 忽略错误
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
/** @type {SelectedElement[]} 选中的元素列表 */
|
|
144
|
-
let selectedElements = loadSelectedElements();
|
|
145
|
-
/**
|
|
146
|
-
* 确保服务已启动
|
|
147
|
-
* @returns {Promise<boolean>} 是否成功启动
|
|
148
|
-
*/
|
|
149
|
-
async function ensureServicesStarted() {
|
|
150
|
-
if (servicesStarted)
|
|
151
|
-
return true;
|
|
152
|
-
try {
|
|
153
|
-
const res = await fetch("/__opencode_start__");
|
|
154
|
-
const data = await res.json();
|
|
155
|
-
if (data.success) {
|
|
156
|
-
servicesStarted = true;
|
|
157
|
-
if (data.sessionUrl) {
|
|
158
|
-
sessionUrl = data.sessionUrl;
|
|
159
|
-
currentSessionId = extractSessionId(sessionUrl);
|
|
160
|
-
if (iframe)
|
|
161
|
-
iframe.src = sessionUrl;
|
|
162
|
-
}
|
|
163
|
-
else {
|
|
164
|
-
if (iframe)
|
|
165
|
-
iframe.src = "about:blank";
|
|
166
|
-
showLoading();
|
|
167
|
-
}
|
|
168
|
-
return true;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
catch (e) {
|
|
172
|
-
console.error("[OpenCode Widget] Failed to start services:", e);
|
|
173
|
-
}
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* 更新页面上下文
|
|
178
|
-
* @param {boolean} [force=false] - 是否强制更新
|
|
179
|
-
*/
|
|
180
|
-
function updateContext(force = false) {
|
|
181
|
-
if (!servicesStarted)
|
|
182
|
-
return;
|
|
183
|
-
const newUrl = window.location.href;
|
|
184
|
-
const newTitle = document.title;
|
|
185
|
-
if (force || newUrl !== currentPageUrl || newTitle !== currentPageTitle) {
|
|
186
|
-
currentPageUrl = newUrl;
|
|
187
|
-
currentPageTitle = newTitle;
|
|
188
|
-
fetch("/__opencode_context__", {
|
|
189
|
-
method: "POST",
|
|
190
|
-
headers: { "Content-Type": "application/json" },
|
|
191
|
-
body: JSON.stringify({
|
|
192
|
-
url: newUrl,
|
|
193
|
-
title: newTitle,
|
|
194
|
-
selectedElements,
|
|
195
|
-
}),
|
|
196
|
-
}).catch(() => { });
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
// 监听路由变化
|
|
200
|
-
const originalPushState = history.pushState;
|
|
201
|
-
const originalReplaceState = history.replaceState;
|
|
202
|
-
history.pushState = function (...args) {
|
|
203
|
-
originalPushState.apply(this, args);
|
|
204
|
-
setTimeout(updateContext, 0);
|
|
205
|
-
};
|
|
206
|
-
history.replaceState = function (...args) {
|
|
207
|
-
originalReplaceState.apply(this, args);
|
|
208
|
-
setTimeout(updateContext, 0);
|
|
209
|
-
};
|
|
210
|
-
window.addEventListener("popstate", () => setTimeout(updateContext, 0));
|
|
211
|
-
window.addEventListener("hashchange", () => setTimeout(updateContext, 0));
|
|
212
|
-
// 监听标题变化
|
|
213
|
-
const titleObserver = new MutationObserver(() => {
|
|
214
|
-
if (document.title !== currentPageTitle) {
|
|
215
|
-
updateContext();
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
if (document.head) {
|
|
219
|
-
titleObserver.observe(document.head, { childList: true, subtree: true });
|
|
220
|
-
}
|
|
221
|
-
/** @type {EventSource|null} SSE 连接实例 */
|
|
222
|
-
let sseConnection = null;
|
|
223
|
-
if (servicesStarted) {
|
|
224
|
-
updateContext(true);
|
|
225
|
-
setupSSEConnection();
|
|
226
|
-
}
|
|
227
|
-
// 创建样式
|
|
228
|
-
const style = document.createElement("style");
|
|
229
|
-
style.textContent = buildWidgetStyles();
|
|
230
|
-
document.head.appendChild(style);
|
|
231
|
-
// 创建容器
|
|
232
|
-
const container = document.createElement("div");
|
|
233
|
-
container.className = `opencode-widget ${position}`;
|
|
234
|
-
// 创建按钮
|
|
235
|
-
const button = document.createElement("button");
|
|
236
|
-
button.className = "opencode-button";
|
|
237
|
-
button.innerHTML = `
|
|
238
|
-
<svg t="1775402599580" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns=" http://www.w3.org/2000/svg " p-id="5390" xmlns:xlink=" http://www.w3.org/1999/xlink " width="100%" height="100%"><path d="M512 981.33H85.34c-15.85 0-30.38-8.77-37.77-22.81a42.624 42.624 0 0 1 2.6-44.02L135 791.08C75.25 710.5 42.67 612.6 42.67 512 42.67 253.21 253.21 42.67 512 42.67S981.34 253.21 981.34 512 770.8 981.33 512 981.33zM166.44 896H512c211.73 0 384-172.27 384-384S723.73 128 512 128 128 300.27 128 512c0 91.29 32.83 179.9 92.46 249.46 12.58 14.69 13.73 36 2.77 51.94L166.44 896z" fill="white" p-id="5391"></path><path d="M384 448m-64 0a64 64 0 1 0 128 0 64 64 0 1 0 -128 0Z" fill="white" p-id="5392"></path><path d="M640 448m-64 0a64 64 0 1 0 128 0 64 64 0 1 0 -128 0Z" fill="white" p-id="5393"></path></svg>
|
|
239
|
-
`;
|
|
240
|
-
button.setAttribute("aria-label", "打开 AI 助手");
|
|
241
|
-
button.title = `AI 助手 (${hotkey || "Ctrl+K"})`;
|
|
242
|
-
// 创建聊天面板
|
|
243
|
-
const chat = document.createElement("div");
|
|
244
|
-
chat.className = "opencode-chat";
|
|
245
|
-
chat.setAttribute("role", "dialog");
|
|
246
|
-
chat.setAttribute("aria-modal", "true");
|
|
247
|
-
chat.setAttribute("aria-label", "AI 助手对话窗口");
|
|
248
|
-
// 创建面板头部操作栏
|
|
249
|
-
const chatHeader = document.createElement("div");
|
|
250
|
-
chatHeader.className = "opencode-chat-header";
|
|
251
|
-
// 左侧操作区
|
|
252
|
-
const headerLeft = document.createElement("div");
|
|
253
|
-
headerLeft.className = "opencode-chat-header-left";
|
|
254
|
-
// 会话列表折叠按钮
|
|
255
|
-
const toggleBtn = document.createElement("button");
|
|
256
|
-
toggleBtn.className = "opencode-header-btn session-toggle";
|
|
257
|
-
toggleBtn.innerHTML = `
|
|
258
|
-
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2">
|
|
259
|
-
<path d="M4 6h16M4 12h16M4 18h16" stroke-linecap="round"/>
|
|
260
|
-
</svg>
|
|
261
|
-
`;
|
|
262
|
-
toggleBtn.title = "展开会话列表";
|
|
263
|
-
toggleBtn.setAttribute("aria-label", "展开会话列表");
|
|
264
|
-
toggleBtn.setAttribute("aria-expanded", "false");
|
|
265
|
-
// 选择元素按钮
|
|
266
|
-
const selectButton = document.createElement("button");
|
|
267
|
-
selectButton.className = "opencode-header-btn select-btn";
|
|
268
|
-
selectButton.innerHTML = `
|
|
269
|
-
<svg viewBox="0 0 1024 1024" width="16" height="16" xmlns="http://www.w3.org/2000/svg">
|
|
270
|
-
<path fill="currentColor" d="M512 896a384 384 0 1 0 0-768 384 384 0 0 0 0 768m0 64a448 448 0 1 1 0-896 448 448 0 0 1 0 896"></path><path fill="currentColor" d="M512 96a32 32 0 0 1 32 32v192a32 32 0 0 1-64 0V128a32 32 0 0 1 32-32m0 576a32 32 0 0 1 32 32v192a32 32 0 1 1-64 0V704a32 32 0 0 1 32-32M96 512a32 32 0 0 1 32-32h192a32 32 0 0 1 0 64H128a32 32 0 0 1-32-32m576 0a32 32 0 0 1 32-32h192a32 32 0 1 1 0 64H704a32 32 0 0 1-32-32"></path>
|
|
271
|
-
</svg>
|
|
272
|
-
`;
|
|
273
|
-
selectButton.title = "选择页面元素 (Ctrl+P)";
|
|
274
|
-
selectButton.setAttribute("aria-label", "选择页面元素");
|
|
275
|
-
selectButton.setAttribute("aria-pressed", "false");
|
|
276
|
-
headerLeft.appendChild(toggleBtn);
|
|
277
|
-
headerLeft.appendChild(selectButton);
|
|
278
|
-
// 标题
|
|
279
|
-
const headerTitle = document.createElement("span");
|
|
280
|
-
headerTitle.className = "opencode-chat-header-title";
|
|
281
|
-
headerTitle.textContent = "AI 助手";
|
|
282
|
-
// 右侧操作区
|
|
283
|
-
const headerActions = document.createElement("div");
|
|
284
|
-
headerActions.className = "opencode-chat-header-actions";
|
|
285
|
-
// 关闭按钮
|
|
286
|
-
const closeBtn = document.createElement("button");
|
|
287
|
-
closeBtn.className = "opencode-header-btn close";
|
|
288
|
-
closeBtn.innerHTML = `
|
|
289
|
-
<svg viewBox="0 0 24 24" width="14" height="14" fill="none" stroke="currentColor" stroke-width="2">
|
|
290
|
-
<path d="M18 6L6 18M6 6l12 12"/>
|
|
291
|
-
</svg>
|
|
292
|
-
`;
|
|
293
|
-
closeBtn.title = "关闭";
|
|
294
|
-
closeBtn.setAttribute("aria-label", "关闭面板");
|
|
295
|
-
closeBtn.addEventListener("click", () => {
|
|
296
|
-
isOpen = false;
|
|
297
|
-
chat.classList.remove("open");
|
|
298
|
-
button.classList.remove("active");
|
|
299
|
-
});
|
|
300
|
-
headerActions.appendChild(closeBtn);
|
|
301
|
-
chatHeader.appendChild(headerLeft);
|
|
302
|
-
chatHeader.appendChild(headerTitle);
|
|
303
|
-
chatHeader.appendChild(headerActions);
|
|
304
|
-
// 创建会话列表
|
|
305
|
-
const sessionList = document.createElement("div");
|
|
306
|
-
sessionList.className = "opencode-session-list collapsed";
|
|
307
|
-
// 创建会话列表头部
|
|
308
|
-
const sessionListHeader = document.createElement("div");
|
|
309
|
-
sessionListHeader.className = "opencode-session-list-header";
|
|
310
|
-
sessionListHeader.innerHTML = `
|
|
311
|
-
<span id="opencode-session-list-title">会话列表</span>
|
|
312
|
-
<button class="opencode-new-session-btn" title="新建会话" aria-label="新建会话">+</button>
|
|
313
|
-
`;
|
|
314
|
-
// 创建会话列表头部骨架屏
|
|
315
|
-
const sessionHeaderSkeleton = document.createElement("div");
|
|
316
|
-
sessionHeaderSkeleton.className = "opencode-session-header-skeleton";
|
|
317
|
-
sessionHeaderSkeleton.innerHTML = `
|
|
318
|
-
<div class="opencode-skeleton-header-title"></div>
|
|
319
|
-
<div class="opencode-skeleton-header-btn"></div>
|
|
320
|
-
`;
|
|
321
|
-
// 创建会话列表内容
|
|
322
|
-
const sessionListContent = document.createElement("div");
|
|
323
|
-
sessionListContent.className = "opencode-session-list-content";
|
|
324
|
-
sessionListContent.setAttribute("role", "listbox");
|
|
325
|
-
sessionListContent.setAttribute("aria-labelledby", "opencode-session-list-title");
|
|
326
|
-
// 创建会话列表内容骨架屏
|
|
327
|
-
const sessionSkeleton = document.createElement("div");
|
|
328
|
-
sessionSkeleton.className = "opencode-session-skeleton";
|
|
329
|
-
sessionSkeleton.innerHTML = `
|
|
330
|
-
<div class="opencode-skeleton-item">
|
|
331
|
-
<div class="opencode-skeleton-title"></div>
|
|
332
|
-
<div class="opencode-skeleton-meta"></div>
|
|
333
|
-
</div>
|
|
334
|
-
<div class="opencode-skeleton-item">
|
|
335
|
-
<div class="opencode-skeleton-title"></div>
|
|
336
|
-
<div class="opencode-skeleton-meta"></div>
|
|
337
|
-
</div>
|
|
338
|
-
<div class="opencode-skeleton-item">
|
|
339
|
-
<div class="opencode-skeleton-title"></div>
|
|
340
|
-
<div class="opencode-skeleton-meta"></div>
|
|
341
|
-
</div>
|
|
342
|
-
<div class="opencode-skeleton-item">
|
|
343
|
-
<div class="opencode-skeleton-title"></div>
|
|
344
|
-
<div class="opencode-skeleton-meta"></div>
|
|
345
|
-
</div>
|
|
346
|
-
<div class="opencode-skeleton-item">
|
|
347
|
-
<div class="opencode-skeleton-title"></div>
|
|
348
|
-
<div class="opencode-skeleton-meta"></div>
|
|
349
|
-
</div>
|
|
350
|
-
`;
|
|
351
|
-
sessionList.appendChild(sessionHeaderSkeleton);
|
|
352
|
-
sessionList.appendChild(sessionListHeader);
|
|
353
|
-
sessionList.appendChild(sessionSkeleton);
|
|
354
|
-
sessionList.appendChild(sessionListContent);
|
|
355
|
-
// 折叠/展开会话列表
|
|
356
|
-
let isSessionListCollapsed = true;
|
|
357
|
-
function toggleSessionList() {
|
|
358
|
-
isSessionListCollapsed = !isSessionListCollapsed;
|
|
359
|
-
if (!isSessionListCollapsed) {
|
|
360
|
-
sessionHeaderSkeleton.classList.add("visible");
|
|
361
|
-
sessionListHeader.style.display = "none";
|
|
362
|
-
sessionSkeleton.classList.add("visible");
|
|
363
|
-
sessionListContent.style.display = "none";
|
|
364
|
-
}
|
|
365
|
-
sessionList.classList.toggle("collapsed", isSessionListCollapsed);
|
|
366
|
-
toggleBtn.title = isSessionListCollapsed
|
|
367
|
-
? "展开会话列表"
|
|
368
|
-
: "折叠会话列表";
|
|
369
|
-
toggleBtn.setAttribute("aria-label", isSessionListCollapsed ? "展开会话列表" : "折叠会话列表");
|
|
370
|
-
toggleBtn.setAttribute("aria-expanded", String(!isSessionListCollapsed));
|
|
371
|
-
if (!isSessionListCollapsed) {
|
|
372
|
-
setTimeout(() => {
|
|
373
|
-
sessionHeaderSkeleton.classList.remove("visible");
|
|
374
|
-
sessionListHeader.style.display = "";
|
|
375
|
-
sessionSkeleton.classList.remove("visible");
|
|
376
|
-
sessionListContent.style.display = "";
|
|
377
|
-
}, 200);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
toggleBtn.addEventListener("click", toggleSessionList);
|
|
381
|
-
// 创建 iframe 容器
|
|
382
|
-
const iframeContainer = document.createElement("div");
|
|
383
|
-
iframeContainer.className = "opencode-iframe-container";
|
|
384
|
-
// 创建加载指示器
|
|
385
|
-
const loadingOverlay = document.createElement("div");
|
|
386
|
-
loadingOverlay.className = "opencode-loading-overlay";
|
|
387
|
-
loadingOverlay.innerHTML = `
|
|
388
|
-
<div class="opencode-loading-spinner"></div>
|
|
389
|
-
<div class="opencode-loading-text">加载中...</div>
|
|
390
|
-
`;
|
|
391
|
-
// 创建空状态提示
|
|
392
|
-
const emptyStateOverlay = document.createElement("div");
|
|
393
|
-
emptyStateOverlay.className = "opencode-empty-state-overlay";
|
|
394
|
-
emptyStateOverlay.innerHTML = `
|
|
395
|
-
<div class="opencode-empty-state-icon">
|
|
396
|
-
<svg viewBox="0 0 24 24" width="48" height="48" fill="none" stroke="currentColor" stroke-width="1.5">
|
|
397
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z" />
|
|
398
|
-
</svg>
|
|
399
|
-
</div>
|
|
400
|
-
<div class="opencode-empty-state-text">当前项目暂无会话</div>
|
|
401
|
-
<button class="opencode-empty-state-btn">立即创建</button>
|
|
402
|
-
`;
|
|
403
|
-
emptyStateOverlay
|
|
404
|
-
.querySelector(".opencode-empty-state-btn")
|
|
405
|
-
.addEventListener("click", () => {
|
|
406
|
-
createNewSession();
|
|
407
|
-
});
|
|
408
|
-
// 创建 iframe
|
|
409
|
-
const iframe = document.createElement("iframe");
|
|
410
|
-
iframe.className = "opencode-iframe";
|
|
411
|
-
iframe.src = servicesStarted && sessionUrl ? sessionUrl : "about:blank";
|
|
412
|
-
iframe.allow = "clipboard-write; clipboard-read";
|
|
413
|
-
iframe.referrerPolicy = "origin";
|
|
414
|
-
if (servicesStarted && !sessionUrl) {
|
|
415
|
-
showLoading();
|
|
416
|
-
}
|
|
417
|
-
iframe.onload = function () {
|
|
418
|
-
if (servicesStarted &&
|
|
419
|
-
iframe.src !== "about:blank" &&
|
|
420
|
-
iframe.src !== window.location.href) {
|
|
421
|
-
updateContext();
|
|
422
|
-
loadSessions();
|
|
423
|
-
}
|
|
424
|
-
if (iframe.src !== "about:blank" && iframe.src !== window.location.href) {
|
|
425
|
-
hideLoading();
|
|
426
|
-
}
|
|
427
|
-
};
|
|
428
|
-
iframeContainer.appendChild(emptyStateOverlay);
|
|
429
|
-
iframeContainer.appendChild(loadingOverlay);
|
|
430
|
-
iframeContainer.appendChild(iframe);
|
|
431
|
-
// 创建右侧工具栏
|
|
432
|
-
const rightToolbar = document.createElement("div");
|
|
433
|
-
rightToolbar.className = `opencode-right-toolbar${selectedElements.length === 0 ? " collapsed" : ""}`;
|
|
434
|
-
// 创建已选节点标题
|
|
435
|
-
const selectedNodesHeader = document.createElement("div");
|
|
436
|
-
selectedNodesHeader.className = "opencode-selected-nodes-header";
|
|
437
|
-
selectedNodesHeader.innerHTML = `
|
|
438
|
-
<div class="opencode-selected-nodes-title">已选节点</div>
|
|
439
|
-
<div class="opencode-selected-nodes-desc">选中的节点会在对话时一起发送给助手</div>
|
|
440
|
-
`;
|
|
441
|
-
// 创建已选节点容器
|
|
442
|
-
const selectedNodesContainer = document.createElement("div");
|
|
443
|
-
selectedNodesContainer.className = "opencode-selected-nodes";
|
|
444
|
-
selectedNodesContainer.setAttribute("role", "list");
|
|
445
|
-
selectedNodesContainer.setAttribute("aria-label", "已选元素列表");
|
|
446
|
-
// 创建清空按钮
|
|
447
|
-
const clearAllButton = document.createElement("button");
|
|
448
|
-
clearAllButton.className = "opencode-clear-all-btn";
|
|
449
|
-
clearAllButton.setAttribute("aria-label", "清空所有已选节点");
|
|
450
|
-
clearAllButton.innerHTML = "一键清空";
|
|
451
|
-
rightToolbar.appendChild(selectedNodesHeader);
|
|
452
|
-
rightToolbar.appendChild(selectedNodesContainer);
|
|
453
|
-
rightToolbar.appendChild(clearAllButton);
|
|
454
|
-
// 创建选择模式常驻提示(固定到页面顶部)
|
|
455
|
-
const selectModeHint = document.createElement("div");
|
|
456
|
-
selectModeHint.className = "opencode-select-mode-hint";
|
|
457
|
-
selectModeHint.innerHTML = `
|
|
458
|
-
<span>🎯 选择模式已开启 - 点击元素进行选择</span>
|
|
459
|
-
<span class="opencode-hint-shortcut">按 ESC 或 Ctrl+P 退出</span>
|
|
460
|
-
`;
|
|
461
|
-
// 创建元素高亮覆盖层
|
|
462
|
-
const elementHighlight = document.createElement("div");
|
|
463
|
-
elementHighlight.className = "opencode-element-highlight";
|
|
464
|
-
// 创建元素信息提示框
|
|
465
|
-
const elementTooltip = document.createElement("div");
|
|
466
|
-
elementTooltip.className = "opencode-element-tooltip";
|
|
467
|
-
// 创建已选节点气泡容器(气泡按钮上方)
|
|
468
|
-
const selectedBubbles = document.createElement("div");
|
|
469
|
-
selectedBubbles.className = "opencode-selected-bubbles";
|
|
470
|
-
selectedBubbles.setAttribute("role", "list");
|
|
471
|
-
selectedBubbles.setAttribute("aria-label", "已选元素列表");
|
|
472
|
-
// 创建内容容器
|
|
473
|
-
const chatContent = document.createElement("div");
|
|
474
|
-
chatContent.className = "opencode-chat-content";
|
|
475
|
-
chat.appendChild(chatHeader);
|
|
476
|
-
chatContent.appendChild(sessionList);
|
|
477
|
-
chatContent.appendChild(iframeContainer);
|
|
478
|
-
chatContent.appendChild(rightToolbar);
|
|
479
|
-
chat.appendChild(chatContent);
|
|
480
|
-
container.appendChild(button);
|
|
481
|
-
container.appendChild(selectedBubbles);
|
|
482
|
-
container.appendChild(chat);
|
|
483
|
-
document.body.appendChild(container);
|
|
484
|
-
document.body.appendChild(selectModeHint);
|
|
485
|
-
document.body.appendChild(elementHighlight);
|
|
486
|
-
document.body.appendChild(elementTooltip);
|
|
487
|
-
if (selectedElements.length > 0) {
|
|
488
|
-
renderSelectedNodes();
|
|
489
|
-
}
|
|
490
|
-
/** @type {Array} 会话列表 */
|
|
491
|
-
let sessions = [];
|
|
492
|
-
/**
|
|
493
|
-
* 显示加载状态
|
|
494
|
-
*/
|
|
495
|
-
function showLoading() {
|
|
496
|
-
loadingOverlay.classList.add("visible");
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* 隐藏加载状态
|
|
500
|
-
*/
|
|
501
|
-
function hideLoading() {
|
|
502
|
-
loadingOverlay.classList.remove("visible");
|
|
503
|
-
}
|
|
504
|
-
/**
|
|
505
|
-
* 加载会话列表
|
|
506
|
-
*/
|
|
507
|
-
async function loadSessions() {
|
|
508
|
-
try {
|
|
509
|
-
const response = await fetch("/__opencode_sessions__");
|
|
510
|
-
sessions = await response.json();
|
|
511
|
-
renderSessionList();
|
|
512
|
-
}
|
|
513
|
-
catch (e) {
|
|
514
|
-
console.error("Failed to load sessions:", e);
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
/**
|
|
518
|
-
* 渲染会话列表
|
|
519
|
-
*/
|
|
520
|
-
function renderSessionList() {
|
|
521
|
-
sessionListContent.innerHTML = "";
|
|
522
|
-
const currentProjectSessions = sessions.filter((session) => session.directory === cwd);
|
|
523
|
-
if (currentProjectSessions.length === 0) {
|
|
524
|
-
emptyStateOverlay.classList.add("visible");
|
|
525
|
-
iframe.style.display = "none";
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
emptyStateOverlay.classList.remove("visible");
|
|
529
|
-
iframe.style.display = "";
|
|
530
|
-
}
|
|
531
|
-
currentProjectSessions.forEach((session) => {
|
|
532
|
-
const item = document.createElement("div");
|
|
533
|
-
item.className = "opencode-session-item";
|
|
534
|
-
item.setAttribute("role", "option");
|
|
535
|
-
item.setAttribute("aria-selected", String(session.id === currentSessionId));
|
|
536
|
-
if (session.id === currentSessionId) {
|
|
537
|
-
item.classList.add("active");
|
|
538
|
-
}
|
|
539
|
-
const header = document.createElement("div");
|
|
540
|
-
header.className = "opencode-session-header";
|
|
541
|
-
const title = document.createElement("div");
|
|
542
|
-
title.className = "opencode-session-title";
|
|
543
|
-
title.textContent = session.title || "新会话";
|
|
544
|
-
const deleteBtn = document.createElement("button");
|
|
545
|
-
deleteBtn.className = "opencode-session-delete-btn";
|
|
546
|
-
deleteBtn.innerHTML = "×";
|
|
547
|
-
deleteBtn.title = "删除会话";
|
|
548
|
-
deleteBtn.setAttribute("aria-label", `删除会话: ${session.title || "新会话"}`);
|
|
549
|
-
deleteBtn.addEventListener("click", (e) => {
|
|
550
|
-
e.stopPropagation();
|
|
551
|
-
confirmDeleteSession(session);
|
|
552
|
-
});
|
|
553
|
-
header.appendChild(title);
|
|
554
|
-
header.appendChild(deleteBtn);
|
|
555
|
-
const meta = document.createElement("div");
|
|
556
|
-
meta.className = "opencode-session-meta";
|
|
557
|
-
const date = new Date(session.time.updated);
|
|
558
|
-
meta.textContent =
|
|
559
|
-
date.toLocaleDateString() + " " + date.toLocaleTimeString();
|
|
560
|
-
item.appendChild(header);
|
|
561
|
-
item.appendChild(meta);
|
|
562
|
-
item.addEventListener("click", () => {
|
|
563
|
-
switchSession(session);
|
|
564
|
-
});
|
|
565
|
-
sessionListContent.appendChild(item);
|
|
566
|
-
});
|
|
567
|
-
}
|
|
568
|
-
/**
|
|
569
|
-
* 切换会话
|
|
570
|
-
*/
|
|
571
|
-
function switchSession(session) {
|
|
572
|
-
if (session.id === currentSessionId) {
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
currentSessionId = session.id;
|
|
576
|
-
const encodedDir = btoa(cwd);
|
|
577
|
-
const baseUrl = webUrl;
|
|
578
|
-
showLoading();
|
|
579
|
-
iframe.src = `${baseUrl}/${encodedDir}/session/${session.id}`;
|
|
580
|
-
renderSessionList();
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* 创建新会话
|
|
584
|
-
*/
|
|
585
|
-
async function createNewSession() {
|
|
586
|
-
try {
|
|
587
|
-
const response = await fetch("/__opencode_sessions__", {
|
|
588
|
-
method: "POST",
|
|
589
|
-
});
|
|
590
|
-
const newSession = await response.json();
|
|
591
|
-
sessions.unshift(newSession);
|
|
592
|
-
switchSession(newSession);
|
|
593
|
-
}
|
|
594
|
-
catch (e) {
|
|
595
|
-
console.error("Failed to create session:", e);
|
|
596
|
-
showNotification("创建会话失败");
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* 确认删除会话
|
|
601
|
-
*/
|
|
602
|
-
async function confirmDeleteSession(session) {
|
|
603
|
-
const confirmed = await showConfirmDialog(`确定要删除会话 "${session.title || "新会话"}" 吗?`);
|
|
604
|
-
if (confirmed) {
|
|
605
|
-
deleteSession(session);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
/**
|
|
609
|
-
* 删除会话
|
|
610
|
-
*/
|
|
611
|
-
async function deleteSession(session) {
|
|
612
|
-
try {
|
|
613
|
-
const response = await fetch(`/__opencode_sessions__?id=${session.id}`, {
|
|
614
|
-
method: "DELETE",
|
|
615
|
-
});
|
|
616
|
-
if (!response.ok) {
|
|
617
|
-
throw new Error("Delete failed");
|
|
618
|
-
}
|
|
619
|
-
sessions = sessions.filter((s) => s.id !== session.id);
|
|
620
|
-
if (session.id === currentSessionId) {
|
|
621
|
-
const remainingSessions = sessions.filter((s) => s.directory === cwd);
|
|
622
|
-
if (remainingSessions.length > 0) {
|
|
623
|
-
switchSession(remainingSessions[0]);
|
|
624
|
-
}
|
|
625
|
-
else {
|
|
626
|
-
currentSessionId = null;
|
|
627
|
-
iframe.src = "about:blank";
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
renderSessionList();
|
|
631
|
-
showNotification("会话已删除");
|
|
632
|
-
}
|
|
633
|
-
catch (e) {
|
|
634
|
-
console.error("Failed to delete session:", e);
|
|
635
|
-
showNotification("删除会话失败");
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
// 绑定新建会话按钮
|
|
639
|
-
sessionListHeader
|
|
640
|
-
.querySelector(".opencode-new-session-btn")
|
|
641
|
-
.addEventListener("click", createNewSession);
|
|
642
|
-
/**
|
|
643
|
-
* 应用主题
|
|
644
|
-
*/
|
|
645
|
-
function applyTheme() {
|
|
646
|
-
const resolvedTheme = theme === "auto"
|
|
647
|
-
? window.matchMedia("(prefers-color-scheme: dark)").matches
|
|
648
|
-
? "dark"
|
|
649
|
-
: "light"
|
|
650
|
-
: theme;
|
|
651
|
-
container.classList.toggle("opencode-dark", resolvedTheme === "dark");
|
|
652
|
-
container.style.colorScheme = resolvedTheme;
|
|
653
|
-
}
|
|
654
|
-
applyTheme();
|
|
655
|
-
if (theme === "auto") {
|
|
656
|
-
window
|
|
657
|
-
.matchMedia("(prefers-color-scheme: dark)")
|
|
658
|
-
.addEventListener("change", applyTheme);
|
|
659
|
-
}
|
|
660
|
-
/**
|
|
661
|
-
* 切换挂件显示状态
|
|
662
|
-
*/
|
|
663
|
-
async function toggle() {
|
|
664
|
-
if (lazy && !servicesStarted) {
|
|
665
|
-
button.classList.add("loading");
|
|
666
|
-
const started = await ensureServicesStarted();
|
|
667
|
-
button.classList.remove("loading");
|
|
668
|
-
if (!started) {
|
|
669
|
-
showNotification("服务启动失败,请检查控制台");
|
|
670
|
-
return;
|
|
671
|
-
}
|
|
672
|
-
setupSSEConnection();
|
|
673
|
-
}
|
|
674
|
-
if (isSelectMode) {
|
|
675
|
-
exitSelectMode();
|
|
676
|
-
updateContext();
|
|
677
|
-
return;
|
|
678
|
-
}
|
|
679
|
-
isOpen = !isOpen;
|
|
680
|
-
chat.classList.toggle("open", isOpen);
|
|
681
|
-
button.classList.toggle("active", isOpen);
|
|
682
|
-
if (isOpen) {
|
|
683
|
-
updateContext();
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
button.addEventListener("click", toggle);
|
|
687
|
-
document.addEventListener("keydown", (e) => {
|
|
688
|
-
if (matchHotkey(e, mainHotkey)) {
|
|
689
|
-
e.preventDefault();
|
|
690
|
-
toggle();
|
|
691
|
-
}
|
|
692
|
-
if (matchHotkey(e, selectHotkey)) {
|
|
693
|
-
e.preventDefault();
|
|
694
|
-
if (window.__VUE_INSPECTOR__) {
|
|
695
|
-
toggleSelectMode();
|
|
696
|
-
}
|
|
697
|
-
else {
|
|
698
|
-
showNotification("Vue Inspector 未加载,无法使用元素选择功能");
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
});
|
|
702
|
-
if (open && servicesStarted) {
|
|
703
|
-
setTimeout(() => {
|
|
704
|
-
toggle();
|
|
705
|
-
}, AUTO_OPEN_DELAY);
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* 显示自定义确认对话框
|
|
709
|
-
* @param {string} message - 确认消息
|
|
710
|
-
* @returns {Promise<boolean>} 用户选择结果
|
|
711
|
-
*/
|
|
712
|
-
function showConfirmDialog(message) {
|
|
713
|
-
return new Promise((resolve) => {
|
|
714
|
-
const overlay = document.createElement("div");
|
|
715
|
-
overlay.className = "opencode-dialog-overlay";
|
|
716
|
-
const dialog = document.createElement("div");
|
|
717
|
-
dialog.className = "opencode-dialog";
|
|
718
|
-
dialog.setAttribute("role", "alertdialog");
|
|
719
|
-
dialog.setAttribute("aria-modal", "true");
|
|
720
|
-
dialog.setAttribute("aria-labelledby", "opencode-dialog-title");
|
|
721
|
-
dialog.setAttribute("aria-describedby", "opencode-dialog-desc");
|
|
722
|
-
dialog.innerHTML = `
|
|
723
|
-
<div class="opencode-dialog-content">
|
|
724
|
-
<div id="opencode-dialog-desc" class="opencode-dialog-message">${message}</div>
|
|
725
|
-
</div>
|
|
726
|
-
<div class="opencode-dialog-actions">
|
|
727
|
-
<button class="opencode-dialog-btn cancel" aria-label="取消">取消</button>
|
|
728
|
-
<button class="opencode-dialog-btn confirm" aria-label="确认">确认</button>
|
|
729
|
-
</div>
|
|
730
|
-
`;
|
|
731
|
-
const handleConfirm = () => {
|
|
732
|
-
overlay.remove();
|
|
733
|
-
resolve(true);
|
|
734
|
-
};
|
|
735
|
-
const handleCancel = () => {
|
|
736
|
-
overlay.remove();
|
|
737
|
-
resolve(false);
|
|
738
|
-
};
|
|
739
|
-
dialog
|
|
740
|
-
.querySelector(".confirm")
|
|
741
|
-
.addEventListener("click", handleConfirm);
|
|
742
|
-
dialog.querySelector(".cancel").addEventListener("click", handleCancel);
|
|
743
|
-
overlay.addEventListener("click", (e) => {
|
|
744
|
-
if (e.target === overlay) {
|
|
745
|
-
handleCancel();
|
|
746
|
-
}
|
|
747
|
-
});
|
|
748
|
-
document.addEventListener("keydown", function handleEscape(e) {
|
|
749
|
-
if (e.key === "Escape") {
|
|
750
|
-
document.removeEventListener("keydown", handleEscape);
|
|
751
|
-
handleCancel();
|
|
752
|
-
}
|
|
753
|
-
});
|
|
754
|
-
overlay.appendChild(dialog);
|
|
755
|
-
container.appendChild(overlay);
|
|
756
|
-
dialog.querySelector(".confirm").focus();
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
/**
|
|
760
|
-
* 显示通知
|
|
761
|
-
* @param {string} message - 通知消息
|
|
762
|
-
*/
|
|
763
|
-
function showNotification(message) {
|
|
764
|
-
const notification = document.createElement("div");
|
|
765
|
-
notification.className = "opencode-notification";
|
|
766
|
-
notification.textContent = message;
|
|
767
|
-
chat.appendChild(notification);
|
|
768
|
-
setTimeout(() => {
|
|
769
|
-
notification.remove();
|
|
770
|
-
}, NOTIFICATION_DURATION);
|
|
771
|
-
}
|
|
772
|
-
/**
|
|
773
|
-
* 添加选中元素
|
|
774
|
-
* @param {SelectedElement} elementInfo - 元素信息
|
|
775
|
-
*/
|
|
776
|
-
function addElement(elementInfo) {
|
|
777
|
-
const key = elementInfo.filePath && elementInfo.line
|
|
778
|
-
? `${elementInfo.filePath}:${elementInfo.line}`
|
|
779
|
-
: null;
|
|
780
|
-
const exists = key &&
|
|
781
|
-
selectedElements.some((el) => {
|
|
782
|
-
const elKey = el.filePath && el.line ? `${el.filePath}:${el.line}` : null;
|
|
783
|
-
return elKey === key;
|
|
784
|
-
});
|
|
785
|
-
if (!exists) {
|
|
786
|
-
selectedElements.push(elementInfo);
|
|
787
|
-
saveSelectedElements(selectedElements);
|
|
788
|
-
renderSelectedNodes();
|
|
789
|
-
if (isSelectMode) {
|
|
790
|
-
renderSelectedBubbles();
|
|
791
|
-
}
|
|
792
|
-
showNotification(`已选中元素 (${selectedElements.length}个)`);
|
|
793
|
-
}
|
|
794
|
-
else {
|
|
795
|
-
showNotification("该元素已选中");
|
|
796
|
-
}
|
|
797
|
-
}
|
|
798
|
-
/**
|
|
799
|
-
* 移除选中元素
|
|
800
|
-
* @param {number} index - 元素索引
|
|
801
|
-
*/
|
|
802
|
-
function removeElement(index) {
|
|
803
|
-
selectedElements.splice(index, 1);
|
|
804
|
-
saveSelectedElements(selectedElements);
|
|
805
|
-
renderSelectedNodes();
|
|
806
|
-
updateToolbarState();
|
|
807
|
-
sendSelectedElements();
|
|
808
|
-
}
|
|
809
|
-
/**
|
|
810
|
-
* 清除所有选中元素
|
|
811
|
-
*/
|
|
812
|
-
function clearAllElements() {
|
|
813
|
-
selectedElements = [];
|
|
814
|
-
saveSelectedElements(selectedElements);
|
|
815
|
-
renderSelectedNodes();
|
|
816
|
-
updateToolbarState();
|
|
817
|
-
sendSelectedElements();
|
|
818
|
-
showNotification("已清除所有选中元素");
|
|
819
|
-
}
|
|
820
|
-
/**
|
|
821
|
-
* 更新工具栏状态
|
|
822
|
-
*/
|
|
823
|
-
function updateToolbarState() {
|
|
824
|
-
if (selectedElements.length > 0) {
|
|
825
|
-
rightToolbar.classList.remove("collapsed");
|
|
826
|
-
}
|
|
827
|
-
else {
|
|
828
|
-
rightToolbar.classList.add("collapsed");
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
/** @type {boolean} 是否处于元素选择模式 */
|
|
832
|
-
let isSelectMode = false;
|
|
833
|
-
/**
|
|
834
|
-
* 处理鼠标移动事件(选择模式下高亮元素)
|
|
835
|
-
* @param {MouseEvent} e - 鼠标事件
|
|
836
|
-
*/
|
|
837
|
-
function handleMouseMove(e) {
|
|
838
|
-
if (!isSelectMode)
|
|
839
|
-
return;
|
|
840
|
-
const inspector = window.__VUE_INSPECTOR__;
|
|
841
|
-
if (!inspector)
|
|
842
|
-
return;
|
|
843
|
-
const { targetNode, params } = inspector.getTargetNode(e);
|
|
844
|
-
if (targetNode && params) {
|
|
845
|
-
const rect = targetNode.getBoundingClientRect();
|
|
846
|
-
elementHighlight.style.display = "block";
|
|
847
|
-
elementHighlight.style.top = `${rect.top}px`;
|
|
848
|
-
elementHighlight.style.left = `${rect.left}px`;
|
|
849
|
-
elementHighlight.style.width = `${rect.width}px`;
|
|
850
|
-
elementHighlight.style.height = `${rect.height}px`;
|
|
851
|
-
const description = getElementDescription(targetNode);
|
|
852
|
-
const fileName = params.file ? params.file.split("/").pop() : "";
|
|
853
|
-
let lineInfo = "";
|
|
854
|
-
if (params.line) {
|
|
855
|
-
lineInfo = `:${params.line}`;
|
|
856
|
-
if (params.column) {
|
|
857
|
-
lineInfo += `:${params.column}`;
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
|
-
elementTooltip.innerHTML = `
|
|
861
|
-
<div class="opencode-tooltip-tag">${description}</div>
|
|
862
|
-
${fileName ? `<div class="opencode-tooltip-file">${fileName}${lineInfo}</div>` : ""}
|
|
863
|
-
`;
|
|
864
|
-
elementTooltip.style.display = "block";
|
|
865
|
-
const tooltipRect = elementTooltip.getBoundingClientRect();
|
|
866
|
-
let tooltipTop = rect.top - tooltipRect.height - 8;
|
|
867
|
-
let tooltipLeft = rect.left;
|
|
868
|
-
if (tooltipTop < 10) {
|
|
869
|
-
tooltipTop = rect.bottom + 8;
|
|
870
|
-
}
|
|
871
|
-
if (tooltipLeft + tooltipRect.width > window.innerWidth - 10) {
|
|
872
|
-
tooltipLeft = window.innerWidth - tooltipRect.width - 10;
|
|
873
|
-
}
|
|
874
|
-
elementTooltip.style.top = `${tooltipTop}px`;
|
|
875
|
-
elementTooltip.style.left = `${tooltipLeft}px`;
|
|
876
|
-
}
|
|
877
|
-
else {
|
|
878
|
-
elementHighlight.style.display = "none";
|
|
879
|
-
elementTooltip.style.display = "none";
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
/**
|
|
883
|
-
* 切换元素选择模式
|
|
884
|
-
*/
|
|
885
|
-
function toggleSelectMode() {
|
|
886
|
-
const inspector = window.__VUE_INSPECTOR__;
|
|
887
|
-
if (!inspector) {
|
|
888
|
-
showNotification("Vue Inspector 未加载,无法使用元素选择功能");
|
|
889
|
-
return;
|
|
890
|
-
}
|
|
891
|
-
isSelectMode = !isSelectMode;
|
|
892
|
-
selectButton.classList.toggle("active", isSelectMode);
|
|
893
|
-
selectButton.setAttribute("aria-pressed", String(isSelectMode));
|
|
894
|
-
selectModeHint.classList.toggle("visible", isSelectMode);
|
|
895
|
-
selectedBubbles.classList.toggle("visible", isSelectMode);
|
|
896
|
-
if (isSelectMode) {
|
|
897
|
-
if (isOpen) {
|
|
898
|
-
isOpen = false;
|
|
899
|
-
chat.classList.remove("open");
|
|
900
|
-
button.classList.remove("active");
|
|
901
|
-
}
|
|
902
|
-
chat.style.display = "none";
|
|
903
|
-
inspector.enable();
|
|
904
|
-
renderSelectedBubbles();
|
|
905
|
-
document.addEventListener("mousemove", handleMouseMove);
|
|
906
|
-
}
|
|
907
|
-
else {
|
|
908
|
-
chat.style.display = "";
|
|
909
|
-
isOpen = true;
|
|
910
|
-
chat.classList.add("open");
|
|
911
|
-
button.classList.add("active");
|
|
912
|
-
inspector.disable();
|
|
913
|
-
document.removeEventListener("mousemove", handleMouseMove);
|
|
914
|
-
elementHighlight.style.display = "none";
|
|
915
|
-
elementTooltip.style.display = "none";
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
/**
|
|
919
|
-
* 退出选择模式
|
|
920
|
-
*/
|
|
921
|
-
function exitSelectMode() {
|
|
922
|
-
if (!isSelectMode)
|
|
923
|
-
return;
|
|
924
|
-
const inspector = window.__VUE_INSPECTOR__;
|
|
925
|
-
if (inspector) {
|
|
926
|
-
inspector.disable();
|
|
927
|
-
}
|
|
928
|
-
isSelectMode = false;
|
|
929
|
-
selectButton.classList.remove("active");
|
|
930
|
-
selectModeHint.classList.remove("visible");
|
|
931
|
-
selectedBubbles.classList.remove("visible");
|
|
932
|
-
chat.style.display = "";
|
|
933
|
-
isOpen = true;
|
|
934
|
-
chat.classList.add("open");
|
|
935
|
-
button.classList.add("active");
|
|
936
|
-
document.removeEventListener("mousemove", handleMouseMove);
|
|
937
|
-
elementHighlight.style.display = "none";
|
|
938
|
-
elementTooltip.style.display = "none";
|
|
939
|
-
}
|
|
940
|
-
// ESC 键退出选择模式(使用捕获阶段确保优先处理)
|
|
941
|
-
document.addEventListener("keydown", (e) => {
|
|
942
|
-
if (e.key === "Escape" && isSelectMode) {
|
|
943
|
-
e.preventDefault();
|
|
944
|
-
e.stopPropagation();
|
|
945
|
-
exitSelectMode();
|
|
946
|
-
}
|
|
947
|
-
}, true);
|
|
948
|
-
/**
|
|
949
|
-
* 建立 SSE 连接监听服务端事件
|
|
950
|
-
*/
|
|
951
|
-
function setupSSEConnection() {
|
|
952
|
-
if (!servicesStarted || sseConnection)
|
|
953
|
-
return;
|
|
954
|
-
sseConnection = new EventSource("/__opencode_events__");
|
|
955
|
-
sseConnection.onopen = () => {
|
|
956
|
-
console.log("[OpenCode] SSE connected");
|
|
957
|
-
};
|
|
958
|
-
sseConnection.onmessage = (event) => {
|
|
959
|
-
try {
|
|
960
|
-
const data = JSON.parse(event.data);
|
|
961
|
-
console.log("[OpenCode] SSE message:", data);
|
|
962
|
-
if (data.type === "CONNECTED") {
|
|
963
|
-
// 连接成功后,主动同步当前节点到服务端
|
|
964
|
-
if (selectedElements.length > 0) {
|
|
965
|
-
fetch("/__opencode_context__", {
|
|
966
|
-
method: "POST",
|
|
967
|
-
headers: { "Content-Type": "application/json" },
|
|
968
|
-
body: JSON.stringify({
|
|
969
|
-
url: window.location.href,
|
|
970
|
-
title: document.title,
|
|
971
|
-
selectedElements: selectedElements,
|
|
972
|
-
}),
|
|
973
|
-
}).catch(() => { });
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
if (data.type === "SESSION_READY") {
|
|
977
|
-
if (data.sessionUrl && !sessionUrl) {
|
|
978
|
-
sessionUrl = data.sessionUrl;
|
|
979
|
-
currentSessionId = extractSessionId(sessionUrl);
|
|
980
|
-
if (iframe) {
|
|
981
|
-
iframe.src = sessionUrl;
|
|
982
|
-
}
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
if (data.type === "CLEAR_ELEMENTS" && selectedElements.length > 0) {
|
|
986
|
-
console.log("[OpenCode] Clearing elements");
|
|
987
|
-
selectedElements = [];
|
|
988
|
-
saveSelectedElements(selectedElements);
|
|
989
|
-
renderSelectedNodes();
|
|
990
|
-
updateToolbarState();
|
|
991
|
-
if (isSelectMode) {
|
|
992
|
-
renderSelectedBubbles();
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
catch (e) {
|
|
997
|
-
console.error("[OpenCode] SSE parse error:", e);
|
|
998
|
-
}
|
|
999
|
-
};
|
|
1000
|
-
sseConnection.onerror = (e) => {
|
|
1001
|
-
console.error("[OpenCode] SSE error:", e);
|
|
1002
|
-
// 连接失败时自动重连
|
|
1003
|
-
if (sseConnection) {
|
|
1004
|
-
sseConnection.close();
|
|
1005
|
-
sseConnection = null;
|
|
1006
|
-
}
|
|
1007
|
-
setTimeout(setupSSEConnection, 3000);
|
|
1008
|
-
};
|
|
1009
|
-
}
|
|
1010
|
-
/**
|
|
1011
|
-
* 渲染已选节点气泡
|
|
1012
|
-
*/
|
|
1013
|
-
function renderSelectedBubbles() {
|
|
1014
|
-
selectedBubbles.innerHTML = "";
|
|
1015
|
-
if (selectedElements.length === 0) {
|
|
1016
|
-
selectedBubbles.innerHTML =
|
|
1017
|
-
'<div class="opencode-bubble-empty">暂无选中元素</div>';
|
|
1018
|
-
return;
|
|
1019
|
-
}
|
|
1020
|
-
selectedElements.forEach((element, index) => {
|
|
1021
|
-
const bubble = document.createElement("div");
|
|
1022
|
-
bubble.className = "opencode-selected-bubble";
|
|
1023
|
-
bubble.setAttribute("role", "listitem");
|
|
1024
|
-
const description = element.description || "未知元素";
|
|
1025
|
-
const fileName = element.filePath
|
|
1026
|
-
? element.filePath.split("/").pop()
|
|
1027
|
-
: "";
|
|
1028
|
-
const lineInfo = element.line
|
|
1029
|
-
? `:${element.line}${element.column ? `:${element.column}` : ""}`
|
|
1030
|
-
: "";
|
|
1031
|
-
bubble.innerHTML = `
|
|
1032
|
-
<span class="opencode-bubble-text">${description}</span>
|
|
1033
|
-
${fileName ? `<span class="opencode-bubble-file">${fileName}${lineInfo}</span>` : ""}
|
|
1034
|
-
<button class="opencode-bubble-remove" data-index="${index}" aria-label="移除元素: ${description}">×</button>
|
|
1035
|
-
`;
|
|
1036
|
-
bubble
|
|
1037
|
-
.querySelector(".opencode-bubble-remove")
|
|
1038
|
-
.addEventListener("click", (e) => {
|
|
1039
|
-
e.stopPropagation();
|
|
1040
|
-
removeElement(index);
|
|
1041
|
-
renderSelectedBubbles();
|
|
1042
|
-
});
|
|
1043
|
-
selectedBubbles.appendChild(bubble);
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
function renderSelectedNodes() {
|
|
1047
|
-
selectedNodesContainer.innerHTML = "";
|
|
1048
|
-
if (selectedElements.length === 0) {
|
|
1049
|
-
rightToolbar.classList.add("collapsed");
|
|
1050
|
-
clearAllButton.style.display = "none";
|
|
1051
|
-
}
|
|
1052
|
-
else {
|
|
1053
|
-
rightToolbar.classList.remove("collapsed");
|
|
1054
|
-
clearAllButton.style.display = "block";
|
|
1055
|
-
}
|
|
1056
|
-
selectedElements.forEach((element, index) => {
|
|
1057
|
-
const node = document.createElement("div");
|
|
1058
|
-
node.className = "opencode-selected-node";
|
|
1059
|
-
node.setAttribute("role", "listitem");
|
|
1060
|
-
const description = element.description || "未知元素";
|
|
1061
|
-
const textPreview = element.innerText
|
|
1062
|
-
? element.innerText.substring(0, 30)
|
|
1063
|
-
: "";
|
|
1064
|
-
const fileName = element.filePath
|
|
1065
|
-
? element.filePath.split("/").pop()
|
|
1066
|
-
: "未知文件";
|
|
1067
|
-
const lineInfo = element.line
|
|
1068
|
-
? `:${element.line}${element.column ? `:${element.column}` : ""}`
|
|
1069
|
-
: "";
|
|
1070
|
-
node.innerHTML = `
|
|
1071
|
-
<div class="opencode-node-content">
|
|
1072
|
-
<span class="opencode-node-text">${description}</span>
|
|
1073
|
-
<span class="opencode-node-file">${textPreview ? textPreview + " · " : ""}${fileName}${lineInfo}</span>
|
|
1074
|
-
</div>
|
|
1075
|
-
<button class="opencode-node-remove" data-index="${index}" aria-label="移除元素: ${description}">×</button>
|
|
1076
|
-
`;
|
|
1077
|
-
node
|
|
1078
|
-
.querySelector(".opencode-node-remove")
|
|
1079
|
-
.addEventListener("click", (e) => {
|
|
1080
|
-
e.stopPropagation();
|
|
1081
|
-
removeElement(index);
|
|
1082
|
-
});
|
|
1083
|
-
node.addEventListener("click", () => {
|
|
1084
|
-
highlightElement(element);
|
|
1085
|
-
});
|
|
1086
|
-
selectedNodesContainer.appendChild(node);
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
|
-
// 绑定清空按钮点击事件
|
|
1090
|
-
clearAllButton.addEventListener("click", async () => {
|
|
1091
|
-
if (selectedElements.length === 0)
|
|
1092
|
-
return;
|
|
1093
|
-
const confirmed = await showConfirmDialog(`确定要清空所有 ${selectedElements.length} 个已选节点吗?`);
|
|
1094
|
-
if (confirmed) {
|
|
1095
|
-
clearAllElements();
|
|
1096
|
-
}
|
|
1097
|
-
});
|
|
1098
|
-
// 绑定选择按钮点击事件
|
|
1099
|
-
selectButton.addEventListener("click", toggleSelectMode);
|
|
1100
|
-
/**
|
|
1101
|
-
* 高亮页面元素
|
|
1102
|
-
* @param {SelectedElement} element - 元素信息
|
|
1103
|
-
*/
|
|
1104
|
-
function highlightElement(element) {
|
|
1105
|
-
try {
|
|
1106
|
-
const description = element.description;
|
|
1107
|
-
if (!description)
|
|
1108
|
-
return;
|
|
1109
|
-
let targetElement = null;
|
|
1110
|
-
if (description.includes("#")) {
|
|
1111
|
-
const idMatch = description.match(/#([^\.\[\s]+)/);
|
|
1112
|
-
if (idMatch) {
|
|
1113
|
-
targetElement = document.getElementById(idMatch[1]);
|
|
1114
|
-
}
|
|
1115
|
-
}
|
|
1116
|
-
if (!targetElement && description.includes(".")) {
|
|
1117
|
-
const classMatch = description.match(/^([a-z]+)\.([^\[\s]+)/i);
|
|
1118
|
-
if (classMatch) {
|
|
1119
|
-
const tagName = classMatch[1];
|
|
1120
|
-
const classes = classMatch[2].split(".").filter(Boolean);
|
|
1121
|
-
const selector = `${tagName}.${classes.join(".")}`;
|
|
1122
|
-
targetElement = document.querySelector(selector);
|
|
1123
|
-
}
|
|
1124
|
-
}
|
|
1125
|
-
if (!targetElement) {
|
|
1126
|
-
const tagMatch = description.match(/^([a-z]+)/i);
|
|
1127
|
-
if (tagMatch) {
|
|
1128
|
-
const simpleSelector = description.split(/[\.\[\s]/)[0];
|
|
1129
|
-
targetElement = document.querySelector(simpleSelector);
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
if (targetElement) {
|
|
1133
|
-
targetElement.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
1134
|
-
const highlightOverlay = document.createElement("div");
|
|
1135
|
-
highlightOverlay.className = "opencode-element-highlight-temp";
|
|
1136
|
-
const rect = targetElement.getBoundingClientRect();
|
|
1137
|
-
highlightOverlay.style.top = `${rect.top + window.scrollY}px`;
|
|
1138
|
-
highlightOverlay.style.left = `${rect.left + window.scrollX}px`;
|
|
1139
|
-
highlightOverlay.style.width = `${rect.width}px`;
|
|
1140
|
-
highlightOverlay.style.height = `${rect.height}px`;
|
|
1141
|
-
document.body.appendChild(highlightOverlay);
|
|
1142
|
-
setTimeout(() => {
|
|
1143
|
-
highlightOverlay.remove();
|
|
1144
|
-
}, 2000);
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
catch (e) {
|
|
1148
|
-
console.error("Failed to highlight element:", e);
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
/**
|
|
1152
|
-
* 发送选中元素到服务器
|
|
1153
|
-
*/
|
|
1154
|
-
function sendSelectedElements() {
|
|
1155
|
-
if (!servicesStarted) {
|
|
1156
|
-
console.log("[OpenCode] sendSelectedElements: services not started");
|
|
1157
|
-
return;
|
|
1158
|
-
}
|
|
1159
|
-
console.log("[OpenCode] Sending selected elements:", selectedElements);
|
|
1160
|
-
fetch("/__opencode_context__", {
|
|
1161
|
-
method: "POST",
|
|
1162
|
-
headers: { "Content-Type": "application/json" },
|
|
1163
|
-
body: JSON.stringify({
|
|
1164
|
-
url: currentPageUrl,
|
|
1165
|
-
title: currentPageTitle,
|
|
1166
|
-
selectedElements: selectedElements,
|
|
1167
|
-
}),
|
|
1168
|
-
})
|
|
1169
|
-
.then(() => {
|
|
1170
|
-
console.log("[OpenCode] Selected elements sent successfully");
|
|
1171
|
-
})
|
|
1172
|
-
.catch((e) => {
|
|
1173
|
-
console.error("[OpenCode] Failed to send selected elements:", e);
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
1176
|
-
/**
|
|
1177
|
-
* 截断字符串
|
|
1178
|
-
* @param {string} str - 原字符串
|
|
1179
|
-
* @param {number} maxLength - 最大长度
|
|
1180
|
-
* @returns {string} 截断后的字符串
|
|
1181
|
-
*/
|
|
1182
|
-
function truncate(str, maxLength) {
|
|
1183
|
-
if (!str)
|
|
1184
|
-
return "";
|
|
1185
|
-
return str.length > maxLength ? str.substring(0, maxLength) + "..." : str;
|
|
1186
|
-
}
|
|
1187
|
-
/**
|
|
1188
|
-
* 获取元素的直接文本内容
|
|
1189
|
-
* @param {Element} element - DOM 元素
|
|
1190
|
-
* @returns {string} 直接文本内容
|
|
1191
|
-
*/
|
|
1192
|
-
function getDirectText(element) {
|
|
1193
|
-
let text = "";
|
|
1194
|
-
for (const child of element.childNodes) {
|
|
1195
|
-
if (child.nodeType === Node.TEXT_NODE) {
|
|
1196
|
-
text += child.textContent || "";
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
return text.trim();
|
|
1200
|
-
}
|
|
1201
|
-
/**
|
|
1202
|
-
* 获取元素描述信息
|
|
1203
|
-
* @param {Element} element - DOM 元素
|
|
1204
|
-
* @returns {string} 元素描述
|
|
1205
|
-
*/
|
|
1206
|
-
function getElementDescription(element) {
|
|
1207
|
-
const tag = element.tagName.toLowerCase();
|
|
1208
|
-
const parts = [tag];
|
|
1209
|
-
const id = element.id;
|
|
1210
|
-
if (id)
|
|
1211
|
-
parts.push(`#${id}`);
|
|
1212
|
-
const className = element.className && typeof element.className === "string"
|
|
1213
|
-
? element.className
|
|
1214
|
-
.trim()
|
|
1215
|
-
.split(/\s+/)
|
|
1216
|
-
.filter(Boolean)
|
|
1217
|
-
.slice(0, 2)
|
|
1218
|
-
.join(".")
|
|
1219
|
-
: "";
|
|
1220
|
-
if (className)
|
|
1221
|
-
parts.push(`.${className}`);
|
|
1222
|
-
const name = element.getAttribute("name");
|
|
1223
|
-
if (name)
|
|
1224
|
-
parts.push(`[name="${name}"]`);
|
|
1225
|
-
const placeholder = element.getAttribute("placeholder");
|
|
1226
|
-
if (placeholder)
|
|
1227
|
-
parts.push(`[placeholder="${placeholder.substring(0, 20)}"]`);
|
|
1228
|
-
const src = element.getAttribute("src");
|
|
1229
|
-
if (src)
|
|
1230
|
-
parts.push(`[src]`);
|
|
1231
|
-
const href = element.getAttribute("href");
|
|
1232
|
-
if (href && href !== "#")
|
|
1233
|
-
parts.push(`[href]`);
|
|
1234
|
-
return parts.join("");
|
|
1235
|
-
}
|
|
1236
|
-
/**
|
|
1237
|
-
* 设置 Vue Inspector 钩子
|
|
1238
|
-
*/
|
|
1239
|
-
function setupInspectorHook() {
|
|
1240
|
-
if (window.__VUE_INSPECTOR__) {
|
|
1241
|
-
const inspector = window.__VUE_INSPECTOR__;
|
|
1242
|
-
const originalHandleClick = inspector.handleClick.bind(inspector);
|
|
1243
|
-
inspector.handleClick = function (e) {
|
|
1244
|
-
if (isSelectMode) {
|
|
1245
|
-
const { targetNode, params } = inspector.getTargetNode(e);
|
|
1246
|
-
if (targetNode && params) {
|
|
1247
|
-
const innerText = getDirectText(targetNode);
|
|
1248
|
-
const description = getElementDescription(targetNode);
|
|
1249
|
-
const elementInfo = {
|
|
1250
|
-
filePath: params.file,
|
|
1251
|
-
line: params.line,
|
|
1252
|
-
column: params.column,
|
|
1253
|
-
innerText: truncate(innerText, 200),
|
|
1254
|
-
description,
|
|
1255
|
-
};
|
|
1256
|
-
addElement(elementInfo);
|
|
1257
|
-
sendSelectedElements();
|
|
1258
|
-
}
|
|
1259
|
-
return;
|
|
1260
|
-
}
|
|
1261
|
-
return originalHandleClick.call(inspector, e);
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
if (window.__VUE_INSPECTOR__) {
|
|
1266
|
-
setupInspectorHook();
|
|
1267
|
-
}
|
|
1268
|
-
else {
|
|
1269
|
-
const checkInspector = setInterval(() => {
|
|
1270
|
-
if (window.__VUE_INSPECTOR__) {
|
|
1271
|
-
setupInspectorHook();
|
|
1272
|
-
clearInterval(checkInspector);
|
|
1273
|
-
}
|
|
1274
|
-
}, INSPECTOR_CHECK_INTERVAL);
|
|
1275
|
-
}
|
|
1276
|
-
// 导出全局 API
|
|
1277
|
-
window.OpenCodeWidget = {
|
|
1278
|
-
open: () => {
|
|
1279
|
-
if (!isOpen)
|
|
1280
|
-
toggle();
|
|
1281
|
-
},
|
|
1282
|
-
close: () => {
|
|
1283
|
-
if (isOpen)
|
|
1284
|
-
toggle();
|
|
1285
|
-
},
|
|
1286
|
-
toggle,
|
|
1287
|
-
showNotification,
|
|
1288
|
-
updateContext,
|
|
1289
|
-
};
|
|
1290
|
-
}
|
|
1291
|
-
/**
|
|
1292
|
-
* 构建挂件样式
|
|
1293
|
-
* @returns {string} CSS 样式字符串
|
|
1294
|
-
*/
|
|
1295
|
-
function buildWidgetStyles() {
|
|
1296
|
-
return `
|
|
1297
|
-
.opencode-widget {
|
|
1298
|
-
position: fixed;
|
|
1299
|
-
z-index: 999999;
|
|
1300
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
.opencode-widget.bottom-right {
|
|
1304
|
-
bottom: 20px;
|
|
1305
|
-
right: 20px;
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
.opencode-widget.bottom-left {
|
|
1309
|
-
bottom: 20px;
|
|
1310
|
-
left: 20px;
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
.opencode-widget.top-right {
|
|
1314
|
-
top: 20px;
|
|
1315
|
-
right: 20px;
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
.opencode-widget.top-left {
|
|
1319
|
-
top: 20px;
|
|
1320
|
-
left: 20px;
|
|
1321
|
-
}
|
|
1322
|
-
|
|
1323
|
-
.opencode-button {
|
|
1324
|
-
width: 44px;
|
|
1325
|
-
height: 44px;
|
|
1326
|
-
border-radius: 50%;
|
|
1327
|
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
1328
|
-
border: none;
|
|
1329
|
-
cursor: pointer;
|
|
1330
|
-
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
|
|
1331
|
-
transition: all 0.3s ease;
|
|
1332
|
-
display: flex;
|
|
1333
|
-
align-items: center;
|
|
1334
|
-
justify-content: center;
|
|
1335
|
-
color: white;
|
|
1336
|
-
padding: 0;
|
|
1337
|
-
position: relative;
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
|
-
.opencode-button::before {
|
|
1341
|
-
content: '';
|
|
1342
|
-
position: absolute;
|
|
1343
|
-
top: -8px;
|
|
1344
|
-
left: -8px;
|
|
1345
|
-
right: -8px;
|
|
1346
|
-
bottom: -8px;
|
|
1347
|
-
border-radius: 50%;
|
|
1348
|
-
}
|
|
1349
|
-
|
|
1350
|
-
.opencode-button:hover {
|
|
1351
|
-
transform: scale(1.1);
|
|
1352
|
-
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
|
|
1353
|
-
background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
|
|
1354
|
-
}
|
|
1355
|
-
|
|
1356
|
-
.opencode-button.active {
|
|
1357
|
-
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
|
|
1358
|
-
box-shadow: 0 6px 20px rgba(240, 147, 251, 0.4);
|
|
1359
|
-
}
|
|
1360
|
-
|
|
1361
|
-
.opencode-button.active svg {
|
|
1362
|
-
transform: rotate(180deg);
|
|
1363
|
-
}
|
|
1364
|
-
|
|
1365
|
-
.opencode-button svg {
|
|
1366
|
-
transition: transform 0.3s ease;
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
.opencode-button.loading {
|
|
1370
|
-
animation: pulse 1s infinite;
|
|
1371
|
-
}
|
|
1372
|
-
|
|
1373
|
-
@keyframes pulse {
|
|
1374
|
-
0%, 100% { opacity: 1; }
|
|
1375
|
-
50% { opacity: 0.5; }
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
.opencode-chat {
|
|
1379
|
-
position: absolute;
|
|
1380
|
-
width: 700px;
|
|
1381
|
-
height: 86vh;
|
|
1382
|
-
background: white;
|
|
1383
|
-
border-radius: 16px;
|
|
1384
|
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
|
1385
|
-
overflow: hidden;
|
|
1386
|
-
opacity: 0;
|
|
1387
|
-
visibility: hidden;
|
|
1388
|
-
transform: translateY(20px) scale(0.95);
|
|
1389
|
-
transition: all 0.3s ease;
|
|
1390
|
-
display: flex;
|
|
1391
|
-
flex-direction: column;
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
.opencode-chat-content {
|
|
1395
|
-
display: flex;
|
|
1396
|
-
flex: 1;
|
|
1397
|
-
overflow: hidden;
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
.opencode-widget.bottom-right .opencode-chat {
|
|
1401
|
-
bottom: 48px;
|
|
1402
|
-
right: 0;
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
.opencode-widget.bottom-left .opencode-chat {
|
|
1406
|
-
bottom: 48px;
|
|
1407
|
-
left: 0;
|
|
1408
|
-
}
|
|
1409
|
-
|
|
1410
|
-
.opencode-widget.top-right .opencode-chat {
|
|
1411
|
-
top: 48px;
|
|
1412
|
-
right: 0;
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
.opencode-widget.top-left .opencode-chat {
|
|
1416
|
-
top: 48px;
|
|
1417
|
-
left: 0;
|
|
1418
|
-
}
|
|
1419
|
-
|
|
1420
|
-
.opencode-chat.open {
|
|
1421
|
-
opacity: 1;
|
|
1422
|
-
visibility: visible;
|
|
1423
|
-
transform: translateY(0) scale(1);
|
|
1424
|
-
}
|
|
1425
|
-
|
|
1426
|
-
.opencode-chat-header {
|
|
1427
|
-
position: relative;
|
|
1428
|
-
flex-shrink: 0;
|
|
1429
|
-
display: flex;
|
|
1430
|
-
align-items: center;
|
|
1431
|
-
justify-content: space-between;
|
|
1432
|
-
padding: 0 12px;
|
|
1433
|
-
height: 40px;
|
|
1434
|
-
background: #f8f9fa;
|
|
1435
|
-
border-bottom: 1px solid #282828;
|
|
1436
|
-
z-index: 5;
|
|
1437
|
-
}
|
|
1438
|
-
|
|
1439
|
-
.opencode-chat-header-left {
|
|
1440
|
-
display: flex;
|
|
1441
|
-
align-items: center;
|
|
1442
|
-
gap: 4px;
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
.opencode-chat-header-title {
|
|
1446
|
-
font-size: 14px;
|
|
1447
|
-
font-weight: 600;
|
|
1448
|
-
color: #282828;
|
|
1449
|
-
position: absolute;
|
|
1450
|
-
left: 50%;
|
|
1451
|
-
transform: translateX(-50%);
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
.opencode-chat-header-actions {
|
|
1455
|
-
display: flex;
|
|
1456
|
-
gap: 4px;
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
.opencode-header-btn {
|
|
1460
|
-
width: 28px;
|
|
1461
|
-
height: 28px;
|
|
1462
|
-
border-radius: 6px;
|
|
1463
|
-
border: none;
|
|
1464
|
-
background: transparent;
|
|
1465
|
-
color: #6b7280;
|
|
1466
|
-
cursor: pointer;
|
|
1467
|
-
display: flex;
|
|
1468
|
-
align-items: center;
|
|
1469
|
-
justify-content: center;
|
|
1470
|
-
transition: all 0.2s;
|
|
1471
|
-
}
|
|
1472
|
-
|
|
1473
|
-
.opencode-header-btn:hover {
|
|
1474
|
-
background: #282828;
|
|
1475
|
-
color: #282828;
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
.opencode-header-btn.close:hover {
|
|
1479
|
-
background: #ef4444;
|
|
1480
|
-
color: white;
|
|
1481
|
-
}
|
|
1482
|
-
|
|
1483
|
-
.opencode-header-btn.select-btn.active {
|
|
1484
|
-
background: #3b82f6;
|
|
1485
|
-
color: white;
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
|
-
.opencode-dark .opencode-chat-header {
|
|
1489
|
-
background: #121212;
|
|
1490
|
-
border-bottom-color: #282828;
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
.opencode-dark .opencode-chat-header-title {
|
|
1494
|
-
color: #f3f4f6;
|
|
1495
|
-
}
|
|
1496
|
-
|
|
1497
|
-
.opencode-dark .opencode-header-btn {
|
|
1498
|
-
color: #9ca3af;
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
.opencode-dark .opencode-header-btn:hover {
|
|
1502
|
-
background: #282828;
|
|
1503
|
-
color: #f3f4f6;
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
.opencode-dark .opencode-header-btn.close:hover {
|
|
1507
|
-
background: #ef4444;
|
|
1508
|
-
color: white;
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
.opencode-session-list {
|
|
1512
|
-
width: 240px;
|
|
1513
|
-
background: #f8f9fa;
|
|
1514
|
-
border-right: 1px solid #282828;
|
|
1515
|
-
display: flex;
|
|
1516
|
-
flex-direction: column;
|
|
1517
|
-
flex-shrink: 0;
|
|
1518
|
-
transition: width 0.2s ease;
|
|
1519
|
-
}
|
|
1520
|
-
|
|
1521
|
-
.opencode-session-list.collapsed {
|
|
1522
|
-
width: 0;
|
|
1523
|
-
overflow: hidden;
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
|
-
.opencode-session-list.collapsed .opencode-session-list-header,
|
|
1527
|
-
.opencode-session-list.collapsed .opencode-session-list-content {
|
|
1528
|
-
display: none;
|
|
1529
|
-
}
|
|
1530
|
-
|
|
1531
|
-
.opencode-session-list-header {
|
|
1532
|
-
padding: 16px;
|
|
1533
|
-
border-bottom: 1px solid #282828;
|
|
1534
|
-
display: flex;
|
|
1535
|
-
justify-content: space-between;
|
|
1536
|
-
align-items: center;
|
|
1537
|
-
font-weight: 600;
|
|
1538
|
-
font-size: 14px;
|
|
1539
|
-
color: #282828;
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
.opencode-new-session-btn {
|
|
1543
|
-
width: 28px;
|
|
1544
|
-
height: 28px;
|
|
1545
|
-
border-radius: 6px;
|
|
1546
|
-
border: none;
|
|
1547
|
-
background: #3b82f6;
|
|
1548
|
-
color: white;
|
|
1549
|
-
font-size: 18px;
|
|
1550
|
-
cursor: pointer;
|
|
1551
|
-
display: flex;
|
|
1552
|
-
align-items: center;
|
|
1553
|
-
justify-content: center;
|
|
1554
|
-
transition: all 0.2s;
|
|
1555
|
-
}
|
|
1556
|
-
|
|
1557
|
-
.opencode-new-session-btn:hover {
|
|
1558
|
-
background: #2563eb;
|
|
1559
|
-
transform: scale(1.05);
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
|
-
.opencode-session-list-content {
|
|
1563
|
-
flex: 1;
|
|
1564
|
-
overflow-y: auto;
|
|
1565
|
-
padding: 8px;
|
|
1566
|
-
}
|
|
1567
|
-
|
|
1568
|
-
.opencode-session-item {
|
|
1569
|
-
padding: 12px;
|
|
1570
|
-
border-radius: 8px;
|
|
1571
|
-
cursor: pointer;
|
|
1572
|
-
transition: all 0.2s;
|
|
1573
|
-
margin-bottom: 4px;
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
.opencode-session-item:hover {
|
|
1577
|
-
background: #282828;
|
|
1578
|
-
}
|
|
1579
|
-
|
|
1580
|
-
.opencode-session-item.active {
|
|
1581
|
-
background: #3b82f6;
|
|
1582
|
-
color: white;
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
.opencode-session-title {
|
|
1586
|
-
font-size: 14px;
|
|
1587
|
-
font-weight: 500;
|
|
1588
|
-
margin-bottom: 4px;
|
|
1589
|
-
overflow: hidden;
|
|
1590
|
-
text-overflow: ellipsis;
|
|
1591
|
-
white-space: nowrap;
|
|
1592
|
-
}
|
|
1593
|
-
|
|
1594
|
-
.opencode-session-meta {
|
|
1595
|
-
font-size: 12px;
|
|
1596
|
-
opacity: 0.6;
|
|
1597
|
-
}
|
|
1598
|
-
|
|
1599
|
-
.opencode-session-header {
|
|
1600
|
-
display: flex;
|
|
1601
|
-
justify-content: space-between;
|
|
1602
|
-
align-items: center;
|
|
1603
|
-
margin-bottom: 4px;
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
.opencode-session-delete-btn {
|
|
1607
|
-
width: 20px;
|
|
1608
|
-
height: 20px;
|
|
1609
|
-
border-radius: 4px;
|
|
1610
|
-
border: none;
|
|
1611
|
-
background: transparent;
|
|
1612
|
-
color: #6b7280;
|
|
1613
|
-
font-size: 16px;
|
|
1614
|
-
cursor: pointer;
|
|
1615
|
-
display: flex;
|
|
1616
|
-
align-items: center;
|
|
1617
|
-
justify-content: center;
|
|
1618
|
-
transition: all 0.2s;
|
|
1619
|
-
opacity: 0;
|
|
1620
|
-
flex-shrink: 0;
|
|
1621
|
-
}
|
|
1622
|
-
|
|
1623
|
-
.opencode-session-item:hover .opencode-session-delete-btn {
|
|
1624
|
-
opacity: 1;
|
|
1625
|
-
}
|
|
1626
|
-
|
|
1627
|
-
.opencode-session-delete-btn:hover {
|
|
1628
|
-
background: #ef4444;
|
|
1629
|
-
color: white;
|
|
1630
|
-
}
|
|
1631
|
-
|
|
1632
|
-
.opencode-session-item.active .opencode-session-delete-btn {
|
|
1633
|
-
color: rgba(255, 255, 255, 0.7);
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
.opencode-session-item.active .opencode-session-delete-btn:hover {
|
|
1637
|
-
background: rgba(255, 255, 255, 0.2);
|
|
1638
|
-
color: white;
|
|
1639
|
-
}
|
|
1640
|
-
|
|
1641
|
-
.opencode-session-header-skeleton {
|
|
1642
|
-
padding: 16px;
|
|
1643
|
-
border-bottom: 1px solid #282828;
|
|
1644
|
-
display: none;
|
|
1645
|
-
justify-content: space-between;
|
|
1646
|
-
align-items: center;
|
|
1647
|
-
}
|
|
1648
|
-
|
|
1649
|
-
.opencode-session-header-skeleton.visible {
|
|
1650
|
-
display: flex;
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
.opencode-skeleton-header-title {
|
|
1654
|
-
height: 18px;
|
|
1655
|
-
width: 80px;
|
|
1656
|
-
background: #151515;
|
|
1657
|
-
background-size: 200% 100%;
|
|
1658
|
-
animation: skeleton-loading 1.5s ease-in-out infinite;
|
|
1659
|
-
border-radius: 4px;
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
.opencode-skeleton-header-btn {
|
|
1663
|
-
width: 28px;
|
|
1664
|
-
height: 28px;
|
|
1665
|
-
background: #151515;
|
|
1666
|
-
background-size: 200% 100%;
|
|
1667
|
-
animation: skeleton-loading 1.5s ease-in-out infinite;
|
|
1668
|
-
border-radius: 6px;
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
.opencode-session-skeleton {
|
|
1672
|
-
flex: 1;
|
|
1673
|
-
overflow-y: auto;
|
|
1674
|
-
padding: 8px;
|
|
1675
|
-
display: none;
|
|
1676
|
-
}
|
|
1677
|
-
|
|
1678
|
-
.opencode-session-skeleton.visible {
|
|
1679
|
-
display: block;
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
.opencode-skeleton-item {
|
|
1683
|
-
padding: 12px;
|
|
1684
|
-
border-radius: 8px;
|
|
1685
|
-
margin-bottom: 4px;
|
|
1686
|
-
background: white;
|
|
1687
|
-
}
|
|
1688
|
-
|
|
1689
|
-
.opencode-skeleton-title {
|
|
1690
|
-
height: 16px;
|
|
1691
|
-
background: #151515;
|
|
1692
|
-
background-size: 200% 100%;
|
|
1693
|
-
animation: skeleton-loading 1.5s ease-in-out infinite;
|
|
1694
|
-
border-radius: 4px;
|
|
1695
|
-
margin-bottom: 8px;
|
|
1696
|
-
width: 70%;
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
.opencode-skeleton-meta {
|
|
1700
|
-
height: 12px;
|
|
1701
|
-
background: #151515;
|
|
1702
|
-
background-size: 200% 100%;
|
|
1703
|
-
animation: skeleton-loading 1.5s ease-in-out infinite;
|
|
1704
|
-
border-radius: 4px;
|
|
1705
|
-
width: 50%;
|
|
1706
|
-
}
|
|
1707
|
-
|
|
1708
|
-
@keyframes skeleton-loading {
|
|
1709
|
-
0% {
|
|
1710
|
-
background-position: 200% 0;
|
|
1711
|
-
}
|
|
1712
|
-
100% {
|
|
1713
|
-
background-position: -200% 0;
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
|
|
1717
|
-
.opencode-dark .opencode-skeleton-item {
|
|
1718
|
-
background: #1e1e1e;
|
|
1719
|
-
}
|
|
1720
|
-
|
|
1721
|
-
.opencode-dark .opencode-skeleton-title,
|
|
1722
|
-
.opencode-dark .opencode-skeleton-meta {
|
|
1723
|
-
background: linear-gradient(90deg, #282828 25%, #4b5563 50%, #282828 75%);
|
|
1724
|
-
background-size: 200% 100%;
|
|
1725
|
-
}
|
|
1726
|
-
|
|
1727
|
-
.opencode-dark .opencode-session-header-skeleton {
|
|
1728
|
-
border-bottom-color: #282828;
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
.opencode-dark .opencode-skeleton-header-title,
|
|
1732
|
-
.opencode-dark .opencode-skeleton-header-btn {
|
|
1733
|
-
background: linear-gradient(90deg, #282828 25%, #4b5563 50%, #282828 75%);
|
|
1734
|
-
background-size: 200% 100%;
|
|
1735
|
-
}
|
|
1736
|
-
|
|
1737
|
-
.opencode-iframe-container {
|
|
1738
|
-
flex: 1;
|
|
1739
|
-
position: relative;
|
|
1740
|
-
overflow: hidden;
|
|
1741
|
-
display: flex;
|
|
1742
|
-
flex-direction: column;
|
|
1743
|
-
margin-top: -42px;
|
|
1744
|
-
}
|
|
1745
|
-
|
|
1746
|
-
.opencode-loading-overlay {
|
|
1747
|
-
position: absolute;
|
|
1748
|
-
top: 0;
|
|
1749
|
-
left: 0;
|
|
1750
|
-
right: 0;
|
|
1751
|
-
bottom: 0;
|
|
1752
|
-
background: rgba(255, 255, 255, 0.9);
|
|
1753
|
-
display: none;
|
|
1754
|
-
flex-direction: column;
|
|
1755
|
-
align-items: center;
|
|
1756
|
-
justify-content: center;
|
|
1757
|
-
z-index: 10;
|
|
1758
|
-
transition: opacity 0.3s ease;
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
.opencode-loading-overlay.visible {
|
|
1762
|
-
display: flex;
|
|
1763
|
-
}
|
|
1764
|
-
|
|
1765
|
-
.opencode-loading-spinner {
|
|
1766
|
-
width: 40px;
|
|
1767
|
-
height: 40px;
|
|
1768
|
-
border: 3px solid #282828;
|
|
1769
|
-
border-top-color: #3b82f6;
|
|
1770
|
-
border-radius: 50%;
|
|
1771
|
-
animation: spin 0.8s linear infinite;
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
@keyframes spin {
|
|
1775
|
-
to { transform: rotate(360deg); }
|
|
1776
|
-
}
|
|
1777
|
-
|
|
1778
|
-
.opencode-loading-text {
|
|
1779
|
-
margin-top: 12px;
|
|
1780
|
-
font-size: 14px;
|
|
1781
|
-
color: #6b7280;
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
.opencode-empty-state-overlay {
|
|
1785
|
-
position: absolute;
|
|
1786
|
-
top: 0;
|
|
1787
|
-
left: 0;
|
|
1788
|
-
right: 0;
|
|
1789
|
-
bottom: 0;
|
|
1790
|
-
background: #f8f9fa;
|
|
1791
|
-
display: none;
|
|
1792
|
-
flex-direction: column;
|
|
1793
|
-
align-items: center;
|
|
1794
|
-
justify-content: center;
|
|
1795
|
-
z-index: 5;
|
|
1796
|
-
transition: opacity 0.3s ease;
|
|
1797
|
-
margin-top: 42px;
|
|
1798
|
-
}
|
|
1799
|
-
|
|
1800
|
-
.opencode-empty-state-overlay.visible {
|
|
1801
|
-
display: flex;
|
|
1802
|
-
}
|
|
1803
|
-
|
|
1804
|
-
.opencode-empty-state-icon {
|
|
1805
|
-
color: #9ca3af;
|
|
1806
|
-
margin-bottom: 16px;
|
|
1807
|
-
}
|
|
1808
|
-
|
|
1809
|
-
.opencode-empty-state-text {
|
|
1810
|
-
color: #4b5563;
|
|
1811
|
-
font-size: 16px;
|
|
1812
|
-
font-weight: 500;
|
|
1813
|
-
margin-bottom: 24px;
|
|
1814
|
-
}
|
|
1815
|
-
|
|
1816
|
-
.opencode-empty-state-btn {
|
|
1817
|
-
padding: 10px 24px;
|
|
1818
|
-
border-radius: 8px;
|
|
1819
|
-
border: none;
|
|
1820
|
-
background: #3b82f6;
|
|
1821
|
-
color: white;
|
|
1822
|
-
font-size: 14px;
|
|
1823
|
-
font-weight: 500;
|
|
1824
|
-
cursor: pointer;
|
|
1825
|
-
transition: all 0.2s;
|
|
1826
|
-
box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
|
-
.opencode-empty-state-btn:hover {
|
|
1830
|
-
background: #2563eb;
|
|
1831
|
-
transform: translateY(-1px);
|
|
1832
|
-
box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
.opencode-empty-state-btn:active {
|
|
1836
|
-
transform: translateY(0);
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
.opencode-iframe {
|
|
1840
|
-
width: 100%;
|
|
1841
|
-
height: 100%;
|
|
1842
|
-
border: none;
|
|
1843
|
-
}
|
|
1844
|
-
|
|
1845
|
-
.opencode-dark .opencode-chat {
|
|
1846
|
-
background: #1a1a1a;
|
|
1847
|
-
}
|
|
1848
|
-
|
|
1849
|
-
.opencode-dark .opencode-session-list {
|
|
1850
|
-
background: #121212;
|
|
1851
|
-
border-right-color: #282828;
|
|
1852
|
-
}
|
|
1853
|
-
|
|
1854
|
-
.opencode-dark .opencode-session-toggle {
|
|
1855
|
-
color: #9ca3af;
|
|
1856
|
-
border-bottom-color: #282828;
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
.opencode-dark .opencode-session-toggle:hover {
|
|
1860
|
-
background: #282828;
|
|
1861
|
-
color: #f3f4f6;
|
|
1862
|
-
}
|
|
1863
|
-
|
|
1864
|
-
.opencode-dark .opencode-session-list-header {
|
|
1865
|
-
border-bottom-color: #282828;
|
|
1866
|
-
color: #f3f4f6;
|
|
1867
|
-
}
|
|
1868
|
-
|
|
1869
|
-
.opencode-dark .opencode-session-item:hover {
|
|
1870
|
-
background: #282828;
|
|
1871
|
-
}
|
|
1872
|
-
|
|
1873
|
-
.opencode-dark .opencode-session-item {
|
|
1874
|
-
color: #d1d5db;
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
.opencode-dark .opencode-session-item.active {
|
|
1878
|
-
background: #3b82f6;
|
|
1879
|
-
color: white;
|
|
1880
|
-
}
|
|
1881
|
-
|
|
1882
|
-
.opencode-dark .opencode-loading-overlay {
|
|
1883
|
-
background: rgba(26, 26, 26, 0.9);
|
|
1884
|
-
}
|
|
1885
|
-
|
|
1886
|
-
.opencode-dark .opencode-loading-spinner {
|
|
1887
|
-
border-color: #282828;
|
|
1888
|
-
border-top-color: #3b82f6;
|
|
1889
|
-
}
|
|
1890
|
-
|
|
1891
|
-
.opencode-dark .opencode-loading-text {
|
|
1892
|
-
color: #9ca3af;
|
|
1893
|
-
}
|
|
1894
|
-
|
|
1895
|
-
.opencode-dark .opencode-empty-state-overlay {
|
|
1896
|
-
background: #1a1a1a;
|
|
1897
|
-
}
|
|
1898
|
-
|
|
1899
|
-
.opencode-dark .opencode-empty-state-icon {
|
|
1900
|
-
color: #4b5563;
|
|
1901
|
-
}
|
|
1902
|
-
|
|
1903
|
-
.opencode-dark .opencode-empty-state-text {
|
|
1904
|
-
color: #d1d5db;
|
|
1905
|
-
}
|
|
1906
|
-
|
|
1907
|
-
.opencode-right-toolbar {
|
|
1908
|
-
width: 140px;
|
|
1909
|
-
background: #f8f9fa;
|
|
1910
|
-
border-left: 1px solid #282828;
|
|
1911
|
-
display: flex;
|
|
1912
|
-
flex-direction: column;
|
|
1913
|
-
flex-shrink: 0;
|
|
1914
|
-
transition: width 0.2s ease;
|
|
1915
|
-
overflow: hidden;
|
|
1916
|
-
}
|
|
1917
|
-
|
|
1918
|
-
.opencode-right-toolbar.collapsed {
|
|
1919
|
-
width: 0;
|
|
1920
|
-
overflow: hidden;
|
|
1921
|
-
}
|
|
1922
|
-
|
|
1923
|
-
.opencode-right-toolbar.collapsed .opencode-selected-nodes-header,
|
|
1924
|
-
.opencode-right-toolbar.collapsed .opencode-selected-nodes,
|
|
1925
|
-
.opencode-right-toolbar.collapsed .opencode-clear-all-btn {
|
|
1926
|
-
display: none;
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1929
|
-
.opencode-selected-nodes-header {
|
|
1930
|
-
padding: 12px 8px 8px;
|
|
1931
|
-
border-bottom: 1px solid #282828;
|
|
1932
|
-
}
|
|
1933
|
-
|
|
1934
|
-
.opencode-selected-nodes-title {
|
|
1935
|
-
font-size: 14px;
|
|
1936
|
-
font-weight: 600;
|
|
1937
|
-
color: #282828;
|
|
1938
|
-
margin-bottom: 4px;
|
|
1939
|
-
}
|
|
1940
|
-
|
|
1941
|
-
.opencode-selected-nodes-desc {
|
|
1942
|
-
font-size: 11px;
|
|
1943
|
-
color: #9ca3af;
|
|
1944
|
-
line-height: 1.4;
|
|
1945
|
-
}
|
|
1946
|
-
|
|
1947
|
-
.opencode-selected-nodes {
|
|
1948
|
-
flex: 1;
|
|
1949
|
-
display: flex;
|
|
1950
|
-
flex-direction: column;
|
|
1951
|
-
padding: 8px;
|
|
1952
|
-
gap: 6px;
|
|
1953
|
-
overflow-y: auto;
|
|
1954
|
-
overflow-x: hidden;
|
|
1955
|
-
}
|
|
1956
|
-
|
|
1957
|
-
.opencode-selected-nodes:empty::before {
|
|
1958
|
-
content: '暂无选中元素';
|
|
1959
|
-
color: #9ca3af;
|
|
1960
|
-
font-size: 12px;
|
|
1961
|
-
text-align: center;
|
|
1962
|
-
padding: 20px 10px;
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
.opencode-selected-node {
|
|
1966
|
-
display: flex;
|
|
1967
|
-
align-items: center;
|
|
1968
|
-
gap: 8px;
|
|
1969
|
-
padding: 8px 10px;
|
|
1970
|
-
background: white;
|
|
1971
|
-
border: 1px solid #282828;
|
|
1972
|
-
border-radius: 6px;
|
|
1973
|
-
font-size: 12px;
|
|
1974
|
-
transition: all 0.2s;
|
|
1975
|
-
}
|
|
1976
|
-
|
|
1977
|
-
.opencode-selected-node:hover {
|
|
1978
|
-
border-color: #3b82f6;
|
|
1979
|
-
box-shadow: 0 2px 4px rgba(59, 130, 246, 0.1);
|
|
1980
|
-
}
|
|
1981
|
-
|
|
1982
|
-
.opencode-node-content {
|
|
1983
|
-
flex: 1;
|
|
1984
|
-
min-width: 0;
|
|
1985
|
-
display: flex;
|
|
1986
|
-
flex-direction: column;
|
|
1987
|
-
gap: 2px;
|
|
1988
|
-
}
|
|
1989
|
-
|
|
1990
|
-
.opencode-node-text {
|
|
1991
|
-
color: #282828;
|
|
1992
|
-
font-weight: 500;
|
|
1993
|
-
overflow: hidden;
|
|
1994
|
-
text-overflow: ellipsis;
|
|
1995
|
-
white-space: nowrap;
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
|
-
.opencode-node-file {
|
|
1999
|
-
color: #9ca3af;
|
|
2000
|
-
font-size: 11px;
|
|
2001
|
-
overflow: hidden;
|
|
2002
|
-
text-overflow: ellipsis;
|
|
2003
|
-
white-space: nowrap;
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
|
-
.opencode-node-remove {
|
|
2007
|
-
width: 18px;
|
|
2008
|
-
height: 18px;
|
|
2009
|
-
border-radius: 4px;
|
|
2010
|
-
border: none;
|
|
2011
|
-
background: transparent;
|
|
2012
|
-
color: #9ca3af;
|
|
2013
|
-
cursor: pointer;
|
|
2014
|
-
display: flex;
|
|
2015
|
-
align-items: center;
|
|
2016
|
-
justify-content: center;
|
|
2017
|
-
font-size: 14px;
|
|
2018
|
-
transition: all 0.2s;
|
|
2019
|
-
flex-shrink: 0;
|
|
2020
|
-
}
|
|
2021
|
-
|
|
2022
|
-
.opencode-node-remove:hover {
|
|
2023
|
-
background: #ef4444;
|
|
2024
|
-
color: white;
|
|
2025
|
-
}
|
|
2026
|
-
|
|
2027
|
-
.opencode-clear-all-btn {
|
|
2028
|
-
width: calc(100% - 16px);
|
|
2029
|
-
margin: 8px;
|
|
2030
|
-
padding: 8px 12px;
|
|
2031
|
-
border-radius: 6px;
|
|
2032
|
-
border: none;
|
|
2033
|
-
background: #ef4444;
|
|
2034
|
-
color: white;
|
|
2035
|
-
font-size: 12px;
|
|
2036
|
-
font-weight: 500;
|
|
2037
|
-
cursor: pointer;
|
|
2038
|
-
display: flex;
|
|
2039
|
-
align-items: center;
|
|
2040
|
-
justify-content: center;
|
|
2041
|
-
gap: 4px;
|
|
2042
|
-
transition: all 0.2s;
|
|
2043
|
-
}
|
|
2044
|
-
|
|
2045
|
-
.opencode-clear-all-btn:hover {
|
|
2046
|
-
background: #dc2626;
|
|
2047
|
-
transform: scale(1.02);
|
|
2048
|
-
}
|
|
2049
|
-
|
|
2050
|
-
.opencode-dark .opencode-right-toolbar {
|
|
2051
|
-
background: #121212;
|
|
2052
|
-
border-left-color: #282828;
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
|
-
.opencode-dark .opencode-selected-nodes-header {
|
|
2056
|
-
border-bottom-color: #282828;
|
|
2057
|
-
}
|
|
2058
|
-
|
|
2059
|
-
.opencode-dark .opencode-selected-nodes-title {
|
|
2060
|
-
color: #f3f4f6;
|
|
2061
|
-
}
|
|
2062
|
-
|
|
2063
|
-
.opencode-dark .opencode-selected-nodes-desc {
|
|
2064
|
-
color: #6b7280;
|
|
2065
|
-
}
|
|
2066
|
-
|
|
2067
|
-
.opencode-dark .opencode-selected-nodes:empty::before {
|
|
2068
|
-
color: #6b7280;
|
|
2069
|
-
}
|
|
2070
|
-
|
|
2071
|
-
.opencode-dark .opencode-selected-node {
|
|
2072
|
-
background: #1e1e1e;
|
|
2073
|
-
border-color: #282828;
|
|
2074
|
-
}
|
|
2075
|
-
|
|
2076
|
-
.opencode-dark .opencode-selected-node:hover {
|
|
2077
|
-
border-color: #3b82f6;
|
|
2078
|
-
}
|
|
2079
|
-
|
|
2080
|
-
.opencode-dark .opencode-node-text {
|
|
2081
|
-
color: #f3f4f6;
|
|
2082
|
-
}
|
|
2083
|
-
|
|
2084
|
-
.opencode-dark .opencode-node-file {
|
|
2085
|
-
color: #6b7280;
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
.opencode-dark .opencode-node-remove {
|
|
2089
|
-
color: #6b7280;
|
|
2090
|
-
}
|
|
2091
|
-
|
|
2092
|
-
.opencode-dark .opencode-node-remove:hover {
|
|
2093
|
-
background: #ef4444;
|
|
2094
|
-
color: white;
|
|
2095
|
-
}
|
|
2096
|
-
|
|
2097
|
-
.opencode-dark .opencode-clear-all-btn {
|
|
2098
|
-
background: #dc2626;
|
|
2099
|
-
color: white;
|
|
2100
|
-
}
|
|
2101
|
-
|
|
2102
|
-
.opencode-dark .opencode-clear-all-btn:hover {
|
|
2103
|
-
background: #b91c1c;
|
|
2104
|
-
}
|
|
2105
|
-
|
|
2106
|
-
.opencode-dark .opencode-button {
|
|
2107
|
-
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
2108
|
-
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.5);
|
|
2109
|
-
}
|
|
2110
|
-
|
|
2111
|
-
.opencode-notification {
|
|
2112
|
-
position: absolute;
|
|
2113
|
-
top: 20px;
|
|
2114
|
-
left: 50%;
|
|
2115
|
-
transform: translateX(-50%);
|
|
2116
|
-
padding: 12px 20px;
|
|
2117
|
-
background: #10b981;
|
|
2118
|
-
color: white;
|
|
2119
|
-
border-radius: 8px;
|
|
2120
|
-
font-size: 14px;
|
|
2121
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
2122
|
-
animation: slideDown 0.3s ease;
|
|
2123
|
-
z-index: 10;
|
|
2124
|
-
}
|
|
2125
|
-
|
|
2126
|
-
.opencode-dialog-overlay {
|
|
2127
|
-
position: fixed;
|
|
2128
|
-
top: 0;
|
|
2129
|
-
left: 0;
|
|
2130
|
-
right: 0;
|
|
2131
|
-
bottom: 0;
|
|
2132
|
-
background: rgba(0, 0, 0, 0.5);
|
|
2133
|
-
display: flex;
|
|
2134
|
-
align-items: center;
|
|
2135
|
-
justify-content: center;
|
|
2136
|
-
z-index: 9999999;
|
|
2137
|
-
animation: fadeIn 0.2s ease;
|
|
2138
|
-
}
|
|
2139
|
-
|
|
2140
|
-
@keyframes fadeIn {
|
|
2141
|
-
from { opacity: 0; }
|
|
2142
|
-
to { opacity: 1; }
|
|
2143
|
-
}
|
|
2144
|
-
|
|
2145
|
-
.opencode-dialog {
|
|
2146
|
-
background: white;
|
|
2147
|
-
border-radius: 12px;
|
|
2148
|
-
padding: 24px;
|
|
2149
|
-
min-width: 320px;
|
|
2150
|
-
max-width: 400px;
|
|
2151
|
-
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
|
2152
|
-
animation: scaleIn 0.2s ease;
|
|
2153
|
-
}
|
|
2154
|
-
|
|
2155
|
-
@keyframes scaleIn {
|
|
2156
|
-
from { transform: scale(0.9); opacity: 0; }
|
|
2157
|
-
to { transform: scale(1); opacity: 1; }
|
|
2158
|
-
}
|
|
2159
|
-
|
|
2160
|
-
.opencode-dialog-content {
|
|
2161
|
-
margin-bottom: 20px;
|
|
2162
|
-
}
|
|
2163
|
-
|
|
2164
|
-
.opencode-dialog-message {
|
|
2165
|
-
font-size: 15px;
|
|
2166
|
-
color: #282828;
|
|
2167
|
-
line-height: 1.5;
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
.opencode-dialog-actions {
|
|
2171
|
-
display: flex;
|
|
2172
|
-
gap: 12px;
|
|
2173
|
-
justify-content: flex-end;
|
|
2174
|
-
}
|
|
2175
|
-
|
|
2176
|
-
.opencode-dialog-btn {
|
|
2177
|
-
padding: 10px 20px;
|
|
2178
|
-
border-radius: 8px;
|
|
2179
|
-
border: none;
|
|
2180
|
-
font-size: 14px;
|
|
2181
|
-
font-weight: 500;
|
|
2182
|
-
cursor: pointer;
|
|
2183
|
-
transition: all 0.2s;
|
|
2184
|
-
}
|
|
2185
|
-
|
|
2186
|
-
.opencode-dialog-btn.cancel {
|
|
2187
|
-
background: #f3f4f6;
|
|
2188
|
-
color: #282828;
|
|
2189
|
-
}
|
|
2190
|
-
|
|
2191
|
-
.opencode-dialog-btn.cancel:hover {
|
|
2192
|
-
background: #282828;
|
|
2193
|
-
color: white;
|
|
2194
|
-
}
|
|
2195
|
-
|
|
2196
|
-
.opencode-dialog-btn.confirm {
|
|
2197
|
-
background: #ef4444;
|
|
2198
|
-
color: white;
|
|
2199
|
-
}
|
|
2200
|
-
|
|
2201
|
-
.opencode-dialog-btn.confirm:hover {
|
|
2202
|
-
background: #dc2626;
|
|
2203
|
-
}
|
|
2204
|
-
|
|
2205
|
-
.opencode-dark .opencode-dialog {
|
|
2206
|
-
background: #1e1e1e;
|
|
2207
|
-
}
|
|
2208
|
-
|
|
2209
|
-
.opencode-dark .opencode-dialog-message {
|
|
2210
|
-
color: #f3f4f6;
|
|
2211
|
-
}
|
|
2212
|
-
|
|
2213
|
-
.opencode-dark .opencode-dialog-btn.cancel {
|
|
2214
|
-
background: #282828;
|
|
2215
|
-
color: #f3f4f6;
|
|
2216
|
-
}
|
|
2217
|
-
|
|
2218
|
-
.opencode-dark .opencode-dialog-btn.cancel:hover {
|
|
2219
|
-
background: #4b5563;
|
|
2220
|
-
}
|
|
2221
|
-
|
|
2222
|
-
@keyframes slideDown {
|
|
2223
|
-
from {
|
|
2224
|
-
transform: translateX(-50%) translateY(-100%);
|
|
2225
|
-
opacity: 0;
|
|
2226
|
-
}
|
|
2227
|
-
to {
|
|
2228
|
-
transform: translateX(-50%) translateY(0);
|
|
2229
|
-
opacity: 1;
|
|
2230
|
-
}
|
|
2231
|
-
}
|
|
2232
|
-
|
|
2233
|
-
.opencode-select-mode-hint {
|
|
2234
|
-
position: fixed;
|
|
2235
|
-
top: 20px;
|
|
2236
|
-
left: 50%;
|
|
2237
|
-
transform: translateX(-50%);
|
|
2238
|
-
padding: 10px 16px;
|
|
2239
|
-
background: #ef4444;
|
|
2240
|
-
color: white;
|
|
2241
|
-
border-radius: 8px;
|
|
2242
|
-
font-size: 13px;
|
|
2243
|
-
box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
|
|
2244
|
-
z-index: 9999999;
|
|
2245
|
-
display: none;
|
|
2246
|
-
align-items: center;
|
|
2247
|
-
gap: 12px;
|
|
2248
|
-
}
|
|
2249
|
-
|
|
2250
|
-
.opencode-select-mode-hint.visible {
|
|
2251
|
-
display: flex;
|
|
2252
|
-
animation: slideDown 0.3s ease;
|
|
2253
|
-
}
|
|
2254
|
-
|
|
2255
|
-
.opencode-hint-shortcut {
|
|
2256
|
-
padding: 2px 6px;
|
|
2257
|
-
background: rgba(255, 255, 255, 0.2);
|
|
2258
|
-
border-radius: 4px;
|
|
2259
|
-
font-size: 12px;
|
|
2260
|
-
}
|
|
2261
|
-
|
|
2262
|
-
.opencode-element-highlight {
|
|
2263
|
-
position: fixed;
|
|
2264
|
-
pointer-events: none;
|
|
2265
|
-
border: 2px solid #3b82f6;
|
|
2266
|
-
background: rgba(59, 130, 246, 0.1);
|
|
2267
|
-
z-index: 9999998;
|
|
2268
|
-
display: none;
|
|
2269
|
-
transition: all 0.1s ease;
|
|
2270
|
-
border-radius: 4px;
|
|
2271
|
-
}
|
|
2272
|
-
|
|
2273
|
-
#vue-inspector-container {
|
|
2274
|
-
display: none !important;
|
|
2275
|
-
}
|
|
2276
|
-
|
|
2277
|
-
.opencode-element-tooltip {
|
|
2278
|
-
position: fixed;
|
|
2279
|
-
background: #1e1e1e;
|
|
2280
|
-
color: white;
|
|
2281
|
-
padding: 8px 12px;
|
|
2282
|
-
border-radius: 6px;
|
|
2283
|
-
font-size: 12px;
|
|
2284
|
-
z-index: 9999998;
|
|
2285
|
-
display: none;
|
|
2286
|
-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
|
|
2287
|
-
max-width: 300px;
|
|
2288
|
-
pointer-events: none;
|
|
2289
|
-
}
|
|
2290
|
-
|
|
2291
|
-
.opencode-tooltip-tag {
|
|
2292
|
-
font-weight: 500;
|
|
2293
|
-
margin-bottom: 4px;
|
|
2294
|
-
word-break: break-all;
|
|
2295
|
-
}
|
|
2296
|
-
|
|
2297
|
-
.opencode-tooltip-file {
|
|
2298
|
-
font-size: 11px;
|
|
2299
|
-
color: #9ca3af;
|
|
2300
|
-
word-break: break-all;
|
|
2301
|
-
}
|
|
2302
|
-
|
|
2303
|
-
.opencode-selected-bubbles {
|
|
2304
|
-
position: absolute;
|
|
2305
|
-
bottom: 44px;
|
|
2306
|
-
right: 0;
|
|
2307
|
-
display: none;
|
|
2308
|
-
flex-direction: column;
|
|
2309
|
-
gap: 6px;
|
|
2310
|
-
max-width: 220px;
|
|
2311
|
-
max-height: 300px;
|
|
2312
|
-
overflow-y: auto;
|
|
2313
|
-
}
|
|
2314
|
-
|
|
2315
|
-
.opencode-selected-bubbles.visible {
|
|
2316
|
-
display: flex;
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
.opencode-selected-bubble {
|
|
2320
|
-
display: flex;
|
|
2321
|
-
flex-direction: column;
|
|
2322
|
-
gap: 2px;
|
|
2323
|
-
padding: 8px 10px;
|
|
2324
|
-
background: white;
|
|
2325
|
-
border: 1px solid #282828;
|
|
2326
|
-
border-radius: 8px;
|
|
2327
|
-
font-size: 12px;
|
|
2328
|
-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
2329
|
-
position: relative;
|
|
2330
|
-
}
|
|
2331
|
-
|
|
2332
|
-
.opencode-bubble-text {
|
|
2333
|
-
color: #282828;
|
|
2334
|
-
font-weight: 500;
|
|
2335
|
-
overflow: hidden;
|
|
2336
|
-
text-overflow: ellipsis;
|
|
2337
|
-
white-space: nowrap;
|
|
2338
|
-
}
|
|
2339
|
-
|
|
2340
|
-
.opencode-bubble-file {
|
|
2341
|
-
color: #9ca3af;
|
|
2342
|
-
font-size: 11px;
|
|
2343
|
-
overflow: hidden;
|
|
2344
|
-
text-overflow: ellipsis;
|
|
2345
|
-
white-space: nowrap;
|
|
2346
|
-
}
|
|
2347
|
-
|
|
2348
|
-
.opencode-bubble-remove {
|
|
2349
|
-
position: absolute;
|
|
2350
|
-
top: 4px;
|
|
2351
|
-
right: 4px;
|
|
2352
|
-
width: 16px;
|
|
2353
|
-
height: 16px;
|
|
2354
|
-
border-radius: 50%;
|
|
2355
|
-
border: none;
|
|
2356
|
-
background: transparent;
|
|
2357
|
-
color: #9ca3af;
|
|
2358
|
-
cursor: pointer;
|
|
2359
|
-
display: flex;
|
|
2360
|
-
align-items: center;
|
|
2361
|
-
justify-content: center;
|
|
2362
|
-
font-size: 12px;
|
|
2363
|
-
transition: all 0.2s;
|
|
2364
|
-
}
|
|
2365
|
-
|
|
2366
|
-
.opencode-bubble-remove:hover {
|
|
2367
|
-
background: #ef4444;
|
|
2368
|
-
color: white;
|
|
2369
|
-
}
|
|
2370
|
-
|
|
2371
|
-
.opencode-bubble-empty {
|
|
2372
|
-
padding: 8px 12px;
|
|
2373
|
-
background: white;
|
|
2374
|
-
border: 1px dashed #d1d5db;
|
|
2375
|
-
border-radius: 8px;
|
|
2376
|
-
color: #9ca3af;
|
|
2377
|
-
font-size: 12px;
|
|
2378
|
-
text-align: center;
|
|
2379
|
-
}
|
|
2380
|
-
|
|
2381
|
-
.opencode-dark .opencode-selected-bubble {
|
|
2382
|
-
background: #1e1e1e;
|
|
2383
|
-
border-color: #282828;
|
|
2384
|
-
}
|
|
2385
|
-
|
|
2386
|
-
.opencode-dark .opencode-bubble-text {
|
|
2387
|
-
color: #f3f4f6;
|
|
2388
|
-
}
|
|
2389
|
-
|
|
2390
|
-
.opencode-dark .opencode-bubble-file {
|
|
2391
|
-
color: #6b7280;
|
|
2392
|
-
}
|
|
2393
|
-
|
|
2394
|
-
.opencode-dark .opencode-bubble-remove {
|
|
2395
|
-
color: #6b7280;
|
|
2396
|
-
}
|
|
2397
|
-
|
|
2398
|
-
.opencode-dark .opencode-bubble-empty {
|
|
2399
|
-
background: #1e1e1e;
|
|
2400
|
-
border-color: #282828;
|
|
2401
|
-
color: #6b7280;
|
|
2402
|
-
}
|
|
2403
|
-
|
|
2404
|
-
.opencode-element-highlight-temp {
|
|
2405
|
-
position: absolute;
|
|
2406
|
-
pointer-events: none;
|
|
2407
|
-
border: 3px solid #3b82f6;
|
|
2408
|
-
background: rgba(59, 130, 246, 0.1);
|
|
2409
|
-
z-index: 9999;
|
|
2410
|
-
border-radius: 4px;
|
|
2411
|
-
animation: highlight-pulse 2s ease-out forwards;
|
|
2412
|
-
}
|
|
2413
|
-
|
|
2414
|
-
@keyframes highlight-pulse {
|
|
2415
|
-
0% {
|
|
2416
|
-
opacity: 1;
|
|
2417
|
-
transform: scale(1);
|
|
2418
|
-
}
|
|
2419
|
-
50% {
|
|
2420
|
-
opacity: 0.8;
|
|
2421
|
-
transform: scale(1.02);
|
|
2422
|
-
}
|
|
2423
|
-
100% {
|
|
2424
|
-
opacity: 0;
|
|
2425
|
-
transform: scale(1);
|
|
2426
|
-
}
|
|
2427
|
-
}
|
|
2428
|
-
|
|
2429
|
-
@media (max-width: 768px) {
|
|
2430
|
-
.opencode-chat {
|
|
2431
|
-
width: calc(100vw - 40px);
|
|
2432
|
-
height: calc(100vh - 100px);
|
|
2433
|
-
}
|
|
2434
|
-
}
|
|
2435
|
-
`;
|
|
2436
|
-
}
|
|
2437
|
-
/**
|
|
2438
|
-
* 自动初始化挂件
|
|
2439
|
-
*/
|
|
2440
|
-
function autoInit() {
|
|
2441
|
-
const script = document.currentScript ||
|
|
2442
|
-
document.querySelector("script[data-opencode-config]");
|
|
2443
|
-
if (script) {
|
|
2444
|
-
const configBase64 = script.getAttribute("data-opencode-config");
|
|
2445
|
-
if (configBase64) {
|
|
2446
|
-
try {
|
|
2447
|
-
const config = JSON.parse(atob(configBase64));
|
|
2448
|
-
if (document.readyState === "loading") {
|
|
2449
|
-
document.addEventListener("DOMContentLoaded", function () {
|
|
2450
|
-
initOpenCodeWidget(config);
|
|
2451
|
-
});
|
|
2452
|
-
}
|
|
2453
|
-
else {
|
|
2454
|
-
initOpenCodeWidget(config);
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
catch (e) {
|
|
2458
|
-
console.error("[OpenCode Widget] Failed to parse config:", e);
|
|
2459
|
-
}
|
|
2460
|
-
}
|
|
2461
|
-
}
|
|
2462
|
-
}
|
|
2463
|
-
// 导出全局初始化函数
|
|
2464
|
-
window.initOpenCodeWidget = initOpenCodeWidget;
|
|
2465
|
-
// 自动初始化
|
|
2466
|
-
autoInit();
|
|
2467
|
-
})();
|
|
2468
|
-
//# sourceMappingURL=client.js.map
|