Skip to content

Commit 19b2d7a

Browse files
authored
fix: tdesign theme toggle and demos (vbenjs#7087)
1 parent 343d8a1 commit 19b2d7a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

apps/web-tdesign/src/app.vue

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script lang="ts" setup>
22
import type { GlobalConfigProvider } from 'tdesign-vue-next';
33
4-
import { onMounted } from 'vue';
4+
import { watch } from 'vue';
55
66
import { usePreferences } from '@vben/preferences';
77
@@ -12,12 +12,13 @@ import zhConfig from 'tdesign-vue-next/es/locale/zh_CN';
1212
defineOptions({ name: 'App' });
1313
const { isDark } = usePreferences();
1414
15-
onMounted(() => {
16-
document.documentElement.setAttribute(
17-
'theme-mode',
18-
isDark.value ? 'dark' : '',
19-
);
20-
});
15+
watch(
16+
() => isDark.value,
17+
(dark) => {
18+
document.documentElement.setAttribute('theme-mode', dark ? 'dark' : '');
19+
},
20+
{ immediate: true },
21+
);
2122
2223
const customConfig: GlobalConfigProvider = {
2324
// 可以在此处定义更多自定义配置,具体可配置内容参看 API 文档

apps/web-tdesign/src/views/demos/tdesign/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@ function notify(type: NotificationType) {
3838
description="支持多语言,主题功能集成切换等"
3939
title="TDesign Vue组件使用演示"
4040
>
41-
<Card class="mb-5" title="按钮">
41+
<Card class="!mb-5" title="按钮">
4242
<Space>
4343
<Button>Default</Button>
4444
<Button theme="primary"> Primary </Button>
4545
<Button theme="default"> Info </Button>
4646
<Button theme="danger"> Error </Button>
4747
</Space>
4848
</Card>
49-
<Card class="mb-5" title="Message">
49+
<Card class="!mb-5" title="Message">
5050
<Space>
5151
<Button @click="info"> 信息 </Button>
5252
<Button theme="danger" @click="error"> 错误 </Button>
@@ -55,7 +55,7 @@ function notify(type: NotificationType) {
5555
</Space>
5656
</Card>
5757

58-
<Card class="mb-5" title="Notification">
58+
<Card class="!mb-5" title="Notification">
5959
<Space>
6060
<Button @click="notify('info')"> 信息 </Button>
6161
<Button theme="danger" @click="notify('error')"> 错误 </Button>

0 commit comments

Comments
 (0)