Skip to content

Commit 3cd5fed

Browse files
committed
feat(ui): 新增浅深色主题切换并统一界面配色
- 新增主题 store 与本地持久化能力,支持侧边栏切换浅色/深色模式 - 将聊天页、会话列表、标题栏、弹窗等配色改为 CSS 变量统一管理 - 适配定位卡片、引用气泡、系统提示等聊天消息组件在不同主题下的可读性 - 同步整理首页、解密页、联系人页、朋友圈页等页面背景与交互样式
1 parent 0a4d30e commit 3cd5fed

26 files changed

Lines changed: 1928 additions & 147 deletions

frontend/app.vue

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,18 @@
3030
</template>
3131

3232
<script setup>
33+
import { useThemeStore } from '~/stores/theme'
3334
import { useChatAccountsStore } from '~/stores/chatAccounts'
3435
import { usePrivacyStore } from '~/stores/privacy'
3536
3637
const route = useRoute()
3738
const desktopUpdate = useDesktopUpdate()
3839
const { open: settingsDialogOpen, closeDialog: closeSettingsDialog } = useSettingsDialog()
40+
const themeStore = useThemeStore()
41+
42+
if (process.client) {
43+
themeStore.init()
44+
}
3945
4046
// In Electron the server/pre-render doesn't know about `window.wechatDesktop`.
4147
// If we render different DOM on server vs client, Vue hydration will keep the
@@ -71,14 +77,15 @@ onMounted(() => {
7177
const privacy = usePrivacyStore()
7278
void chatAccounts.ensureLoaded()
7379
privacy.init()
80+
themeStore.init()
7481
})
7582
7683
onBeforeUnmount(() => {
7784
window.removeEventListener('resize', updateDprVar)
7885
})
7986
8087
const rootClass = computed(() => {
81-
const base = 'bg-gradient-to-br from-green-50 via-emerald-50 to-green-100'
88+
const base = 'theme-app-shell'
8289
return isDesktop.value
8390
? `wechat-desktop h-screen flex overflow-hidden ${base}`
8491
: `h-screen flex overflow-hidden ${base}`
@@ -126,4 +133,15 @@ const showSidebar = computed(() => {
126133
.wechat-desktop .wechat-desktop-content > .min-h-screen {
127134
min-height: 100%;
128135
}
136+
137+
.theme-app-shell {
138+
background:
139+
radial-gradient(circle at top left, rgba(7, 193, 96, 0.08), transparent 32%),
140+
radial-gradient(circle at top right, rgba(16, 174, 239, 0.08), transparent 36%),
141+
linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 45%, #dcfce7 100%);
142+
}
143+
144+
html[data-theme='dark'] .theme-app-shell {
145+
background: var(--app-shell-bg);
146+
}
129147
</style>

frontend/assets/css/chat.css

Lines changed: 54 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,17 @@
3333
}
3434

3535
.overflow-y-auto::-webkit-scrollbar-track {
36-
background: #f1f1f1;
36+
background: var(--scrollbar-track);
3737
border-radius: 3px;
3838
}
3939

4040
.overflow-y-auto::-webkit-scrollbar-thumb {
41-
background: #c1c1c1;
41+
background: var(--scrollbar-thumb);
4242
border-radius: 3px;
4343
}
4444

4545
.overflow-y-auto::-webkit-scrollbar-thumb:hover {
46-
background: #a1a1a1;
46+
background: var(--scrollbar-thumb-hover);
4747
}
4848

4949
/* 会话列表宽度:按物理像素(px)配置,按 dpr 换算为 CSS px */
@@ -75,7 +75,25 @@
7575

7676
.session-list-resizer:hover::after,
7777
.session-list-resizer-active::after {
78-
background: rgba(0, 0, 0, 0.12);
78+
background: var(--session-list-resizer);
79+
}
80+
81+
.msg-bubble.bubble-tail-r {
82+
background-color: var(--chat-bubble-sent) !important;
83+
color: var(--chat-bubble-sent-text) !important;
84+
}
85+
86+
.msg-bubble.bubble-tail-l {
87+
background-color: var(--chat-bubble-received) !important;
88+
color: var(--chat-bubble-received-text) !important;
89+
}
90+
91+
.bubble-tail-r::after {
92+
background: var(--chat-bubble-sent);
93+
}
94+
95+
.bubble-tail-l::after {
96+
background: var(--chat-bubble-received);
7997
}
8098

8199
/* 消息气泡样式 */
@@ -87,7 +105,7 @@
87105

88106
/* 发送的消息(右侧绿色气泡) */
89107
.sent-message {
90-
background-color: #95EB69 !important;
108+
background-color: var(--chat-bubble-sent) !important;
91109
border-radius: var(--message-radius);
92110
}
93111

@@ -99,13 +117,13 @@
99117
transform: translateY(-50%) rotate(45deg);
100118
width: 10px;
101119
height: 10px;
102-
background-color: #95EB69;
120+
background-color: var(--chat-bubble-sent);
103121
border-radius: 2px;
104122
}
105123

106124
/* 接收的消息(左侧白色气泡) */
107125
.received-message {
108-
background-color: white !important;
126+
background-color: var(--chat-bubble-received) !important;
109127
border-radius: var(--message-radius);
110128
}
111129

@@ -117,7 +135,7 @@
117135
transform: translateY(-50%) rotate(45deg);
118136
width: 10px;
119137
height: 10px;
120-
background-color: white;
138+
background-color: var(--chat-bubble-received);
121139
border-radius: 2px;
122140
}
123141

@@ -172,7 +190,7 @@
172190
transform: translateY(-50%) rotate(45deg);
173191
width: 10px;
174192
height: 10px;
175-
background-color: #95EC69;
193+
background-color: var(--chat-bubble-sent);
176194
border-radius: 2px;
177195
}
178196

@@ -188,7 +206,7 @@
188206
transform: translateY(-50%) rotate(45deg);
189207
width: 10px;
190208
height: 10px;
191-
background-color: white;
209+
background-color: var(--chat-bubble-received);
192210
border-radius: 2px;
193211
}
194212

@@ -216,7 +234,8 @@
216234
}
217235

218236
.wechat-voice-sent {
219-
background: #95EC69;
237+
background: var(--chat-bubble-sent);
238+
color: var(--chat-bubble-sent-text);
220239
}
221240

222241
.wechat-voice-sent::after {
@@ -227,12 +246,13 @@
227246
transform: translateY(-50%) rotate(45deg);
228247
width: 10px;
229248
height: 10px;
230-
background: #95EC69;
249+
background: var(--chat-bubble-sent);
231250
border-radius: 2px;
232251
}
233252

234253
.wechat-voice-received {
235-
background: white;
254+
background: var(--chat-bubble-received);
255+
color: var(--chat-bubble-received-text);
236256
}
237257

238258
.wechat-voice-received::before {
@@ -243,7 +263,7 @@
243263
transform: translateY(-50%) rotate(45deg);
244264
width: 10px;
245265
height: 10px;
246-
background: white;
266+
background: var(--chat-bubble-received);
247267
border-radius: 2px;
248268
}
249269

@@ -259,7 +279,7 @@
259279
width: 18px;
260280
height: 18px;
261281
flex-shrink: 0;
262-
color: #1a1a1a;
282+
color: currentColor;
263283
}
264284

265285
.wechat-quote-voice-icon {
@@ -293,7 +313,7 @@
293313

294314
.wechat-voice-duration {
295315
font-size: 14px;
296-
color: #1a1a1a;
316+
color: inherit;
297317
}
298318

299319
.wechat-voice-unread {
@@ -315,7 +335,8 @@
315335
}
316336

317337
.wechat-voip-sent {
318-
background: #95EC69;
338+
background: var(--chat-bubble-sent);
339+
color: var(--chat-bubble-sent-text);
319340
}
320341

321342
.wechat-voip-sent::after {
@@ -326,12 +347,13 @@
326347
transform: translateY(-50%) rotate(45deg);
327348
width: 10px;
328349
height: 10px;
329-
background: #95EC69;
350+
background: var(--chat-bubble-sent);
330351
border-radius: 2px;
331352
}
332353

333354
.wechat-voip-received {
334-
background: white;
355+
background: var(--chat-bubble-received);
356+
color: var(--chat-bubble-received-text);
335357
}
336358

337359
.wechat-voip-received::before {
@@ -342,7 +364,7 @@
342364
transform: translateY(-50%) rotate(45deg);
343365
width: 10px;
344366
height: 10px;
345-
background: white;
367+
background: var(--chat-bubble-received);
346368
border-radius: 2px;
347369
}
348370

@@ -362,7 +384,7 @@
362384

363385
.wechat-voip-text {
364386
font-size: 14px;
365-
color: #1a1a1a;
387+
color: inherit;
366388
}
367389

368390
/* 统一特殊消息尾巴(红包 / 文件等) */
@@ -390,14 +412,14 @@
390412

391413
.wechat-chat-history-card {
392414
width: 210px;
393-
background: #ffffff;
415+
background: var(--merged-history-bg);
394416
border-radius: var(--message-radius);
395417
cursor: pointer;
396418
transition: background-color 0.15s ease;
397419
}
398420

399421
.wechat-chat-history-card:hover {
400-
background: #f5f5f5;
422+
background: var(--merged-history-hover);
401423
}
402424

403425
.wechat-chat-history-body {
@@ -407,13 +429,13 @@
407429
.wechat-chat-history-title {
408430
font-size: 14px;
409431
font-weight: 400;
410-
color: #161616;
432+
color: var(--merged-history-title);
411433
margin-bottom: 6px;
412434
}
413435

414436
.wechat-chat-history-preview {
415437
font-size: 12px;
416-
color: #6b7280;
438+
color: var(--merged-history-preview);
417439
line-height: 1.4;
418440
}
419441

@@ -439,12 +461,17 @@
439461
left: 13px;
440462
right: 13px;
441463
height: 1.5px;
442-
background: #e8e8e8;
464+
background: var(--merged-history-divider);
443465
}
444466

445467
.wechat-chat-history-bottom span {
446468
font-size: 12px;
447-
color: #b2b2b2;
469+
color: var(--merged-history-footer);
470+
}
471+
472+
.wechat-quote-preview {
473+
background: var(--quote-bubble-bg);
474+
color: var(--quote-bubble-text);
448475
}
449476

450477
/* 转账消息样式 - 微信风格 */

0 commit comments

Comments
 (0)