feat: Implement theme management and UI enhancements across the application

- Added theme initialization and management in the UI store.
- Enhanced dark mode styles for various components, including tables, dialogs, and inputs.
- Updated multiple components to use CSS variables for consistent theming.
- Introduced a new simplified API for updating knowledge base configurations.
- Improved overall UI consistency and responsiveness with new styles.
This commit is contained in:
wizardchen
2025-11-06 02:45:44 +08:00
parent 4fa3adbf3b
commit 7a64371603
28 changed files with 2808 additions and 330 deletions
@@ -48,8 +48,11 @@
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { ref, onMounted, watch } from 'vue'
import { MessagePlugin } from 'tdesign-vue-next'
import { useUIStore } from '@/stores/ui'
const uiStore = useUIStore()
// 本地状态
const localLanguage = ref('zh-CN')
@@ -68,6 +71,13 @@ onMounted(() => {
console.error('加载常规设置失败:', e)
}
}
// 同步 store 的主题状态
localTheme.value = uiStore.theme
})
// 监听 store 的主题变化,同步到本地状态
watch(() => uiStore.theme, (newTheme) => {
localTheme.value = newTheme
})
// 保存设置到 localStorage
@@ -88,9 +98,8 @@ const handleLanguageChange = () => {
// 处理主题变化
const handleThemeChange = () => {
saveSettings()
uiStore.setTheme(localTheme.value as 'light' | 'dark')
MessagePlugin.success('主题设置已保存')
// TODO: 实际的主题切换逻辑可后续添加
}
</script>
@@ -105,13 +114,13 @@ const handleThemeChange = () => {
h2 {
font-size: 20px;
font-weight: 600;
color: #333333;
color: var(--td-text-color-primary);
margin: 0 0 8px 0;
}
.section-description {
font-size: 14px;
color: #666666;
color: var(--td-text-color-secondary);
margin: 0;
line-height: 1.5;
}
@@ -128,7 +137,7 @@ const handleThemeChange = () => {
align-items: flex-start;
justify-content: space-between;
padding: 20px 0;
border-bottom: 1px solid #e5e7eb;
border-bottom: 1px solid var(--td-component-border);
&:last-child {
border-bottom: none;
@@ -143,14 +152,14 @@ const handleThemeChange = () => {
label {
font-size: 15px;
font-weight: 500;
color: #333333;
color: var(--td-text-color-primary);
display: block;
margin-bottom: 4px;
}
.desc {
font-size: 13px;
color: #666666;
color: var(--td-text-color-secondary);
margin: 0;
line-height: 1.5;
}