-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweb-client.html
More file actions
884 lines (758 loc) · 28.2 KB
/
web-client.html
File metadata and controls
884 lines (758 loc) · 28.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MobileAgentLivelink - Web客户端</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0,0,0,0.3);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 30px;
text-align: center;
}
.header h1 {
font-size: 28px;
margin-bottom: 10px;
}
.header p {
opacity: 0.9;
font-size: 14px;
}
.status {
display: inline-block;
padding: 8px 16px;
border-radius: 20px;
background: rgba(255,255,255,0.2);
margin-top: 15px;
font-size: 14px;
}
.status.connected {
background: rgba(76, 175, 80, 0.9);
}
.status.disconnected {
background: rgba(244, 67, 54, 0.9);
}
.content {
padding: 30px;
}
.section {
margin-bottom: 30px;
}
.section h2 {
color: #333;
margin-bottom: 15px;
font-size: 20px;
border-bottom: 2px solid #667eea;
padding-bottom: 10px;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
color: #555;
font-weight: 500;
}
.form-group input {
width: 100%;
padding: 12px;
border: 2px solid #ddd;
border-radius: 8px;
font-size: 16px;
transition: border-color 0.3s;
}
.form-group input:focus {
outline: none;
border-color: #667eea;
}
.btn {
width: 100%;
padding: 12px 24px;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
}
.btn-primary {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}
.btn-primary:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.pc-list {
display: grid;
gap: 10px;
}
.pc-item {
padding: 15px;
border: 2px solid #eee;
border-radius: 10px;
cursor: pointer;
transition: all 0.3s;
}
.pc-item:hover {
border-color: #667eea;
background: #f8f9ff;
}
.pc-item.selected {
border-color: #667eea;
background: #f0f4ff;
}
.pc-item h3 {
color: #333;
margin-bottom: 5px;
}
.pc-item p {
color: #888;
font-size: 13px;
}
.chat-container {
border: 2px solid #eee;
border-radius: 10px;
height: 400px;
display: flex;
flex-direction: column;
overflow: hidden;
}
.chat-messages {
flex: 1;
overflow-y: auto;
padding: 20px;
background: #f8f9ff;
}
.message {
margin-bottom: 15px;
padding: 12px 16px;
border-radius: 10px;
max-width: 80%;
animation: fadeIn 0.3s;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.message.sent {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
margin-left: auto;
}
.message.received {
background: white;
color: #333;
border: 1px solid #ddd;
}
.message .time {
font-size: 11px;
opacity: 0.7;
margin-top: 5px;
}
.message-input {
display: flex;
padding: 15px;
background: white;
border-top: 1px solid #eee;
gap: 10px;
}
.message-input input {
flex: 1;
padding: 12px;
border: 2px solid #ddd;
border-radius: 8px;
font-size: 15px;
transition: border-color 0.3s;
}
.message-input input:focus {
outline: none;
border-color: #667eea;
}
.message-input button {
padding: 12px 24px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
border-radius: 8px;
font-weight: 600;
cursor: pointer;
transition: all 0.3s;
}
.message-input button:hover {
transform: translateY(-2px);
box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}
.hidden {
display: none !important;
}
.info-box {
padding: 15px;
background: #e3f2fd;
border-left: 4px solid #2196f3;
border-radius: 5px;
margin-bottom: 15px;
font-size: 14px;
color: #555;
}
.empty-state {
text-align: center;
padding: 60px 20px;
color: #999;
}
.empty-state svg {
width: 80px;
height: 80px;
margin-bottom: 20px;
opacity: 0.5;
}
@media (max-width: 600px) {
.container {
margin: 0;
border-radius: 0;
}
.header h1 {
font-size: 24px;
}
.content {
padding: 20px;
}
.chat-container {
height: 350px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🚀 MobileAgentLivelink</h1>
<p>Web客户端 - 远程控制PC Agent IDE</p>
<div id="connectionStatus" class="status disconnected">未连接</div>
</div>
<div class="content">
<!-- 连接设置 -->
<div id="connectSection" class="section">
<h2>连接设置</h2>
<div class="form-group">
<label for="serverUrl">中转服务器地址</label>
<input type="text" id="serverUrl" placeholder="ws://your-server-ip:8765/ws" value="ws://localhost:8765/ws">
</div>
<div class="form-group">
<label for="deviceId">设备ID(任意唯一标识)</label>
<input type="text" id="deviceId" placeholder="web-client-001" value="web-client-001">
</div>
<div class="form-group">
<label for="pairToken">配对密钥(从PC端获取)</label>
<input type="text" id="pairToken" placeholder="pc端 AUTH_TOKEN">
</div>
<button id="connectBtn" class="btn btn-primary" onclick="connect()">连接服务器</button>
</div>
<!-- PC选择 -->
<div id="pcListSection" class="section hidden">
<h2>选择PC设备</h2>
<div class="info-box">
已连接到服务器,请选择要控制的PC设备
</div>
<button class="btn btn-primary" onclick="listPCs()" style="margin-bottom: 15px;">刷新PC列表</button>
<div id="pcList" class="pc-list">
<div class="empty-state">
<p>正在加载在线PC列表...</p>
</div>
</div>
</div>
<!-- 聊天界面 -->
<div id="chatSection" class="section hidden">
<h2>与PC对话</h2>
<div class="info-box" id="pairedPCInfo">
已配对到: <strong id="pairedPCId">-</strong>
</div>
<div class="section">
<div class="form-group">
<label for="contextPaths">上下文请求(可选,逗号分隔路径)</label>
<input type="text" id="contextPaths" placeholder="docs/CONTEXT.md" value="docs/CONTEXT.md">
</div>
<div style="display:flex; gap:10px; flex-wrap:wrap; margin-bottom:10px;">
<button class="btn btn-primary" onclick="requestContext()" id="btnRequestContext">请求上下文</button>
<button class="btn btn-primary" onclick="requestStatus()" id="btnRequestStatus">获取PC状态</button>
<button class="btn btn-primary" onclick="requestNewChat()" id="btnRequestNewChat">新对话/清空上下文</button>
</div>
<div style="display:flex; gap:10px; flex-wrap:wrap;">
<button class="btn" onclick="setChatState(true)" id="btnSetChatOpen">标记面板已打开</button>
<button class="btn" onclick="setChatState(false)" id="btnSetChatClose">标记面板已关闭</button>
</div>
</div>
<div class="chat-container">
<div id="chatMessages" class="chat-messages">
<div class="message received">
<div class="content">连接成功!可以发送开发需求了</div>
<div class="time">系统消息</div>
</div>
</div>
<div class="message-input">
<input type="text" id="messageInput" placeholder="输入开发需求..." onkeypress="handleKeyPress(event)">
<button onclick="sendMessage()">发送</button>
</div>
</div>
</div>
</div>
</div>
<script>
let ws = null;
let pairedPCId = null;
let selectedPCId = null;
let chatHistory = [];
const STORAGE_KEYS = {
serverUrl: 'mal_server_url',
deviceId: 'mal_device_id',
pairToken: 'mal_pair_token',
contextPaths: 'mal_context_paths',
history: 'mal_chat_history'
};
function connect() {
const serverUrl = document.getElementById('serverUrl').value;
const deviceId = document.getElementById('deviceId').value;
if (!serverUrl || !deviceId) {
alert('请填写完整连接信息');
return;
}
// 立即保存设置,确保持久化
saveSettings();
try {
ws = new WebSocket(serverUrl);
ws.onopen = handleOpen;
ws.onmessage = handleMessage;
ws.onerror = handleError;
ws.onclose = handleClose;
document.getElementById('connectBtn').disabled = true;
document.getElementById('connectBtn').textContent = '连接中...';
} catch (e) {
alert('连接失败: ' + e.message);
document.getElementById('connectBtn').disabled = false;
document.getElementById('connectBtn').textContent = '连接服务器';
}
}
function loadSettings() {
const serverUrl = localStorage.getItem(STORAGE_KEYS.serverUrl);
const deviceId = localStorage.getItem(STORAGE_KEYS.deviceId);
const pairToken = localStorage.getItem(STORAGE_KEYS.pairToken);
const contextPaths = localStorage.getItem(STORAGE_KEYS.contextPaths);
if (serverUrl) {
document.getElementById('serverUrl').value = serverUrl;
}
if (deviceId) {
document.getElementById('deviceId').value = deviceId;
}
if (pairToken) {
document.getElementById('pairToken').value = pairToken;
}
if (contextPaths) {
document.getElementById('contextPaths').value = contextPaths;
}
}
function saveSettings() {
localStorage.setItem(STORAGE_KEYS.serverUrl, document.getElementById('serverUrl').value);
localStorage.setItem(STORAGE_KEYS.deviceId, document.getElementById('deviceId').value);
localStorage.setItem(STORAGE_KEYS.pairToken, document.getElementById('pairToken').value);
localStorage.setItem(STORAGE_KEYS.contextPaths, document.getElementById('contextPaths').value);
}
function loadHistory() {
try {
const raw = localStorage.getItem(STORAGE_KEYS.history);
if (!raw) {
return;
}
const items = JSON.parse(raw);
if (Array.isArray(items)) {
chatHistory = items;
items.forEach(item => addMessage(item.type, item.content, item.time, false));
}
} catch (e) {
console.error('历史记录加载失败:', e);
}
}
function saveHistory() {
localStorage.setItem(STORAGE_KEYS.history, JSON.stringify(chatHistory));
}
function getContextPaths() {
const raw = document.getElementById('contextPaths').value.trim();
if (!raw) {
return [];
}
return raw.split(',').map(item => item.trim()).filter(Boolean);
}
function getPairToken() {
return document.getElementById('pairToken').value.trim();
}
function handleOpen() {
const deviceId = document.getElementById('deviceId').value;
// 注册设备
ws.send(JSON.stringify({
type: 'register',
device_id: deviceId,
device_type: 'mobile'
}));
updateConnectionStatus(true);
document.getElementById('connectSection').classList.add('hidden');
document.getElementById('pcListSection').classList.remove('hidden');
listPCs();
updateButtonStates();
}
function handleMessage(event) {
try {
const data = JSON.parse(event.data);
const type = data.type;
switch (type) {
case 'registered':
console.log('设备注册成功:', data.device_id);
break;
case 'pc_list':
displayPCList(data.pcs);
break;
case 'pair_result':
handlePairResult(data);
break;
case 'ack':
handleAck(data);
break;
case 'status':
displayStatus(data);
break;
case 'context_result':
displayContextResult(data);
break;
case 'task_started':
addMessage('system', '任务开始执行');
break;
case 'task_done':
displayTaskDone(data);
break;
case 'new_chat_result':
displayNewChatResult(data);
break;
case 'set_chat_state_result':
displayChatStateResult(data);
break;
case 'error':
alert('错误: ' + data.message);
break;
}
} catch (e) {
console.error('消息解析失败:', e);
}
}
function handleError(error) {
console.error('WebSocket错误:', error);
alert('连接错误,请检查服务器地址');
resetConnection();
}
function handleClose() {
console.log('连接已关闭');
resetConnection();
}
function resetConnection() {
updateConnectionStatus(false);
pairedPCId = null;
selectedPCId = null;
document.getElementById('pairedPCId').textContent = '-';
document.getElementById('connectBtn').disabled = false;
document.getElementById('connectBtn').textContent = '连接服务器';
document.getElementById('connectSection').classList.remove('hidden');
document.getElementById('pcListSection').classList.add('hidden');
document.getElementById('chatSection').classList.add('hidden');
updateButtonStates();
}
function updateConnectionStatus(connected) {
const status = document.getElementById('connectionStatus');
if (connected) {
status.textContent = '已连接';
status.classList.remove('disconnected');
status.classList.add('connected');
} else {
status.textContent = '未连接';
status.classList.remove('connected');
status.classList.add('disconnected');
}
}
function listPCs() {
if (ws && ws.readyState === WebSocket.OPEN) {
ws.send(JSON.stringify({ type: 'list_pcs' }));
document.getElementById('pcList').innerHTML = '<div class="empty-state"><p>正在加载在线PC列表...</p></div>';
}
}
function displayPCList(pcs) {
const container = document.getElementById('pcList');
if (!pcs || pcs.length === 0) {
container.innerHTML = `
<div class="empty-state">
<p>暂无在线PC设备</p>
<p style="font-size: 12px; margin-top: 10px;">请确保PC客户端正在运行并已连接到服务器</p>
</div>
`;
return;
}
container.innerHTML = pcs.map(pcId => `
<div class="pc-item" onclick="selectPC('${pcId}')" id="pc-${pcId}">
<h3>💻 ${pcId}</h3>
<p>点击配对此设备</p>
</div>
`).join('');
}
function selectPC(pcId) {
selectedPCId = pcId;
// 高亮选中项
document.querySelectorAll('.pc-item').forEach(el => el.classList.remove('selected'));
document.getElementById('pc-' + pcId)?.classList.add('selected');
// 发送配对请求
ws.send(JSON.stringify({
type: 'pair',
pc_id: pcId,
token: getPairToken()
}));
}
function updateButtonStates() {
const isConnected = ws && ws.readyState === WebSocket.OPEN;
const isPaired = !!pairedPCId;
const buttonsEnabled = isConnected && isPaired;
const buttons = [
'btnRequestContext',
'btnRequestStatus',
'btnRequestNewChat',
'btnSetChatOpen',
'btnSetChatClose'
];
buttons.forEach(btnId => {
const btn = document.getElementById(btnId);
if (btn) {
btn.disabled = !buttonsEnabled;
if (!buttonsEnabled) {
btn.style.opacity = '0.6';
btn.style.cursor = 'not-allowed';
} else {
btn.style.opacity = '1';
btn.style.cursor = 'pointer';
}
}
});
}
function handlePairResult(data) {
if (data.success) {
pairedPCId = data.pc_id;
document.getElementById('pairedPCId').textContent = pairedPCId;
document.getElementById('pcListSection').classList.add('hidden');
document.getElementById('chatSection').classList.remove('hidden');
addMessage('system', `已成功配对到 PC: ${pairedPCId}`);
updateButtonStates();
} else {
const reasonMap = {
invalid_token: '配对失败: 密钥无效,请检查配对密钥是否正确',
pc_offline: '配对失败: PC未在线',
pc_token_not_configured: '配对失败: PC端未配置AUTH_TOKEN,请先在PC端配置'
};
alert(reasonMap[data.reason] || '配对失败');
}
}
function sendMessage() {
const input = document.getElementById('messageInput');
const content = input.value.trim();
if (!content) {
return;
}
if (!checkConnectionAndPairing()) {
return;
}
const messageId = Date.now();
const contextPaths = getContextPaths();
saveSettings();
// 显示发送的消息
addMessage('sent', content);
input.value = '';
// 发送到PC
ws.send(JSON.stringify({
type: 'send_to_cursor',
content: content,
message_id: messageId,
context_request: contextPaths.length ? { paths: contextPaths } : undefined
}));
}
function handleAck(data) {
if (data.success) {
addMessage('system', '消息已发送到Cursor');
} else {
addMessage('system', '消息发送失败');
}
}
function displayStatus(data) {
let statusText = 'PC状态:\n';
if (data.running !== undefined) {
statusText += `- Cursor运行中: ${data.running ? '是' : '否'}\n`;
}
if (data.title) {
statusText += `- 窗口标题: ${data.title}\n`;
}
if (data.minimized !== undefined) {
statusText += `- 最小化: ${data.minimized ? '是' : '否'}\n`;
}
if (data.project_root) {
statusText += `- 工程目录: ${data.project_root}\n`;
}
if (data.last_message) {
statusText += `- 最后消息: ${data.last_message}\n`;
}
addMessage('received', statusText);
}
function displayContextResult(data) {
if (!data.items || data.items.length === 0) {
addMessage('received', '未返回上下文内容');
return;
}
data.items.forEach(item => {
if (item.ok) {
const header = `上下文: ${item.path}${item.truncated ? ' (已截断)' : ''}`;
addMessage('received', `${header}\n${item.content}`);
} else {
addMessage('received', `上下文获取失败: ${item.path} (${item.error})`);
}
});
}
function displayTaskDone(data) {
const estimated = data.estimated ? '(保底通知)' : '';
addMessage('system', `任务完成${estimated}`);
}
function displayNewChatResult(data) {
if (data.success) {
addMessage('system', '已触发新对话');
chatHistory = [];
saveHistory();
document.getElementById('chatMessages').innerHTML = '';
} else {
addMessage('system', '新对话触发失败');
}
}
function displayChatStateResult(data) {
if (data.success) {
addMessage('system', `已标记面板状态为: ${data.open ? '打开' : '关闭'}`);
} else {
addMessage('system', '面板状态更新失败');
}
}
function checkConnectionAndPairing() {
if (!ws || ws.readyState !== WebSocket.OPEN) {
alert('未连接到服务器,请先连接');
return false;
}
if (!pairedPCId) {
alert('未配对到PC,请先选择并配对PC设备');
return false;
}
return true;
}
function requestStatus() {
if (!checkConnectionAndPairing()) {
return;
}
ws.send(JSON.stringify({ type: 'get_status' }));
}
function requestContext() {
if (!checkConnectionAndPairing()) {
return;
}
const requestId = Date.now();
const paths = getContextPaths();
saveSettings();
ws.send(JSON.stringify({
type: 'get_context',
request_id: requestId,
context_request: { paths }
}));
}
function requestNewChat() {
if (!checkConnectionAndPairing()) {
return;
}
const requestId = Date.now();
ws.send(JSON.stringify({ type: 'new_chat', request_id: requestId }));
}
function setChatState(open) {
if (!checkConnectionAndPairing()) {
return;
}
const requestId = Date.now();
ws.send(JSON.stringify({ type: 'set_chat_state', request_id: requestId, open }));
}
function addMessage(type, content, time = null, save = true) {
const container = document.getElementById('chatMessages');
const messageDiv = document.createElement('div');
messageDiv.className = `message ${type}`;
const contentDiv = document.createElement('div');
contentDiv.className = 'content';
contentDiv.textContent = content;
const timeDiv = document.createElement('div');
timeDiv.className = 'time';
const timeText = time || new Date().toLocaleTimeString();
timeDiv.textContent = timeText;
messageDiv.appendChild(contentDiv);
messageDiv.appendChild(timeDiv);
container.appendChild(messageDiv);
if (save) {
chatHistory.push({ type, content, time: timeText });
saveHistory();
}
// 滚动到底部
container.scrollTop = container.scrollHeight;
}
// 页面加载时立即加载设置(不等待load事件,确保尽早恢复)
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => {
loadSettings();
loadHistory();
updateButtonStates();
});
} else {
// DOM已经加载完成
loadSettings();
loadHistory();
updateButtonStates();
}
// 也监听load事件作为备用
window.addEventListener('load', () => {
// 确保设置已加载
if (!localStorage.getItem(STORAGE_KEYS.serverUrl)) {
loadSettings();
}
updateButtonStates();
});
function handleKeyPress(event) {
if (event.key === 'Enter') {
sendMessage();
}
}
</script>
</body>
</html>