fix: tdesign theme toggle and demos (#7087)

This commit is contained in:
ppxb
2026-01-10 14:11:08 +08:00
committed by GitHub
parent 343d8a1c1e
commit 19b2d7af41
2 changed files with 11 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import type { GlobalConfigProvider } from 'tdesign-vue-next';
import { onMounted } from 'vue';
import { watch } from 'vue';
import { usePreferences } from '@vben/preferences';
@@ -12,12 +12,13 @@ import zhConfig from 'tdesign-vue-next/es/locale/zh_CN';
defineOptions({ name: 'App' });
const { isDark } = usePreferences();
onMounted(() => {
document.documentElement.setAttribute(
'theme-mode',
isDark.value ? 'dark' : '',
);
});
watch(
() => isDark.value,
(dark) => {
document.documentElement.setAttribute('theme-mode', dark ? 'dark' : '');
},
{ immediate: true },
);
const customConfig: GlobalConfigProvider = {
// 可以在此处定义更多自定义配置,具体可配置内容参看 API 文档