feat: update theme and UI styles across components

- Refactored CSS variables for consistent theming, replacing hardcoded colors with CSS variables for better maintainability.
- Updated various components including `AgentAvatar`, `AgentSelector`, and `AgentShareSettings` to utilize new theme variables for colors, backgrounds, and shadows.
- Enhanced SVG icons to use `currentColor` for better adaptability to theme changes.
- Improved overall UI consistency by aligning styles with the new theming approach, enhancing user experience across the application.

These changes significantly improve the visual coherence and maintainability of the UI, ensuring a more seamless user experience.
This commit is contained in:
wizardchen
2026-03-05 11:19:36 +08:00
committed by lyingbug
parent 44f38ca6c3
commit dbc7c32874
95 changed files with 2544 additions and 2407 deletions
+43
View File
@@ -0,0 +1,43 @@
import { ref, watch } from 'vue'
export type ThemeMode = 'light' | 'dark' | 'system'
const STORAGE_KEY = 'WeKnora_theme'
// Shared reactive state across all consumers
const currentTheme = ref<ThemeMode>(
(localStorage.getItem(STORAGE_KEY) as ThemeMode) || 'light'
)
function getSystemTheme(): 'light' | 'dark' {
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
}
function applyTheme(mode: ThemeMode) {
const effective = mode === 'system' ? getSystemTheme() : mode
document.documentElement.setAttribute('theme-mode', effective)
}
export function useTheme() {
function setTheme(mode: ThemeMode) {
currentTheme.value = mode
localStorage.setItem(STORAGE_KEY, mode)
applyTheme(mode)
}
return { currentTheme, setTheme }
}
/** Call once in main.ts to initialise theme and listen for OS changes. */
export function initTheme() {
const saved = (localStorage.getItem(STORAGE_KEY) as ThemeMode) || 'light'
currentTheme.value = saved
applyTheme(saved)
// React to OS theme changes when user chose "system"
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
if (currentTheme.value === 'system') {
applyTheme('system')
}
})
}