Skip to content

Commit b362d4f

Browse files
committed
feat: use <ColorScheme> component
1 parent cfb8e54 commit b362d4f

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

app.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ useHead({
88
99
const color = useColorMode()
1010
const mode = computed(() => color.value as ConfigProviderTheme)
11-
1211
</script>
1312

1413
<template>
1514
<VanConfigProvider :theme="mode">
16-
<NuxtLayout>
17-
<NuxtPage />
18-
</NuxtLayout>
15+
<ColorScheme tag="div">
16+
<NuxtLayout>
17+
<NuxtPage />
18+
</NuxtLayout>
19+
</ColorScheme>
1920
</VanConfigProvider>
2021
</template>
2122

pages/index.vue

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,33 +30,31 @@ function toggleDark() {
3030
</script>
3131

3232
<template>
33-
<ClientOnly>
34-
<VanCellGroup inset>
35-
<VanCell
36-
center
37-
title="🌗 暗黑模式"
38-
>
39-
<template #right-icon>
40-
<VanSwitch
41-
v-model="checked"
42-
size="20px"
43-
aria-label="on/off Dark Mode"
44-
@click="toggleDark"
45-
/>
46-
</template>
47-
</VanCell>
48-
49-
<template
50-
v-for="item in menuItems"
51-
:key="item.route"
52-
>
53-
<!-- item.route -->
54-
<VanCell
55-
:title="item.title"
56-
to="/"
57-
is-link
33+
<VanCellGroup inset>
34+
<VanCell
35+
center
36+
title="🌗 暗黑模式"
37+
>
38+
<template #right-icon>
39+
<VanSwitch
40+
v-model="checked"
41+
size="20px"
42+
aria-label="on/off Dark Mode"
43+
@click="toggleDark"
5844
/>
5945
</template>
60-
</VanCellGroup>
61-
</ClientOnly>
46+
</VanCell>
47+
48+
<template
49+
v-for="item in menuItems"
50+
:key="item.route"
51+
>
52+
<!-- item.route -->
53+
<VanCell
54+
:title="item.title"
55+
to="/"
56+
is-link
57+
/>
58+
</template>
59+
</VanCellGroup>
6260
</template>

0 commit comments

Comments
 (0)