feat: add dark theme support with CSS custom properties and Naive UI integration

Implement runtime theme switching using CSS custom properties delegated through SCSS variables, with light/dark/system modes, FOUC prevention, sidebar toggle, and settings selector. Add theme-aware video assets for sidebar and chat thinking indicator.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ekko
2026-04-16 23:13:04 +08:00
parent 076a7c2a38
commit b5aeb876b8
32 changed files with 465 additions and 126 deletions
@@ -331,7 +331,7 @@ function isImage(type: string): boolean {
border-radius: 50%;
border: none;
background: rgba(0, 0, 0, 0.5);
color: #fff;
color: var(--text-on-overlay);
display: flex;
align-items: center;
justify-content: center;
@@ -394,8 +394,8 @@ function isImage(type: string): boolean {
// Drag-over state
.input-wrapper.drag-over {
border-color: #4a90d9;
border-color: var(--accent-info);
border-style: dashed;
background-color: rgba(74, 144, 217, 0.04);
background-color: rgba(var(--accent-info-rgb), 0.04);
}
</style>
@@ -105,7 +105,7 @@ const renderedHtml = computed(() => md.render(props.content))
}
th {
background: rgba($accent-primary, 0.08);
background: rgba(var(--accent-primary-rgb), 0.08);
color: $text-primary;
font-weight: 600;
}
@@ -189,4 +189,20 @@ const renderedHtml = computed(() => md.render(props.content))
.hljs-title\.function_ { color: #1a1a1a; }
.hljs-params { color: #2a2a2a; }
.hljs-meta { color: #999999; }
// Dark mode highlight.js — inverted pure ink
.dark .hljs { color: #d0d0d0; }
.dark .hljs-keyword,
.dark .hljs-selector-tag { color: #f0f0f0; font-weight: 600; }
.dark .hljs-string,
.dark .hljs-attr { color: #aaaaaa; }
.dark .hljs-number { color: #cccccc; }
.dark .hljs-comment { color: #666666; font-style: italic; }
.dark .hljs-built_in { color: #bbbbbb; }
.dark .hljs-type { color: #c6c6c6; }
.dark .hljs-variable { color: #f0f0f0; }
.dark .hljs-title,
.dark .hljs-title\.function_ { color: #f0f0f0; }
.dark .hljs-params { color: #d0d0d0; }
.dark .hljs-meta { color: #666666; }
</style>
@@ -201,7 +201,7 @@ const formattedToolResult = computed(() => {
.message-bubble {
background-color: $msg-user-bg;
border-radius: $radius-md $radius-md 4px $radius-md;
border-radius: 10px;
}
}
@@ -223,7 +223,7 @@ const formattedToolResult = computed(() => {
.message-bubble {
background-color: $msg-assistant-bg;
border-radius: $radius-md $radius-md $radius-md 4px;
border-radius: 10px;
}
}
@@ -238,7 +238,7 @@ const formattedToolResult = computed(() => {
border-left: 3px solid $warning;
border-radius: $radius-sm;
max-width: 80%;
background-color: rgba($warning, 0.06);
background-color: rgba(var(--warning-rgb), 0.06);
}
}
}
@@ -261,6 +261,7 @@ const formattedToolResult = computed(() => {
font-size: 14px;
line-height: 1.65;
word-break: break-word;
border-radius: 10px;
}
.msg-attachments {
@@ -315,6 +316,10 @@ const formattedToolResult = computed(() => {
color: $text-muted;
margin-top: 4px;
padding: 0 4px;
.dark & {
color: #999999;
}
}
.tool-line {
@@ -369,7 +374,7 @@ const formattedToolResult = computed(() => {
.tool-error-badge {
font-size: 9px;
color: $error;
background: rgba($error, 0.08);
background: rgba(var(--error-rgb), 0.08);
padding: 0 4px;
border-radius: 3px;
line-height: 14px;
@@ -91,7 +91,11 @@ watch(currentToolCalls, scrollToBottom)
display: flex;
flex-direction: column;
gap: 16px;
background-color: #ffffff;
background-color: $bg-card;
.dark & {
background-color: #333333;
}
}
.empty-state {
@@ -152,7 +152,7 @@ async function handleDelete() {
transition: border-color $transition-fast;
&:hover {
border-color: rgba($accent-primary, 0.3);
border-color: rgba(var(--accent-primary-rgb), 0.3);
}
}
@@ -180,22 +180,22 @@ async function handleDelete() {
font-weight: 500;
&.success {
background: rgba($success, 0.12);
background: rgba(var(--success-rgb), 0.12);
color: $success;
}
&.info {
background: rgba($accent-primary, 0.12);
background: rgba(var(--accent-primary-rgb), 0.12);
color: $accent-primary;
}
&.warning {
background: rgba($warning, 0.12);
background: rgba(var(--warning-rgb), 0.12);
color: $warning;
}
&.error {
background: rgba($error, 0.12);
background: rgba(var(--error-rgb), 0.12);
color: $error;
}
}
@@ -70,7 +70,7 @@ async function handleDelete() {
transition: border-color $transition-fast;
&:hover {
border-color: rgba($accent-primary, 0.3);
border-color: rgba(var(--accent-primary-rgb), 0.3);
}
}
@@ -98,12 +98,12 @@ async function handleDelete() {
font-weight: 500;
&.builtin {
background: rgba($accent-primary, 0.12);
background: rgba(var(--accent-primary-rgb), 0.12);
color: $accent-primary;
}
&.custom {
background: rgba($success, 0.12);
background: rgba(var(--success-rgb), 0.12);
color: $success;
}
}
@@ -181,11 +181,11 @@ async function handleExport() {
transition: border-color $transition-fast;
&:hover {
border-color: rgba($accent-primary, 0.3);
border-color: rgba(var(--accent-primary-rgb), 0.3);
}
&.active {
border-color: rgba($success, 0.4);
border-color: rgba(var(--success-rgb), 0.4);
}
}
@@ -1,12 +1,20 @@
<script setup lang="ts">
import { NSwitch, useMessage } from 'naive-ui'
import { NSwitch, NSelect, useMessage } from 'naive-ui'
import { useI18n } from 'vue-i18n'
import { useSettingsStore } from '@/stores/hermes/settings'
import { useTheme, type ThemeMode } from '@/composables/useTheme'
import SettingRow from './SettingRow.vue'
const settingsStore = useSettingsStore()
const message = useMessage()
const { t } = useI18n()
const { mode, setMode } = useTheme()
const themeOptions = [
{ label: t('settings.display.themeLight'), value: 'light' },
{ label: t('settings.display.themeDark'), value: 'dark' },
{ label: t('settings.display.themeSystem'), value: 'system' },
]
async function save(values: Record<string, any>) {
try {
@@ -16,10 +24,19 @@ async function save(values: Record<string, any>) {
message.error(t('settings.saveFailed'))
}
}
function handleThemeChange(val: string) {
const m = val as ThemeMode
setMode(m)
save({ skin: m })
}
</script>
<template>
<section class="settings-section">
<SettingRow :label="t('settings.display.theme')" :hint="t('settings.display.themeHint')">
<NSelect :value="mode" :options="themeOptions" size="small" :consistent-menu-width="false" class="input-sm" @update:value="handleThemeChange" />
</SettingRow>
<SettingRow :label="t('settings.display.streaming')" :hint="t('settings.display.streamingHint')">
<NSwitch :value="settingsStore.display.streaming" @update:value="v => save({ streaming: v })" />
</SettingRow>
@@ -57,7 +57,7 @@ const configured = computed(() => {
overflow: hidden;
&.configured {
border-color: rgba($success, 0.2);
border-color: rgba(var(--success-rgb), 0.2);
}
}
@@ -70,7 +70,7 @@ const configured = computed(() => {
user-select: none;
&:hover {
background-color: rgba($text-primary, 0.03);
background-color: rgba(var(--text-primary-rgb), 0.03);
}
}
@@ -185,7 +185,7 @@ watch(() => `${props.category}/${props.skill}`, loadSkill, { immediate: true })
border-radius: 4px;
&:hover {
background: rgba($accent-primary, 0.06);
background: rgba(var(--accent-primary-rgb), 0.06);
}
}
@@ -150,7 +150,7 @@ async function handleToggle(category: string, skillName: string, newEnabled: boo
border-radius: $radius-sm;
&:hover {
background: rgba($accent-primary, 0.04);
background: rgba(var(--accent-primary-rgb), 0.04);
}
}
@@ -174,7 +174,7 @@ async function handleToggle(category: string, skillName: string, newEnabled: boo
.category-count {
font-size: 11px;
color: $text-muted;
background: rgba($accent-primary, 0.06);
background: rgba(var(--accent-primary-rgb), 0.06);
padding: 1px 6px;
border-radius: 8px;
}
@@ -200,12 +200,12 @@ async function handleToggle(category: string, skillName: string, newEnabled: boo
gap: 8px;
&:hover {
background: rgba($accent-primary, 0.06);
background: rgba(var(--accent-primary-rgb), 0.06);
color: $text-primary;
}
&.active {
background: rgba($accent-primary, 0.1);
background: rgba(var(--accent-primary-rgb), 0.1);
color: $text-primary;
font-weight: 500;
}
@@ -127,6 +127,10 @@ import { computed } from 'vue'
border-radius: 2px 2px 0 0;
min-height: 0;
transition: height 0.3s ease;
.dark & {
background: #66bb6a;
}
}
.bar-col {
@@ -140,7 +144,7 @@ import { computed } from 'vue'
left: 50%;
transform: translateX(-50%);
background: $text-primary;
color: #fff;
color: var(--text-on-accent);
padding: 6px 10px;
border-radius: $radius-sm;
font-size: 11px;
@@ -85,6 +85,10 @@ function formatTokens(n: number): string {
border-radius: 3px;
min-width: 2px;
transition: width 0.3s ease;
.dark & {
background: #66bb6a;
}
}
.model-tokens {