-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
4681 lines (4028 loc) · 186 KB
/
index.html
File metadata and controls
4681 lines (4028 loc) · 186 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>
<!-- 国外源 -->
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>赛博女友 另一个时空的她 v1.0.0</title>
<link rel="icon" type="image/x-icon" href="./resource/ico.png">
<link rel="icon" type="image/png" sizes="16x16" href="./resource/ico.png">
<link rel="icon" type="image/png" sizes="32x32" href="./resource/ico.png">
<link rel="apple-touch-icon" sizes="180x180" href="./resource/ico.png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script type="module">
// Firebase v10+ CDN ESM 初始化(请替换为你的真实配置)
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.12.3/firebase-app.js';
import { getAuth, onAuthStateChanged, createUserWithEmailAndPassword, signInWithEmailAndPassword, signOut, updateProfile } from 'https://www.gstatic.com/firebasejs/10.12.3/firebase-auth.js';
import { getFirestore, doc, setDoc, getDoc, collection, addDoc, getDocs, query, where, updateDoc, deleteDoc, onSnapshot, orderBy, limit, limitToLast, endBefore, startAfter, serverTimestamp } from 'https://www.gstatic.com/firebasejs/10.12.3/firebase-firestore.js';
window.__firebase = { ready: false };
const firebaseConfig = {
apiKey: "AIzaSyDHNpPbI1Pm7O9EnaCvhnFqov3l6WvSUxI",
authDomain: "ai-grilfirend.firebaseapp.com",
projectId: "ai-grilfirend",
storageBucket: "ai-grilfirend.firebasestorage.app",
messagingSenderId: "56625080751",
appId: "1:56625080751:web:35d082aa26167312e6e75a",
measurementId: "G-T75JFYKP1P"
};
try {
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
const db = getFirestore(app);
// 将Firestore函数暴露到全局
window.__firebase = {
app,
auth,
db,
ready: true,
firestore: {
doc,
collection,
getDocs,
query,
orderBy,
getDoc,
updateDoc,
deleteDoc,
serverTimestamp,
setDoc,
addDoc,
where
}
};
onAuthStateChanged(auth, async (user) => {
window.__currentUser = user || null;
document.dispatchEvent(new CustomEvent('auth:changed', { detail: { user } }));
});
} catch (e) {
console.warn('Firebase 初始化失败,自动降级为游客模式:', e);
}
// 暴露常用方法(供下方非 module 脚本调用)
window.__fbApi = {
// 获取所有用户(仅超级管理员)
async adminGetAllUsers() {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) throw new Error('未登录');
const profile = await this.getUserProfile();
if (!profile || profile.role !== 'superadmin') throw new Error('需要超级管理员权限');
const qSnap = await getDocs(collection(db, 'users'));
return qSnap.docs.map(d => ({ id: d.id, ...d.data() }));
},
// 更新用户角色(仅超级管理员)
async adminUpdateUserRole(userId, newRole) {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) throw new Error('未登录');
const profile = await this.getUserProfile();
if (!profile || profile.role !== 'superadmin') throw new Error('需要超级管理员权限');
// 不能修改自己的角色
if (userId === user.uid) {
throw new Error('不能修改自己的角色');
}
await updateDoc(doc(db, 'users', userId), {
role: newRole
});
},
// 删除用户(仅超级管理员)
async adminDeleteUser(userId) {
const { db, auth } = window.__firebase;
const user = window.__currentUser;
if (!user) throw new Error('未登录');
const profile = await this.getUserProfile();
if (!profile || profile.role !== 'superadmin') throw new Error('需要超级管理员权限');
// 不能删除自己
if (userId === user.uid) {
throw new Error('不能删除自己');
}
// 删除用户的所有对话
const conversationsRef = collection(db, 'users', userId, 'conversations');
const convSnap = await getDocs(conversationsRef);
for (const convDoc of convSnap.docs) {
// 删除对话中的所有消息
const messagesRef = collection(db, 'users', userId, 'conversations', convDoc.id, 'messages');
const messagesSnap = await getDocs(messagesRef);
for (const msgDoc of messagesSnap.docs) {
await deleteDoc(doc(db, 'users', userId, 'conversations', convDoc.id, 'messages', msgDoc.id));
}
// 删除对话
await deleteDoc(doc(db, 'users', userId, 'conversations', convDoc.id));
}
// 删除用户设置
try {
await deleteDoc(doc(db, 'users', userId, 'meta', 'settings'));
} catch (e) {
console.log('用户设置不存在,跳过删除');
}
// 删除用户档案
await deleteDoc(doc(db, 'users', userId));
console.log('用户Firestore数据已删除');
},
// 获取用户对话(仅超级管理员)
async adminGetUserConversations(userId) {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) throw new Error('未登录');
const profile = await this.getUserProfile();
if (!profile || profile.role !== 'superadmin') throw new Error('需要超级管理员权限');
const conversationsRef = collection(db, 'users', userId, 'conversations');
const q = query(conversationsRef, orderBy('updatedAt', 'desc'));
const qSnap = await getDocs(q);
return qSnap.docs.map(d => ({ id: d.id, ...d.data() }));
},
// 删除对话(仅超级管理员)
async adminDeleteConversation(userId, conversationId) {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) throw new Error('未登录');
const profile = await this.getUserProfile();
if (!profile || profile.role !== 'superadmin') throw new Error('需要超级管理员权限');
// 删除对话中的所有消息
const messagesRef = collection(db, 'users', userId, 'conversations', conversationId, 'messages');
const messagesSnap = await getDocs(messagesRef);
for (const msgDoc of messagesSnap.docs) {
await deleteDoc(doc(db, 'users', userId, 'conversations', conversationId, 'messages', msgDoc.id));
}
// 删除对话
await deleteDoc(doc(db, 'users', userId, 'conversations', conversationId));
},
// 生成key(管理员和超级管理员都可以)
async adminAddKey({ account }) {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) throw new Error('未登录');
const profile = await this.getUserProfile();
if (!profile || (profile.role !== 'admin' && profile.role !== 'superadmin')) throw new Error('需要管理员权限');
console.log('Hello ' + profile.role + ' ' + user.displayName);
const randomKey = Math.random().toString(36).slice(2, 10).toUpperCase();
await addDoc(collection(db, 'keys'), {
key: randomKey,
account: account || '',
username: '',
used: false,
usedBy: '',
createdAt: Date.now()
});
return randomKey;
},
// 列出所有key(管理员和超级管理员都可以)
async adminListKeys() {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) throw new Error('未登录');
const profile = await this.getUserProfile();
if (!profile || (profile.role !== 'admin' && profile.role !== 'superadmin')) throw new Error('需要管理员权限');
const qSnap = await getDocs(collection(db, 'keys'));
return qSnap.docs.map(d => ({ id: d.id, ...d.data() }));
},
// 删除key(管理员和超级管理员都可以)
async adminDeleteKeys(ids = []) {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) throw new Error('未登录');
const profile = await this.getUserProfile();
if (!profile || (profile.role !== 'admin' && profile.role !== 'superadmin')) throw new Error('需要管理员权限');
await Promise.all(ids.map(id => deleteDoc(doc(db, 'keys', id))));
},
// 在 window.__fbApi 的 register 方法中修改
async register({ account, username, password, confirmPassword, inviteKey }) {
const { auth, db, ready } = window.__firebase;
if (!ready) throw new Error('Firebase 未初始化');
if (!account || !username || !password || !confirmPassword) throw new Error('请填写完整信息');
if (password !== confirmPassword) throw new Error('两次密码不一致');
const isRoot = username.trim().toLowerCase() === 'root';
// 检查是否已存在root用户
if (isRoot) {
const rootQuery = query(collection(db, 'users'), where('username', '==', 'root'));
const rootSnap = await getDocs(rootQuery);
if (!rootSnap.empty) {
throw new Error('root用户已存在,无法再次注册');
}
}
if (!isRoot) {
if (!inviteKey) throw new Error('需要邀请码');
// 校验 key 是否存在且未使用
const q = query(collection(db, 'keys'), where('key', '==', inviteKey));
const snap = await getDocs(q);
if (snap.empty) throw new Error('邀请码不存在');
const keyDoc = snap.docs[0];
const keyData = keyDoc.data();
if (keyData.used) throw new Error('邀请码已被使用');
}
// 使用账号作为邮箱前缀(本地演示:构造伪邮箱)
const email = `${account}@example.com`;
const cred = await createUserWithEmailAndPassword(auth, email, password);
await updateProfile(cred.user, { displayName: username });
// 写入用户档案
await setDoc(doc(db, 'users', cred.user.uid), {
account,
username,
role: isRoot ? 'superadmin' : 'user', // 只有root用户设为superadmin
createdAt: Date.now()
});
if (!isRoot) {
// 绑定 key
const q2 = query(collection(db, 'keys'), where('key', '==', inviteKey));
const snap2 = await getDocs(q2);
const keyDoc2 = snap2.docs[0];
await updateDoc(doc(db, 'keys', keyDoc2.id), {
used: true,
usedBy: cred.user.uid,
usedAt: Date.now(),
account: account,
username: username
});
}
return cred.user;
},
async login({ account, password }) {
const { auth, ready } = window.__firebase;
if (!ready) throw new Error('Firebase 未初始化');
const email = `${account}@example.com`;
const cred = await signInWithEmailAndPassword(auth, email, password);
return cred.user;
},
async logout() {
const { auth, ready } = window.__firebase;
if (!ready) return;
await signOut(auth);
},
async getUserProfile() {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) return null;
const snap = await getDoc(doc(db, 'users', user.uid));
return snap.exists() ? snap.data() : null;
},
// 确保会话文档存在
async ensureConversation(conversationId, title = '对话') {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) return null;
const convRef = doc(db, 'users', user.uid, 'conversations', String(conversationId));
const snap = await getDoc(convRef);
if (!snap.exists()) {
await setDoc(convRef, {
title: title,
createdAt: serverTimestamp(),
updatedAt: serverTimestamp()
});
}
return convRef;
},
// 保存消息
async saveMessage(conversationId, { role, content, time }) {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) return;
const convRef = await this.ensureConversation(conversationId);
await addDoc(collection(convRef, 'messages'), {
role,
content,
time,
createdAt: serverTimestamp()
});
await updateDoc(convRef, { updatedAt: serverTimestamp() });
},
// 订阅最新消息(实时)
subscribeLatest(conversationId, pageSize, onChange) {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) return () => {};
const convRef = doc(db, 'users', user.uid, 'conversations', String(conversationId));
const qLatest = query(collection(convRef, 'messages'), orderBy('createdAt', 'asc'), limitToLast(pageSize));
return onSnapshot(qLatest, (snapshot) => {
const docs = snapshot.docs.map(d => ({ id: d.id, ...d.data(), _snap: d }));
onChange(docs);
});
},
// 在 window.__fbApi 对象中修改 loadOlder 方法
async loadOlder(conversationId, firstDocSnap, pageSize) {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user || !firstDocSnap) {
console.log('loadOlder: 用户未登录或没有快照');
return { items: [], first: null };
}
try {
const convRef = doc(db, 'users', user.uid, 'conversations', String(conversationId));
const qOlder = query(
collection(convRef, 'messages'),
orderBy('createdAt', 'asc'),
endBefore(firstDocSnap),
limitToLast(pageSize)
);
const snap = await getDocs(qOlder);
const items = snap.docs.map(d => ({ id: d.id, ...d.data(), _snap: d }));
console.log('loadOlder 查询结果:', {
conversationId,
pageSize,
returnedCount: items.length,
hasDocs: !snap.empty
});
return {
items,
first: snap.docs[0] || null // 返回新的第一条消息的快照
};
} catch (error) {
console.error('loadOlder 错误:', error);
throw error;
}
},
// 保存/读取设置
async saveSettings(settings) {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) {
localStorage.setItem('settings:guest', JSON.stringify(settings));
return;
}
await setDoc(doc(db, 'users', user.uid, 'meta', 'settings'), settings, { merge: true });
},
async loadSettings() {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) {
const raw = localStorage.getItem('settings:guest');
return raw ? JSON.parse(raw) : null;
}
const snap = await getDoc(doc(db, 'users', user.uid, 'meta', 'settings'));
return snap.exists() ? snap.data() : null;
},
// 在 window.__fbApi 对象中添加删除对话的方法
async deleteConversation(conversationId) {
const { db } = window.__firebase;
const user = window.__currentUser;
if (!user) throw new Error('未登录');
// 删除对话中的所有消息
const messagesRef = collection(db, 'users', user.uid, 'conversations', conversationId, 'messages');
const messagesSnap = await getDocs(messagesRef);
for (const msgDoc of messagesSnap.docs) {
await deleteDoc(doc(db, 'users', user.uid, 'conversations', conversationId, 'messages', msgDoc.id));
}
// 删除对话本身
await deleteDoc(doc(db, 'users', user.uid, 'conversations', conversationId));
}
};
</script>
<style>
/* ===== CSS 变量定义 ===== */
:root {
--primary-color: #ff6b9d;
--secondary-color: #ffa8cb;
--bg-color: #fff5f9;
--sidebar-bg: #ffeef5;
--text-color: #333;
--light-text: #666;
--border-color: #ffd6e6;
--user-msg-bg: #ff6b9d;
--ai-msg-bg: #f0f0f0;
--shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
--sidebar-width: 280px;
--header-height: 70px;
--mobile-header-height: 60px;
--mobile-input-height: 80px;
}
/* ===== 基础样式 ===== */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
-webkit-tap-highlight-color: transparent;
}
body {
background-color: var(--bg-color);
color: var(--text-color);
height: 100vh;
overflow: hidden;
position: relative;
}
/* ===== 背景视频 ===== */
#background-video {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
object-fit: cover;
opacity: 0.5;
z-index: -1;
}
/* ===== 移动端遮罩 ===== */
.mobile-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 90;
display: none;
}
/* ===== 侧边栏样式 ===== */
.sidebar {
position: fixed;
left: 0;
top: 0;
width: var(--sidebar-width);
height: 100vh;
background-color: var(--sidebar-bg);
border-right: 1px solid var(--border-color);
display: flex;
flex-direction: column;
padding: 20px;
overflow-y: auto;
transition: transform 0.3s ease;
z-index: 100;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}
.sidebar.collapsed {
transform: translateX(-100%);
}
.sidebar.open {
transform: translateX(0);
}
/* 侧边栏logo */
.logo {
display: flex;
align-items: center;
margin-bottom: 30px;
padding-bottom: 15px;
border-bottom: 1px solid var(--border-color);
}
.logo-icon {
width: 40px;
height: 40px;
background-color: var(--primary-color);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 10px;
color: white;
}
.logo h1 {
font-size: 1.4rem;
font-weight: 600;
color: var(--primary-color);
}
/* 侧边栏按钮组 */
.user-buttons-group {
display: flex;
flex-direction: column;
gap: 8px;
margin-bottom: 15px;
width: 100%;
}
.button-with-tag {
position: relative;
width: 100%;
}
/* 统一侧边栏按钮样式 */
.new-chat-btn,
.settings-btn,
.auth-btn,
.admin-btn {
background-color: var(--primary-color);
color: white;
border: none;
padding: 12px 16px;
border-radius: 10px;
font-size: 1rem;
font-weight: 500;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 12px;
transition: all 0.3s ease;
width: 100%;
box-shadow: var(--shadow);
}
.new-chat-btn:hover,
.settings-btn:hover,
.auth-btn:hover,
.admin-btn:hover {
background-color: #ff4d8a;
transform: translateY(-2px);
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}
.new-chat-btn:active,
.settings-btn:active,
.auth-btn:active,
.admin-btn:active {
transform: translateY(0);
}
.new-chat-btn i,
.settings-btn i,
.auth-btn i,
.admin-btn i {
margin-right: 8px;
font-size: 1rem;
}
/* 特殊按钮样式 */
#refresh-conversations {
background-color: var(--secondary-color);
margin-top: 8px;
}
#refresh-conversations:hover {
background-color: #ff8cb8;
}
.user-buttons-group .settings-btn {
margin-bottom: 0;
}
/* 对话历史区域 */
.chat-history {
flex-grow: 1;
overflow-y: auto;
}
.history-item {
padding: 12px 15px;
border-radius: 10px;
margin-bottom: 8px;
cursor: pointer;
transition: all 0.2s ease;
display: flex;
align-items: center;
}
.history-item:hover {
background-color: #ffd6e6;
}
.history-item.active {
background-color: var(--primary-color);
color: white;
}
.history-item i {
margin-right: 10px;
}
/* 空白状态样式 */
.empty-state {
padding: 20px;
text-align: center;
color: var(--light-text);
}
.empty-state i {
font-size: 2rem;
margin-bottom: 10px;
opacity: 0.5;
}
.empty-state p {
margin: 0;
font-size: 0.9rem;
}
/* ===== 主聊天区域样式 ===== */
.chat-container {
margin-left: 0;
width: 100%;
display: flex;
flex-direction: column;
height: 100vh;
transition: margin-left 0.3s ease;
}
.chat-container.sidebar-open {
margin-left: 0;
width: 100%;
}
/* 聊天头部 */
.chat-header {
padding: 15px 20px;
border-bottom: 1px solid var(--border-color);
display: flex;
align-items: center;
background-color: white;
height: var(--header-height);
position: relative;
z-index: 10;
transition: margin-left 0.3s ease, width 0.3s ease;
}
.toggle-sidebar {
background: none;
border: none;
font-size: 1.5rem;
color: var(--primary-color);
cursor: pointer;
margin-right: 15px;
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
}
.toggle-sidebar:hover {
background-color: #ffd6e6;
}
.gf-avatar {
width: 50px;
height: 50px;
border-radius: 50%;
background-color: var(--secondary-color);
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 1.5rem;
margin-right: 15px;
}
.gf-info h2 {
font-size: 1.3rem;
font-weight: 600;
margin-bottom: 5px;
}
.gf-info p {
color: var(--light-text);
font-size: 0.9rem;
}
/* 消息区域 */
.chat-messages {
flex-grow: 1;
padding: 20px;
overflow-y: auto;
display: flex;
flex-direction: column;
max-width: 1250px;
margin: 0 auto;
width: 100%;
scrollbar-width: thin;
scrollbar-color: var(--primary-color) transparent;
padding-bottom: 100px;
transition: margin-left 0.3s ease, width 0.3s ease;
}
.chat-messages::-webkit-scrollbar {
width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
background-color: var(--primary-color);
border-radius: 3px;
}
/* 加载更多按钮 */
.load-more {
display: none;
margin: 10px auto 0;
padding: 6px 12px;
font-size: 0.9rem;
border: 1px solid var(--border-color);
border-radius: 8px;
background: #fff;
cursor: pointer;
}
/* 消息样式 */
.message {
max-width: 85%;
padding: 15px 18px;
border-radius: 18px;
margin-bottom: 15px;
line-height: 1.6;
position: relative;
box-shadow: var(--shadow);
word-wrap: break-word;
}
.user-message {
align-self: flex-end;
background-color: var(--user-msg-bg);
color: white;
border-bottom-right-radius: 5px;
}
.ai-message {
align-self: flex-start;
background-color: var(--ai-msg-bg);
border-bottom-left-radius: 5px;
}
.message-time {
font-size: 0.75rem;
margin-top: 8px;
opacity: 0.7;
}
/* Markdown内容样式 */
.message.ai-message code {
background-color: rgba(0, 0, 0, 0.1);
padding: 2px 4px;
border-radius: 3px;
font-family: 'Courier New', monospace;
}
.message.ai-message pre {
background-color: rgba(0, 0, 0, 0.05);
padding: 10px;
border-radius: 5px;
overflow-x: auto;
margin: 10px 0;
}
.message.ai-message pre code {
background: none;
padding: 0;
}
.message.ai-message blockquote {
border-left: 3px solid var(--secondary-color);
padding-left: 10px;
margin: 10px 0;
color: var(--light-text);
}
.message.ai-message ul,
.message.ai-message ol {
padding-left: 20px;
margin: 10px 0;
}
.message.ai-message li {
margin: 5px 0;
}
.message.ai-message table {
border-collapse: collapse;
width: 100%;
margin: 10px 0;
}
.message.ai-message th,
.message.ai-message td {
border: 1px solid var(--border-color);
padding: 8px;
text-align: left;
}
.message.ai-message th {
background-color: rgba(255, 107, 157, 0.1);
}
/* 思考标签样式 */
.thinking-section {
border-left: 3px solid var(--secondary-color);
padding-left: 10px;
font-size: 0.9em;
background: rgba(255, 168, 203, 0.1) !important;
margin-bottom: 10px;
border-radius: 8px;
padding: 10px;
}
/* 打字指示器 */
.typing-indicator {
display: none;
align-self: flex-start;
background-color: var(--ai-msg-bg);
padding: 15px 20px;
border-radius: 18px;
border-bottom-left-radius: 5px;
margin-bottom: 20px;
box-shadow: var(--shadow);
}
.typing-dots {
display: flex;
}
.typing-dots span {
height: 8px;
width: 8px;
border-radius: 50%;
background-color: var(--light-text);
display: block;
margin: 0 2px;
opacity: 0.4;
animation: typing 1s infinite;
}
.typing-dots span:nth-child(2) {
animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
animation-delay: 0.4s;
}
@keyframes typing {
0%, 100% {
transform: translateY(0);
opacity: 0.4;
}
50% {
transform: translateY(-5px);
opacity: 1;
}
}
/* 流式消息样式 */
.streaming-message {
position: relative;
}
.streaming-message::after {
content: '|';
animation: blink 1s infinite;
color: var(--primary-color);
margin-left: 2px;
}
@keyframes blink {
0%, 50% { opacity: 1; }
51%, 100% { opacity: 0; }
}
/* ===== 输入区域样式 ===== */
.chat-input-container {
position: fixed;
bottom: 0;
left: 0;
right: 0;
z-index: 10;
padding: 15px 20px;
border-top: 1px solid var(--border-color);
background-color: white;
display: flex;
justify-content: center;
box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.05);
transition: left 0.3s ease, width 0.3s ease;
padding-top: 25px; /* 为思考标签留出空间 */
}
.chat-input-wrapper {
display: flex;
background-color: #f9f9f9;
border-radius: 25px;
padding: 12px 15px;
box-shadow: var(--shadow);
max-width: 1250px;
width: 100%;
align-items: flex-end;
transition: max-width 0.3s ease;
position: relative;
}
.chat-input {
flex-grow: 1;
border: none;
background: transparent;
padding: 10px 0;
font-size: 1rem;
outline: none;
resize: none;
max-height: 150px;
min-height: 40px;
line-height: 1.4;
}
.send-btn {
background-color: var(--primary-color);
color: white;
border: none;
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
margin-left: 10px;
transition: all 0.3s ease;
flex-shrink: 0;
}
.send-btn:hover {
background-color: #ff4d8a;
transform: scale(1.05);
}
.send-btn:disabled {
background-color: var(--secondary-color);
cursor: not-allowed;
transform: none;
}
/* 思考标签容器 */
.thinking-tag-container {
position: absolute;
top: -30px;
left: 0;
right: 0;
text-align: center;
pointer-events: none;
}