refactor: Simplify UI styles and remove unused theme management
- Removed theme initialization and management from the UI store. - Cleaned up CSS styles across multiple components, replacing CSS variables with fixed color values for consistency. - Updated background colors and text colors to enhance UI clarity and responsiveness. - Streamlined component styles to improve maintainability and readability.
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
type Theme = 'light' | 'dark'
|
||||
|
||||
export const useUIStore = defineStore('ui', {
|
||||
state: () => ({
|
||||
showSettingsModal: false,
|
||||
showKBSettingsModal: false,
|
||||
currentKBId: null as string | null,
|
||||
settingsInitialSection: null as string | null,
|
||||
settingsInitialSubSection: null as string | null,
|
||||
theme: 'light' as Theme
|
||||
settingsInitialSubSection: null as string | null
|
||||
}),
|
||||
|
||||
actions: {
|
||||
@@ -37,57 +34,6 @@ export const useUIStore = defineStore('ui', {
|
||||
closeKBSettings() {
|
||||
this.showKBSettingsModal = false
|
||||
this.currentKBId = null
|
||||
},
|
||||
|
||||
// 初始化主题(从localStorage加载)
|
||||
initTheme() {
|
||||
const savedSettings = localStorage.getItem('WeKnora_general_settings')
|
||||
if (savedSettings) {
|
||||
try {
|
||||
const parsed = JSON.parse(savedSettings)
|
||||
this.theme = parsed.theme || 'light'
|
||||
} catch (e) {
|
||||
console.error('加载主题设置失败:', e)
|
||||
this.theme = 'light'
|
||||
}
|
||||
}
|
||||
this.applyTheme()
|
||||
},
|
||||
|
||||
// 设置主题
|
||||
setTheme(theme: Theme) {
|
||||
this.theme = theme
|
||||
this.applyTheme()
|
||||
this.saveThemeToStorage()
|
||||
},
|
||||
|
||||
// 切换主题
|
||||
toggleTheme() {
|
||||
this.theme = this.theme === 'light' ? 'dark' : 'light'
|
||||
this.applyTheme()
|
||||
this.saveThemeToStorage()
|
||||
},
|
||||
|
||||
// 应用主题到DOM
|
||||
applyTheme() {
|
||||
document.documentElement.setAttribute('theme-mode', this.theme)
|
||||
},
|
||||
|
||||
// 保存主题到localStorage
|
||||
saveThemeToStorage() {
|
||||
const savedSettings = localStorage.getItem('WeKnora_general_settings')
|
||||
let settings = { language: 'zh-CN', theme: this.theme }
|
||||
|
||||
if (savedSettings) {
|
||||
try {
|
||||
const parsed = JSON.parse(savedSettings)
|
||||
settings = { ...parsed, theme: this.theme }
|
||||
} catch (e) {
|
||||
console.error('解析现有设置失败:', e)
|
||||
}
|
||||
}
|
||||
|
||||
localStorage.setItem('WeKnora_general_settings', JSON.stringify(settings))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user