forked from lioensky/VCPChat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.html
More file actions
executable file
·1036 lines (968 loc) · 72.9 KB
/
Copy pathmain.html
File metadata and controls
executable file
·1036 lines (968 loc) · 72.9 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
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy"
content="default-src 'self' data:;
script-src 'self' 'unsafe-inline';
style-src 'self' 'unsafe-inline' https:;
img-src * data: file: blob:;
media-src * data: file:;
font-src *;
connect-src * ws: wss:;">
<title>VCPChat</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="Flowlockmodules/flowlock.css">
<link rel="stylesheet" href="Promptmodules/prompt-modules.css">
<link rel="stylesheet" href="vendor/katex.min.css" crossorigin="anonymous">
<script defer src="vendor/katex.min.js" crossorigin="anonymous"></script>
<script defer src="vendor/auto-render.min.js" crossorigin="anonymous"></script>
<script src="vendor/marked.min.js"></script> <!-- 添加 marked.js -->
<script src="vendor/highlight.min.js"></script>
<script src="vendor/anime.min.js"></script>
<script src="vendor/mermaid.min.js"></script>
<script src="vendor/three.min.js"></script> <!-- 全局引入 three.js -->
<script src="vendor/morphdom.min.js"></script>
</head>
<body>
<div class="seam-fixer" id="title-bar-seam-fixer"></div>
<div class="title-bar">
<div class="title-bar-text"><img src="assets/icon.png" alt="Logo" class="title-bar-logo"> VCPChat</div>
<div class="title-bar-controls">
<button id="themes-btn" class="title-bar-button" title="主题商店" onclick="window.electronAPI.openThemesWindow()">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16" style="width: 12px; height: 12px;">
<path d="M15.825.12a.5.5 0 0 1 .132.584c-1.53 3.43-4.743 8.17-7.095 10.64a6.067 6.067 0 0 1-2.373 1.534c-.018.227-.06.538-.16.868-.201.659-.667 1.479-1.708 1.74a8.118 8.118 0 0 1-3.078.132 3.659 3.659 0 0 1-.562-.135 1.382 1.382 0 0 1-.466-.247.714.714 0 0 1-.204-.288.622.622 0 0 1 .004-.443c.095-.245.316-.38.461-.452.394-.197.625-.453.867-.826.095-.144.184-.297.287-.472l.117-.198c.151-.255.326-.5.527-.734.206-.236.438-.46.693-.659.26-.2.548-.37.848-.487.306-.12.624-.19.958-.21a3.36 3.36 0 0 1 .82.025c.28.04.554.12.81.24.26.12.5.28.7.49.2.21.36.46.48.74.12.28.2.6.22.94.02.34-.02.69-.1.99-.08.3-.2.59-.35.86-.15.27-.35.52-.58.75-.23.23-.5.43-.78.58-.28.15-.59.26-.92.32-.33.06-.67.06-1.01-.02a4.007 4.007 0 0 1-1.12-.328.5.5 0 0 1-.28-.88c.24-.17.54-.38.87-.58.33-.19.68-.42 1.05-.68.37-.26.76-.55 1.18-.86.42-.3.87-.62 1.34-.94.47-.32.96-.64 1.48-.96.52-.32 1.05-.63 1.6-.92.55-.29 1.1-.56 1.65-.8.55-.24 1.1-.47 1.6-.68.5-.2.95-.38 1.36-.51a.5.5 0 0 1 .585.132z"/>
</svg>
</button>
<button id="minimize-to-tray-btn" class="title-bar-button" title="最小化到托盘">
<svg viewBox="0 0 10 10">
<polygon points="5,8 0,2 10,2"></polygon>
</svg>
</button>
<button id="minimize-btn" class="title-bar-button" title="最小化">
<svg x="0px" y="0px" viewBox="0 0 10.2 1"><rect x="0" y="0" width="10.2" height="1"></rect></svg>
</button>
<button id="maximize-btn" class="title-bar-button" title="最大化">
<svg viewBox="0 0 10 10"><path d="M0,0v10h10V0H0z M9,9H1V1h8V9z"></path></svg>
</button>
<button id="restore-btn" class="title-bar-button" title="还原" style="display: none;">
<svg viewBox="0 0 10.2 10.1"><path d="M2.1,0v2H0v8.1h8.2v-2h2V0H2.1z M7.2,9.2H1.1V3h6.1V9.2z M9.2,7.1h-1V2H3.1V1h6.1V7.1z"></path></svg>
</button>
<button id="close-btn" class="title-bar-button close-button" title="关闭">
<svg viewBox="0 0 10 10"><polygon points="10,1.01 8.99,0 5,3.99 1.01,0 0,1.01 3.99,5 0,8.99 1.01,10 5,6.01 8.99,10 10,8.99 6.01,5"></polygon></svg>
</button>
</div>
</div>
<div class="container">
<aside class="sidebar active">
<div class="sidebar-tabs">
<button class="sidebar-tab-button active" data-tab="agents">助手</button>
<button class="sidebar-tab-button" data-tab="topics">话题</button>
<button class="sidebar-tab-button" data-tab="settings">设置</button>
</div>
<div class="sidebar-tab-content active" id="tabContentAgents">
<div class="agents-header">
<h2>VCP Agents</h2>
<div class="topic-search-container">
<input type="text" id="agentSearchInput" placeholder="搜索助手或群..." class="topic-search-input">
</div>
</div>
<ul class="agent-list" id="agentList">
<!-- 示例:
<li class="active" data-agent-id="xiaoke">
<img src="path/to/xiaoke_avatar.png" alt="小克头像" class="avatar">
<span class="agent-name">猫娘小克</span>
</li>
-->
</ul>
<div class="sidebar-actions">
<button id="createNewAgentBtn" class="sidebar-button create-agent-btn small-button">创建Agent</button>
<button id="createNewGroupBtn" class="sidebar-button create-group-btn small-button">创建 Group</button>
</div>
</div>
<div class="sidebar-tab-content" id="tabContentTopics">
<!-- 话题内容区 -->
<div class="topics-header-container">
<h2>话题</h2>
<div class="topic-search-container">
<input type="text" id="topicSearchInput" placeholder="搜索话题..." class="topic-search-input">
<!-- Search button removed -->
</div>
</div>
<ul class="topic-list" id="topicList">
<!-- 话题列表将在这里动态加载 -->
</ul>
</div>
<div class="sidebar-tab-content" id="tabContentSettings">
<!-- 设置内容区 -->
<div class="settings-header-bar">
<h2>设置</h2>
<button id="globalSettingsBtn" class="sidebar-button global-settings-btn">全局设置</button>
</div>
<div id="agentSettingsContainer" style="display: none;"> <!-- Initially hidden -->
<h3 id="agentSettingsContainerTitle">助手设置: <span id="selectedAgentNameForSettings"></span></h3>
<form id="agentSettingsForm">
<input type="hidden" id="editingAgentId" name="agentId">
<!-- Agent名称和头像容器 -->
<div class="agent-identity-container">
<div class="agent-identity-main">
<div class="agent-avatar-wrapper">
<img id="agentAvatarPreview" src="assets/default_avatar.png" alt="头像预览" class="agent-avatar-display" style="display: block;">
<label for="agentAvatarInput" class="avatar-upload-overlay">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"></path>
<circle cx="12" cy="13" r="4"></circle>
</svg>
</label>
<input type="file" id="agentAvatarInput" name="avatar" accept="image/png, image/jpeg, image/gif" style="display: none;">
</div>
<div class="agent-name-wrapper">
<label for="agentNameInput">Agent 名称</label>
<input type="text" id="agentNameInput" name="name" required>
</div>
</div>
<!-- 自定义样式设置 - 可折叠 -->
<div class="agent-style-collapsible-container collapsed">
<div class="style-collapse-header" id="styleCollapseHeader">
<span class="style-collapse-icon">▶</span>
<span class="style-collapse-title">自定义样式设置</span>
</div>
<div class="agent-style-controls">
<!-- 禁用自定义颜色开关 -->
<div class="style-control-item full-width">
<div class="form-group-inline" style="justify-content: space-between; align-items: center; margin-bottom: 10px;">
<label for="disableCustomColors" style="margin-bottom: 0;">助手页面中使用主题默认颜色</label>
<label class="switch" style="margin-bottom: 0;">
<input type="checkbox" id="disableCustomColors" name="disableCustomColors">
<span class="slider round"></span>
</label>
</div>
</div>
<!-- 会话中使用主题颜色开关 -->
<div class="style-control-item full-width">
<div class="form-group-inline" style="justify-content: space-between; align-items: center; margin-bottom: 10px;">
<label for="useThemeColorsInChat" style="margin-bottom: 0;">会话界面中使用主题默认颜色</label>
<label class="switch" style="margin-bottom: 0;">
<input type="checkbox" id="useThemeColorsInChat" name="useThemeColorsInChat">
<span class="slider round"></span>
</label>
</div>
</div>
<div class="style-control-item">
<label for="agentAvatarBorderColor">头像外框颜色:</label>
<div class="color-input-group">
<input type="color" id="agentAvatarBorderColor" name="avatarBorderColor" value="#3d5a80">
<input type="text" id="agentAvatarBorderColorText" placeholder="#3d5a80" maxlength="7">
</div>
</div>
<div class="style-control-item">
<label for="agentNameTextColor">名称文字颜色:</label>
<div class="color-input-group">
<input type="color" id="agentNameTextColor" name="nameTextColor" value="#ffffff">
<input type="text" id="agentNameTextColorText" placeholder="#ffffff" maxlength="7">
</div>
</div>
<!-- 重置颜色按钮 -->
<div class="style-control-item full-width">
<button type="button" id="resetAvatarColorsBtn" class="reset-colors-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"></path>
<path d="M21 3v5h-5"></path>
<path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"></path>
<path d="M3 21v-5h5"></path>
</svg>
重置为头像默认颜色
</button>
</div>
<div class="style-control-item full-width">
<label for="agentCustomCss">列表项自定义CSS:</label>
<textarea id="agentCustomCss" name="customCss" placeholder="例如: border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.2);" rows="3"></textarea>
<small style="color: var(--text-secondary); font-size: 0.85em;">提示:此CSS将应用于【助手】页面的Agent列表项容器</small>
</div>
<div class="style-control-item full-width">
<label for="agentCardCss">名片样式CSS:</label>
<textarea id="agentCardCss" name="cardCss" placeholder="例如: border-radius: 15px; background: linear-gradient(135deg, rgba(138, 43, 226, 0.1), rgba(75, 0, 130, 0.05));" rows="3"></textarea>
<small style="color: var(--text-secondary); font-size: 0.85em;">提示:此CSS将应用于【设置】页面中Agent的名片区域(头像和名称)</small>
</div>
<div class="style-control-item full-width">
<label for="agentChatCss">会话样式CSS:</label>
<textarea id="agentChatCss" name="chatCss" placeholder="例如: .message-avatar { filter: drop-shadow(0 0 10px rgba(100,150,255,0.8)); } .sender-name { text-shadow: 0 0 8px currentColor; }" rows="4"></textarea>
<small style="color: var(--text-secondary); font-size: 0.85em;">提示:此CSS将应用于【聊天会话】中Agent的头像和名称。可使用 .message-avatar 控制头像,.sender-name 控制名称</small>
</div>
</div>
</div>
</div>
<div>
<label for="systemPromptContainer">系统提示词(三个模块独立,编辑后注意保存以生效):</label>
<div id="systemPromptContainer" class="system-prompt-container">
<!-- Promptmodules will be initialized here -->
</div>
</div>
<div>
<label for="agentModel">模型名称:</label>
<div class="model-input-container">
<input type="text" id="agentModel" name="model" placeholder="例如 gemini-2.5-flash-preview-05-20">
<button type="button" id="openModelSelectBtn" class="small-button" title="选择模型">
<svg data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="16" height="16">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9"></path>
</svg>
</button>
</div>
</div>
<!-- 参数设置可折叠容器 -->
<div class="agent-params-collapsible-container">
<div class="params-header" id="paramsToggleHeader">
<span class="params-title">模型参数配置</span>
<div class="params-summary" id="paramsSummary"></div>
<button type="button" class="params-toggle-btn" id="paramsToggleBtn" aria-label="展开/折叠参数">
<svg class="toggle-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
</div>
<div class="params-content" id="paramsContent">
<div>
<label for="agentTemperature">Temperature (0-1):</label>
<input type="number" id="agentTemperature" name="temperature" min="0" max="1" step="0.1">
</div>
<div>
<label for="agentContextTokenLimit">上下文Token上限:</label>
<input type="number" id="agentContextTokenLimit" name="contextTokenLimit" min="0" step="100">
</div>
<div>
<label for="agentMaxOutputTokens">最大输出Token上限:</label>
<input type="number" id="agentMaxOutputTokens" name="maxOutputTokens" min="0" step="50">
</div>
<div>
<label for="agentTopP">Top P (0-1):</label>
<input type="number" id="agentTopP" name="top_p" min="0" max="0.95" step="0.05">
</div>
<div>
<label for="agentTopK">Top K (0-64):</label>
<input type="number" id="agentTopK" name="top_k" min="0" max="64" step="1">
</div>
<div class="form-group-inline">
<label>输出模式:</label>
<label for="agentStreamOutputTrue" style="margin-left: 10px;">
<input type="radio" id="agentStreamOutputTrue" name="streamOutput" value="true" checked> 流式
</label>
<label for="agentStreamOutputFalse" style="margin-left: 15px;">
<input type="radio" id="agentStreamOutputFalse" name="streamOutput" value="false"> 非流式
</label>
</div>
</div>
</div>
<hr class="form-divider">
<!-- 语音设置可折叠容器 -->
<div class="agent-params-collapsible-container">
<div class="params-header" id="ttsToggleHeader">
<span class="params-title">语音设置 (Sovits TTS)</span>
<div class="params-summary" id="ttsSummary"></div>
<button type="button" class="params-toggle-btn" id="ttsToggleBtn" aria-label="展开/折叠语音设置">
<svg class="toggle-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
</div>
<div class="params-content" id="ttsContent">
<div>
<label for="agentTtsVoicePrimary">主语言模型:</label>
<div class="model-input-container">
<select id="agentTtsVoicePrimary" name="ttsVoicePrimary">
<option value="">不使用语音</option>
</select>
<button type="button" id="refreshTtsModelsBtn" class="small-button" title="刷新模型列表">
<svg data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="16" height="16">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 11.667 0l3.181-3.183m-4.991-2.691v-2.985h-4.992v2.985h4.992Zm-4.993 0v4.992h4.992v-4.992h-4.992Z"></path>
</svg>
</button>
</div>
</div>
<div>
<label for="agentTtsRegexPrimary">主语言正则 (留空则匹配全部):</label>
<input type="text" id="agentTtsRegexPrimary" name="ttsRegexPrimary" placeholder="例如 [^\[\]]+">
</div>
<hr class="form-divider-dashed">
<div>
<label for="agentTtsVoiceSecondary">副语言模型:</label>
<div class="model-input-container">
<select id="agentTtsVoiceSecondary" name="ttsVoiceSecondary">
<option value="">不使用</option>
</select>
</div>
</div>
<div>
<label for="agentTtsRegexSecondary">副语言正则:</label>
<input type="text" id="agentTtsRegexSecondary" name="ttsRegexSecondary" placeholder="例如 \[(.*?)\]">
</div>
<hr class="form-divider-dashed">
<div>
<label for="agentTtsSpeed">语速:</label>
<div class="slider-container">
<input type="range" id="agentTtsSpeed" name="ttsSpeed" min="0.5" max="2.0" step="0.1" value="1.0">
<span id="ttsSpeedValue">1.0</span>
</div>
</div>
</div>
</div>
<div class="form-actions">
<button type="submit">保存Agent设置</button>
<div class="delete-button-container">
<button type="button" id="deleteAgentBtn" class="danger-button">删除此Agent</button>
</div>
</div>
</form>
</div>
<p id="selectAgentPromptForSettings" style="display: block;">请先在“助手”标签页选择一个Agent以查看或修改其设置。</p>
</div>
</aside>
<div class="resizer" id="resizerLeft"></div>
<main class="main-content">
<header class="chat-header">
<h3 id="currentChatAgentName">选择一个Agent开始聊天</h3>
<div class="chat-actions">
<button id="toggleAssistantBtn" class="header-button" title="左键划词助手/右键折叠侧栏">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" width="18" height="18" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 11.667 0l3.181-3.183m-4.991-2.691v-2.985h-4.992v2.985h4.992Zm-4.993 0v4.992h4.992v-4.992h-4.992Z"></path>
</svg>
</button>
<button id="toggleNotificationsBtn" class="header-button" title="左键启动通知/右键监控面板">
<svg data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="18" height="18">
<path stroke-linecap="round" stroke-linejoin="round" d="M14.857 17.082a23.848 23.848 0 0 0 5.454-1.31A8.967 8.967 0 0 1 18 9.75V9A6 6 0 0 0 6 9v.75a8.967 8.967 0 0 1-2.312 6.022c1.733.64 3.56 1.085 5.455 1.31m5.714 0a24.255 24.255 0 0 1-5.714 0m5.714 0a3 3 0 1 1-5.714 0"></path>
</svg>
</button>
<button id="themeToggleBtn" class="header-button" title="深色/浅色模式">
<svg id="sun-icon" class="theme-icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386-1.591 1.591M21 12h-2.25m-.386 6.364-1.591-1.591M12 18.75V21m-4.773-4.227-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z"></path>
</svg>
<svg id="moon-icon" class="theme-icon" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<path d="M21.752 15.002A9.72 9.72 0 0 1 18 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 0 0 3 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 0 0 9.002-5.998Z"></path>
</svg>
</button>
<button id="currentAgentSettingsBtn" class="header-button" title="当前Agent设置" style="display: none;">⚙️ Agent设置</button>
<button id="voiceChatBtn" class="header-button" title="语音聊天" style="margin-right: 5px; display: none;">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" width="18" height="18">
<path d="M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.49 6-3.31 6-6.72h-1.7z"></path>
</svg>
</button>
</div>
</header>
<div class="chat-messages-container">
<div class="chat-messages" id="chatMessages">
</div>
</div>
<footer class="chat-input-area">
<div class="attachment-preview-area" id="attachmentPreviewArea"></div>
<textarea id="messageInput" placeholder="输入消息... (Shift+Enter 换行)" rows="1" disabled></textarea>
<button id="sendMessageBtn" title="发送消息 (Ctrl+Enter)" disabled>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 512 512" fill="currentColor"><path d="M474.444 19.857a20.336 20.336 0 0 0-21.592-2.781L33.737 213.8v38.066l176.037 70.414L322.69 496h38.074l120.3-455.4a20.342 20.342 0 0 0-6.62-20.743ZM337.257 459.693L240.2 310.37l149.353-163.582l-23.631-21.576L215.4 290.069L70.257 232.012L443.7 56.72Z"/></svg>
</button>
<button id="attachFileBtn" title="发送文件" disabled>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="4 4 56 56" fill="currentColor"><path d="M 18.505859 9.4140625 C 15.577379 9.4140625 13.181641 11.809801 13.181641 14.738281 L 13.181641 50.154297 C 13.181641 53.082777 15.577379 55.478516 18.505859 55.478516 L 46.644531 55.478516 C 49.573011 55.478516 51.96875 53.082777 51.96875 50.154297 L 51.96875 29.148438 A 1.0001 1.0001 0 1 0 49.96875 29.148438 L 49.96875 50.154297 C 49.96875 52.001817 48.492051 53.478516 46.644531 53.478516 L 18.505859 53.478516 C 16.65834 53.478516 15.181641 52.001817 15.181641 50.154297 L 15.181641 14.738281 C 15.181641 12.890761 16.65834 11.414062 18.505859 11.414062 L 36.712891 11.414062 L 48.449219 24.03125 L 39.064453 24.03125 C 38.283048 24.03125 37.669922 23.420077 37.669922 22.638672 L 37.669922 16.798828 A 1.0001 1.0001 0 1 0 35.669922 16.798828 L 35.669922 22.638672 C 35.669922 24.501267 37.201858 26.03125 39.064453 26.03125 L 50.744141 26.03125 A 1.0001 1.0001 0 0 0 51.476562 24.351562 L 37.880859 9.734375 A 1.0001 1.0001 0 0 0 37.148438 9.4140625 L 18.505859 9.4140625 z"></path></svg>
</button>
</footer>
</main>
<div class="resizer" id="resizerRight"></div>
<aside class="notifications-sidebar" id="notificationsSidebar">
<header class="notifications-header">
<h4 id="notificationTitle" style="display: none;">VCP 通知</h4>
<div class="datetime-container">
<div id="digitalClock" class="digital-clock"></div>
<div id="dateDisplay" class="date-display"></div>
</div>
<div class="notification-header-actions">
<button id="openForumBtn" class="header-button" title="左键VCP论坛/右键VCPMemo中心">
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
</svg>
</button>
<button id="doNotDisturbBtn" class="header-button" title="过滤模式(左键总开关/右键设置过滤规则)">过滤</button>
<button id="clearNotificationsBtn" title="清空通知">清空</button>
</div>
</header>
<div class="notifications-status" id="vcpLogConnectionStatus">
VCPLog: 未连接
</div>
<ul class="notifications-list" id="notificationsList">
</ul>
<div id="inviteAgentButtonsContainer" class="invite-agent-buttons-container" style="display: none; padding: 10px; border-top: 1px solid var(--border-color); margin-top:10px;">
<!-- 邀请发言按钮将由 JavaScript 动态填充到这里 -->
</div>
<hr class="section-divider">
<div class="notes-section">
<button id="openTranslatorBtn" class="header-button" title="翻译">
<svg data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="18" height="18">
<path stroke-linecap="round" stroke-linejoin="round" d="M10.5 21h7.5m-9-13.5h6m-6 4.5h6m-10.5-6.75h6a2.25 2.25 0 0 1 2.25 2.25v10.5a2.25 2.25 0 0 1-2.25 2.25h-6a2.25 2.25 0 0 1-2.25-2.25v-10.5A2.25 2.25 0 0 1 10.5 3.75ZM15.75 12a3.75 3.75 0 1 1-7.5 0 3.75 3.75 0 0 1 7.5 0Z" />
</svg>
翻译
</button>
<button id="openNotesBtn" class="header-button" title="打开笔记">
<svg data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="18" height="18">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.862 4.487l1.687-1.688a1.875 1.875 0 112.652 2.652L10.582 16.07a4.5 4.5 0 01-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 011.13-1.897l8.2-8.2zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0115.75 21H5.25A2.25 2.25 0 013 18.75V8.25A2.25 2.25 0 015.25 6H10"></path>
</svg>
笔记
</button>
<button id="openMusicBtn" class="header-button" title="音乐播放器">
<svg data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="18" height="18">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 18V5l12-2v13M9 18a3 3 0 100-6 3 3 0 000 6zm12-2a3 3 0 100-6 3 3 0 000 6z"></path>
</svg>
音乐
</button>
<button id="openCanvasBtn" class="header-button" title="协同">
<svg data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="18" height="18">
<path stroke-linecap="round" stroke-linejoin="round" d="M17.25 6.75 22.5 12l-5.25 5.25m-10.5 0L1.5 12l5.25-5.25m7.5-3-4.5 16.5"></path>
</svg>
协同
</button>
</div>
</aside>
</div>
<div id="modal-container"></div>
<template id="globalSettingsModalTemplate">
<div class="modal" id="globalSettingsModal">
<div class="modal-content">
<span class="close-button" onclick="uiHelperFunctions.closeModal('globalSettingsModal')">×</span>
<h2>全局设置</h2>
<form id="globalSettingsForm">
<!-- 用户身份容器 -->
<div class="agent-identity-container">
<div class="agent-identity-main">
<div class="agent-avatar-wrapper">
<img id="userAvatarPreview" src="assets/default_user_avatar.png" alt="用户头像预览" class="agent-avatar-display" style="display: block;">
<label for="userAvatarInput" class="avatar-upload-overlay">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"></path>
<circle cx="12" cy="13" r="4"></circle>
</svg>
</label>
<input type="file" id="userAvatarInput" name="userAvatar" accept="image/png, image/jpeg, image/gif" style="display: none;">
</div>
<div class="agent-name-wrapper">
<label for="userName">用户名:</label>
<input type="text" id="userName" name="userName" placeholder="您的用户名" required>
</div>
</div>
<!-- 用户自定义样式设置 - 可折叠 -->
<div class="agent-style-collapsible-container collapsed">
<div class="style-collapse-header" id="userStyleCollapseHeader">
<span class="style-collapse-icon">▶</span>
<span class="style-collapse-title">自定义样式设置</span>
</div>
<div class="agent-style-controls">
<div class="style-control-item">
<label for="userAvatarBorderColor">头像外框颜色:</label>
<div class="color-input-group">
<input type="color" id="userAvatarBorderColor" name="userAvatarBorderColor" value="#3d5a80">
<input type="text" id="userAvatarBorderColorText" placeholder="#3d5a80" maxlength="7">
</div>
</div>
<div class="style-control-item">
<label for="userNameTextColor">名称文字颜色:</label>
<div class="color-input-group">
<input type="color" id="userNameTextColor" name="userNameTextColor" value="#ffffff">
<input type="text" id="userNameTextColorText" placeholder="#ffffff" maxlength="7">
</div>
</div>
<!-- 重置颜色按钮 -->
<div class="style-control-item full-width">
<button type="button" id="resetUserAvatarColorsBtn" class="reset-colors-btn">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8"></path>
<path d="M21 3v5h-5"></path>
<path d="M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16"></path>
<path d="M3 21v-5h5"></path>
</svg>
重置为头像默认颜色
</button>
</div>
</div>
</div>
</div>
<hr style="border: none; border-top: 1px solid var(--border-color); margin: 20px 0;">
<div>
<label for="vcpServerUrl">VCP 服务器 URL:</label>
<input type="url" id="vcpServerUrl" name="vcpServerUrl" placeholder="将自动补全 /v1/chat/completions" required>
</div>
<div>
<label for="vcpApiKey">VCP API Key:</label>
<input type="password" id="vcpApiKey" name="vcpApiKey">
</div>
<div>
<label for="vcpLogUrl">VCP WebSocket服务器 URL:</label>
<input type="url" id="vcpLogUrl" name="vcpLogUrl">
</div>
<div>
<label for="vcpLogKey">VCP WebSocket鉴权 Key:</label>
<input type="password" id="vcpLogKey" name="vcpLogKey">
</div>
<div class="form-group">
<label>网络笔记路径:</label>
<div id="networkNotesPathsContainer" style="display: flex; flex-direction: column; gap: 8px;">
<!-- Path inputs will be dynamically added here -->
</div>
<button type="button" id="addNetworkPathBtn" class="sidebar-button small-button" style="margin-top: 8px; width: auto; padding: 4px 10px;">添加路径</button>
</div>
<div class="form-group-inline" style="justify-content: space-between; align-items: center; margin-bottom: 15px;">
<label for="enableAgentBubbleTheme">开启Agent自定义气泡主题</label>
<label class="switch">
<input type="checkbox" id="enableAgentBubbleTheme" name="enableAgentBubbleTheme" checked>
<span class="slider round"></span>
</label>
</div>
<div class="form-group-inline" style="justify-content: space-between; align-items: center; margin-bottom: 15px;">
<label for="enableSmoothStreaming">开启高级流式渲染</label>
<label class="switch">
<input type="checkbox" id="enableSmoothStreaming" name="enableSmoothStreaming">
<span class="slider round"></span>
</label>
</div>
<div class="form-group-inline">
<div>
<label for="minChunkBufferSize" style="display: block; margin-bottom: 4px;">最小渲染Chunk字数 (≥1):</label>
<input type="number" id="minChunkBufferSize" name="minChunkBufferSize" min="1" value="16" style="width: 80px;">
</div>
<div style="margin-left: 20px;">
<label for="smoothStreamIntervalMs" style="display: block; margin-bottom: 4px;">最小渲染Chunk间隔 (ms, ≥1):</label>
<input type="number" id="smoothStreamIntervalMs" name="smoothStreamIntervalMs" min="1" value="100" style="width: 80px;">
</div>
</div>
<div>
</div>
<hr style="border: none; border-top: 1px solid var(--border-color); margin: 20px 0;">
<div id="assistantAgentContainer" style="margin-top: 15px;">
<label for="assistantAgent">划词助手 Agent:</label>
<select id="assistantAgent" name="assistantAgent">
<option value="">请选择一个Agent</option>
<!-- Agent list will be populated by JS -->
</select>
</div>
<div id="topicSummaryModelContainer" style="margin-top: 15px;">
<label for="topicSummaryModel">话题总结模型:</label>
<div class="model-input-container">
<input type="text" id="topicSummaryModel" name="topicSummaryModel" placeholder="默认: gemini-2.5-flash-preview-05-20">
<button type="button" id="openTopicSummaryModelSelectBtn" class="small-button" title="选择模型">
<svg data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="16" height="16">
<path stroke-linecap="round" stroke-linejoin="round" d="M8.25 15L12 18.75 15.75 15m-7.5-6L12 5.25 15.75 9"></path>
</svg>
</button>
</div>
</div>
<hr style="border: none; border-top: 1px solid var(--border-color); margin: 20px 0;">
<div class="form-group-inline" style="justify-content: space-between; align-items: center; margin-bottom: 20px;">
<label for="enableDistributedServer">启用VCP分布式服务器</label>
<label class="switch">
<input type="checkbox" id="enableDistributedServer" name="enableDistributedServer">
<span class="slider round"></span>
</label>
</div>
<div class="form-group-inline" style="justify-content: space-between; align-items: center; margin-bottom: 20px;">
<label for="enableVcpToolInjection">开启VCP工具信息注入上下文</label>
<label class="switch">
<input type="checkbox" id="enableVcpToolInjection" name="enableVcpToolInjection">
<span class="slider round"></span>
</label>
</div>
<div class="form-group-inline" style="justify-content: space-between; align-items: center; margin-bottom: 20px;">
<label for="enableThoughtChainInjection" title="开启后,AI 的元思考内容(Thought Chain)将保留在上下文中,否则将被自动清理。">元思考注入 AI 上下文</label>
<label class="switch">
<input type="checkbox" id="enableThoughtChainInjection" name="enableThoughtChainInjection">
<span class="slider round"></span>
</label>
</div>
<div class="form-group-inline" style="justify-content: space-between; align-items: center; margin-bottom: 20px;">
<label for="enableAiMessageButtons" title="开启后,AI回复中的按钮将可以点击并自动发送消息">启用AI消息快捷按钮</label>
<label class="switch">
<input type="checkbox" id="enableAiMessageButtons" name="enableAiMessageButtons">
<span class="slider round"></span>
</label>
</div>
<hr style="border: none; border-top: 1px solid var(--border-color); margin: 20px 0;">
<div class="form-group-inline" style="justify-content: space-between; align-items: center; margin-bottom: 15px;">
<label for="enableContextSanitizer" title="开启后,在提交给AI的上下文中,较早的AI消息的HTML将被转换为Markdown以节省Token。">上下文HTML标签转MD净化器</label>
<label class="switch">
<input type="checkbox" id="enableContextSanitizer" name="enableContextSanitizer">
<span class="slider round"></span>
</label>
</div>
<div class="form-group" id="contextSanitizerDepthContainer" style="display: none; margin-bottom: 20px;">
<label for="contextSanitizerDepth">净化初始深度:</label>
<input type="number" id="contextSanitizerDepth" name="contextSanitizerDepth" min="0" value="2" style="width: 80px;">
<small style="color: var(--text-secondary); margin-top: 5px; display: block;">
例如: 设置为2,则从倒数第3条AI消息开始净化。设置为0,则净化所有AI消息。
</small>
</div>
<div class="form-group-inline" style="justify-content: space-between; align-items: center;">
<label for="agentMusicControl">启用Agent音乐控制</label>
<label class="switch">
<input type="checkbox" id="agentMusicControl" name="agentMusicControl">
<span class="slider round"></span>
</label>
</div>
<hr style="border: none; border-top: 1px solid var(--border-color); margin: 20px 0;">
<div class="form-group" style="margin-bottom: 20px;">
<label for="continueWritingPrompt">中键续写默认提示词:</label>
<input type="text" id="continueWritingPrompt" name="continueWritingPrompt" placeholder="默认: 请继续" value="请继续">
<small style="color: var(--text-secondary); margin-top: 5px; display: block;">
提示:在输入框上中键点击时,如果输入框为空则使用此提示词进行续写;使用 ctrl/command+d 快速使用。
</small>
</div>
<div class="form-group" style="margin-bottom: 20px;">
<label for="flowlockContinueDelay">心流锁续写延迟 (秒):</label>
<input type="number" id="flowlockContinueDelay" name="flowlockContinueDelay" min="1" max="300" step="1" value="5" style="width: 80px;">
<small style="color: var(--text-secondary); margin-top: 5px; display: block;">
提示:AI完成一次续写后,等待指定秒数再开始下一次续写。
</small>
</div>
<hr style="border: none; border-top: 1px solid var(--border-color); margin: 20px 0;">
<div class="form-group-inline" style="justify-content: space-between; align-items: center; margin-bottom: 15px;">
<label for="enableMiddleClickQuickAction">启用在聊天气泡中的中键快捷功能</label>
<label class="switch">
<input type="checkbox" id="enableMiddleClickQuickAction" name="enableMiddleClickQuickAction">
<span class="slider round"></span>
</label>
</div>
<div class="form-group" id="middleClickQuickActionContainer" style="display: none; margin-bottom: 20px;">
<label for="middleClickQuickAction">中键快速执行功能:</label>
<select id="middleClickQuickAction" name="middleClickQuickAction">
<option value="">请选择要快速执行的功能</option>
<option value="edit">编辑消息</option>
<option value="copy">复制文本</option>
<option value="createBranch">创建分支</option>
<option value="forward">转发消息</option>
<option value="readAloud">朗读气泡</option>
<option value="readMode">阅读模式</option>
<option value="regenerate">重新回复</option>
<option value="delete">删除消息</option>
</select>
<small style="color: var(--text-secondary); margin-top: 5px; display: block;">
提示:启用后,中键按下消息气泡,1 秒内松开将快速执行选中的右键菜单功能
</small>
</div>
<!-- 重新回复保险机制开关 - 仅在中键快速执行功能为重新回复时显示 -->
<div class="form-group" id="regenerateConfirmationContainer" style="display: none; margin-bottom: 15px;">
<div class="form-group-inline" style="justify-content: space-between; align-items: center;">
<label for="enableRegenerateConfirmation" title="开启后,当重新回复的消息不是最后一条时会显示确认对话框">重新回复保险机制</label>
<label class="switch">
<input type="checkbox" id="enableRegenerateConfirmation" name="enableRegenerateConfirmation">
<span class="slider round"></span>
</label>
</div>
</div>
<div class="form-group" id="middleClickAdvancedContainer" style="display: none; margin-bottom: 20px;">
<div class="form-group-inline" style="justify-content: space-between; align-items: center; margin-bottom: 15px;">
<label for="enableMiddleClickAdvanced">启用高级中键九宫格选择</label>
<label class="switch">
<input type="checkbox" id="enableMiddleClickAdvanced" name="enableMiddleClickAdvanced">
<span class="slider round"></span>
</label>
</div>
<div class="form-group" id="middleClickAdvancedSettings" style="display: none; margin-bottom: 15px;">
<label for="middleClickAdvancedDelay">九宫格出现延迟 (毫秒):</label>
<input type="number" id="middleClickAdvancedDelay" name="middleClickAdvancedDelay" min="1000" max="5000" step="100" value="1000" style="width: 100px;">
<small style="color: var(--text-secondary); margin-top: 5px; display: block;">
提示:中键按下后不松开,延迟若干时间 (1000-5000ms) 后出现九宫格选择界面,按住鼠标移动到相关功能后松开即可完成快速设置。
</small>
</div>
</div>
<button type="submit" style="margin-top: 20px;">保存全局设置</button>
</form>
</div>
</div>
</template>
<template id="avatarCropperModalTemplate">
<div class="modal" id="avatarCropperModal">
<div class="modal-content" style="max-width: 420px;"> <!-- Adjusted width for cropper -->
<span class="close-button" onclick="uiHelperFunctions.closeModal('avatarCropperModal'); document.getElementById('agentAvatarInput').value = ''; if(document.getElementById('userAvatarInput')) document.getElementById('userAvatarInput').value = '';">×</span>
<h2>裁剪头像</h2>
<div id="avatarCropperContainer" style="width: 360px; height: 360px; margin: 10px auto; position: relative; border: 1px solid var(--border-color); overflow: hidden; background-color: #ccc;">
<!-- Canvas for the image -->
<canvas id="avatarCanvas" width="360" height="360"></canvas>
<!-- Div for the circular overlay -->
<div id="avatarCropOverlay" style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; cursor: grab;">
<svg width="100%" height="100%" viewBox="0 0 360 360" style="pointer-events: none;"> <!-- SVG itself non-interactive -->
<defs>
<mask id="circleMask">
<rect width="360" height="360" fill="white"/>
<circle id="cropCircle" cx="180" cy="180" r="100" fill="black"/>
</mask>
</defs>
<rect width="360" height="360" fill="rgba(0,0,0,0.5)" mask="url(#circleMask)"/>
<circle id="cropCircleBorder" cx="180" cy="180" r="100" fill="none" stroke="rgba(255,255,255,0.7)" stroke-width="2" stroke-dasharray="5,5"/>
</svg>
</div>
</div>
<div style="text-align: center; margin-top: 0px; margin-bottom:15px; font-size: 0.9em; color: var(--secondary-text);"><small>使用鼠标滚轮缩放, 拖动选区</small></div>
<div class="form-actions" style="margin-top: 10px;">
<button type="button" id="cancelCropBtn" class="sidebar-button" style="background-color: var(--button-bg); color: var(--primary-text);">取消</button>
<button type="button" id="confirmCropBtn" class="sidebar-button" style="background-color: var(--user-bubble-bg); color: white;">确认裁剪</button>
</div>
</div>
</div>
</template>
<template id="createGroupModalTemplate">
<div class="modal" id="createGroupModal">
<div class="modal-content">
<span class="close-button" onclick="uiHelperFunctions.closeModal('createGroupModal')">×</span>
<h2>创建新群组</h2>
<form id="createGroupForm">
<div>
<label for="newGroupNameInput">群组名称:</label>
<input type="text" id="newGroupNameInput" name="groupName" placeholder="请输入群组名称" required>
</div>
<div class="form-actions">
<button type="button" class="button-secondary" onclick="uiHelperFunctions.closeModal('createGroupModal')">取消</button>
<button type="submit" class="button-primary">创建</button>
</div>
</form>
</div>
</div>
</template>
<template id="modelSelectModalTemplate">
<div class="modal" id="modelSelectModal">
<div class="modal-content">
<span class="close-button" onclick="uiHelperFunctions.closeModal('modelSelectModal')">×</span>
<h2>选择模型</h2>
<div class="model-search-container">
<input type="text" id="modelSearchInput" placeholder="搜索模型..." class="model-search-input">
<button type="button" id="refreshModelsBtn" class="small-button" title="刷新模型列表">
<svg data-slot="icon" fill="none" stroke-width="1.5" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" width="16" height="16">
<path stroke-linecap="round" stroke-linejoin="round" d="M16.023 9.348h4.992v-.001M2.985 19.644v-4.992m0 0h4.992m-4.993 0 3.181 3.183a8.25 8.25 0 0 0 11.667 0l3.181-3.183m-4.991-2.691v-2.985h-4.992v2.985h4.992Zm-4.993 0v4.992h4.992v-4.992h-4.992Z"></path>
</svg>
</button>
</div>
<ul id="modelList" class="model-list">
<!-- Models will be dynamically loaded here -->
</ul>
</div>
</div>
</template>
<template id="globalSearchModalTemplate">
<div id="global-search-modal" class="search-modal-overlay" style="display: none;">
<div class="search-modal-content">
<div class="search-modal-header">
<h3>全局搜索</h3>
<button id="global-search-close-button" class="search-modal-close-button">×</button>
</div>
<div class="search-modal-body">
<div class="search-controls">
<select id="global-search-agent-select" class="search-agent-select">
<option value="all">所有助手和群组</option>
</select>
</div>
<textarea id="global-search-input" placeholder="搜索聊天记录 (Ctrl+F)... 支持多行搜索,Ctrl+Enter 或 Shift+Enter 执行搜索" rows="3"></textarea>
<div id="global-search-results"></div>
<div id="global-search-pagination"></div>
</div>
</div>
</div>
</template>
<template id="forwardMessageModalTemplate">
<div class="modal" id="forwardMessageModal">
<div class="modal-content">
<span class="close-button" onclick="uiHelperFunctions.closeModal('forwardMessageModal')">×</span>
<h2>转发消息</h2>
<div id="forward-modal-body">
<div class="form-group">
<label for="forwardTargetSearch">转发给:</label>
<input type="text" id="forwardTargetSearch" placeholder="搜索 Agent 或群组...">
</div>
<ul id="forwardTargetList" class="agent-list">
<!-- Target agents will be populated here -->
</ul>
<div class="form-group">
<label for="forwardAdditionalComment">附加评论 (可选):</label>
<textarea id="forwardAdditionalComment" rows="3" placeholder="例如:你怎么看?"></textarea>
</div>
<div class="form-actions">
<button type="button" class="button-secondary" onclick="uiHelperFunctions.closeModal('forwardMessageModal')">取消</button>
<button type="button" id="confirmForwardBtn" class="button-primary">确认转发</button>
</div>
</div>
</div>
</div>
</template>
<template id="regexRuleModalTemplate">
<div class="modal" id="regexRuleModal">
<div class="modal-content">
<span class="close-button" id="closeRegexRuleModal">×</span>
<h2>编辑正则表达式规则</h2>
<form id="regexRuleForm">
<input type="hidden" id="editingRegexRuleId">
<div>
<label for="regexRuleTitle">规则标题:</label>
<input type="text" id="regexRuleTitle" name="title" placeholder="例如:隐藏VCP内部标签" required>
</div>
<div>
<label for="regexRuleFind">查找内容 (正则表达式):</label>
<textarea id="regexRuleFind" name="findPattern" rows="3" placeholder="例如:/\[VCP.*?\]/g"></textarea>
</div>
<div>
<label for="regexRuleReplace">替换为 (留空则为删除):</label>
<textarea id="regexRuleReplace" name="replaceWith" rows="2" placeholder="例如:[内容已隐藏]"></textarea>
</div>
<div class="form-fieldset">
<label>影响角色:</label>
<div class="checkbox-group">
<label><input type="checkbox" name="applyToRoles" value="assistant"> AI</label>
<label><input type="checkbox" name="applyToRoles" value="user"> 用户</label>
</div>
</div>
<div class="form-fieldset">
<label>影响范围:</label>
<div class="checkbox-group">
<label title="仅影响聊天界面的显示,不改变实际数据">
<input type="checkbox" id="applyToFrontend"> 应用于前端显示
</label>
<label title="仅影响发送给AI的上下文,不改变聊天界面">
<input type="checkbox" id="applyToContext"> 应用于AI上下文
</label>
</div>
<small style="color: var(--text-secondary); margin-top: 5px; display: block;">
提示:可以同时勾选两项,或只勾选其中一项实现特定效果
</small>
</div>
<div class="form-fieldset">
<label>深度控制 (-1代表无限):</label>
<div class="depth-control-group">
<div>
<label for="regexRuleMinDepth">最小深度:</label>
<input type="number" id="regexRuleMinDepth" name="minDepth" value="0" min="-1">
</div>
<div>
<label for="regexRuleMaxDepth">最大深度:</label>
<input type="number" id="regexRuleMaxDepth" name="maxDepth" value="-1" min="-1">
</div>
</div>
</div>
<div class="form-actions">
<button type="button" id="cancelRegexRule" class="button-secondary">取消</button>
<button type="submit" class="button-primary">保存规则</button>
</div>
</form>
</div>
</div>
</template>
<template id="filterRulesModalTemplate">
<div class="modal" id="filterRulesModal">
<div class="modal-content" style="max-width: 800px; max-height: 80vh; overflow-y: auto;">
<span class="close-button" id="closeFilterRulesModal">×</span>
<h2>过滤规则设置</h2>
<div class="filter-rules-header" style="margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 15px;">
<div style="display: flex; align-items: center; gap: 8px; flex: 0 1 auto;">
<span style="font-weight: 500; color: var(--secondary-text); white-space: nowrap;">当前状态:</span>
<span id="filterStatus" style="color: var(--text-secondary); font-size: 0.95em; white-space: nowrap;"></span>
</div>
<button type="button" id="addFilterRuleBtn" class="sidebar-button small-button" style="width: 130px; flex-shrink: 0; margin-left: auto;">添加过滤规则</button>
</div>
<div id="filterRulesList" class="filter-rules-list">
<!-- 过滤规则将在这里动态显示 -->
</div>
<div style="margin-top: 20px; padding-top: 15px; border-top: 1px solid var(--border-color);">
<div style="font-size: 0.9em; color: var(--text-secondary);">
<p><strong>使用说明:</strong></p>
<p>• <strong>过滤总开关关闭:</strong>显示所有通知</p>
<p>• <strong>过滤总开关开启:</strong>只显示白名单规则匹配的消息,其他消息都被过滤掉</p>
<p>• <strong>停留时间:</strong>可设置每条规则对应的通知显示时长,支持永久显示</p>
</div>
</div>
</div>
</div>
</template>
<template id="filterRuleEditorModalTemplate">
<div class="modal" id="filterRuleEditorModal">
<div class="modal-content">
<span class="close-button" id="closeFilterRuleEditorModal">×</span>
<h2 id="filterRuleEditorTitle">添加过滤规则</h2>
<form id="filterRuleEditorForm">
<input type="hidden" id="editingFilterRuleId">
<div>
<label for="filterRuleName">规则名称:</label>
<input type="text" id="filterRuleName" name="name" placeholder="例如:系统消息过滤" required>
</div>
<div class="form-fieldset">
<label>规则类型:</label>
<div class="radio-group">
<label for="ruleTypeWhitelist" style="display: flex; align-items: center; gap: 5px;">
<input type="radio" id="ruleTypeWhitelist" name="ruleType" value="whitelist" checked>
白名单(总是显示匹配的消息)
</label>
</div>
</div>
<div>
<label for="filterRulePattern">匹配模式:</label>
<input type="text" id="filterRulePattern" name="pattern" placeholder="消息标题中包含的关键字或正则表达式" required>
<small style="color: var(--text-secondary); margin-top: 5px; display: block;">
支持简单的关键字匹配或正则表达式(无需/包围)
</small>
</div>
<div class="form-fieldset">
<label>匹配位置:</label>
<div class="checkbox-group">
<label><input type="checkbox" name="matchPosition" value="start"> 标题开头</label>
<label><input type="checkbox" name="matchPosition" value="end"> 标题结尾</label>
<label><input type="checkbox" name="matchPosition" value="contain"> 标题包含</label>
</div>
</div>
<div>
<label for="filterRuleDuration">消息停留时间(秒):</label>
<div style="display: flex; align-items: center; gap: 10px;">
<input type="number" id="filterRuleDuration" name="duration" min="0" max="300" value="7" style="width: 80px;" oninput="this.value = Math.max(0, Math.min(300, parseInt(this.value) || 0))">
<span>秒</span>
<label for="filterRuleDurationInfinite" style="display: flex; align-items: center; gap: 5px;">
<input type="checkbox" id="filterRuleDurationInfinite" name="durationInfinite">
永久显示(不自动消失)
</label>
</div>
<small style="color: var(--text-secondary); margin-top: 5px; display: block;">
设为0表示立即消失,1-300秒表示停留指定时间后消失,勾选永久显示则不自动消失
</small>
</div>
<div class="form-fieldset">
<label for="filterRuleEnabled" style="display: flex; align-items: center; gap: 5px;">
<input type="checkbox" id="filterRuleEnabled" name="enabled" checked>
启用此规则
</label>
</div>
<div class="form-actions">
<button type="button" id="cancelFilterRuleEditor" class="button-secondary">取消</button>
<button type="submit" class="button-primary">保存规则</button>
</div>
</form>
</div>
</div>
</template>