Skip to content

Commit b41a88a

Browse files
committed
chore: Remove previous Dark mode (#51)
1 parent 632e55a commit b41a88a

File tree

4 files changed

+7
-63
lines changed

4 files changed

+7
-63
lines changed

src/App.vue

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
11
<script setup lang="ts">
22
import type { ConfigProviderTheme } from 'vant'
3-
import { localStorage } from '@/utils/local-storage'
4-
import { useStore } from '@/stores'
53
import { useRouteTransitionNameHook } from '@/stores/modules/routeTransitionName'
64
7-
const store = useStore()
85
const theme = ref<ConfigProviderTheme>('light')
9-
const mode = computed(() => store.mode)
10-
11-
watch(mode, (val) => {
12-
if (val === 'dark' || localStorage.get('theme') === 'dark') {
13-
theme.value = 'dark'
14-
document.querySelector('html')
15-
.setAttribute('data-theme', 'dark')
16-
}
17-
else {
18-
theme.value = 'light'
19-
document.querySelector('html')
20-
.setAttribute('data-theme', 'light')
21-
}
22-
}, { immediate: true })
23-
246
provide('isRealDark', computed(() => theme.value === 'dark'))
257
</script>
268

src/stores/index.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
import { createPinia, defineStore } from 'pinia'
2-
3-
export const useStore = defineStore({
4-
id: 'index',
5-
persist: true,
6-
state: () => ({
7-
// light || dark
8-
mode: '',
9-
}),
10-
})
1+
import { createPinia } from 'pinia'
112

123
const store = createPinia()
134
export { store }

src/styles/app.less

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
body {
2+
background-color: #eff2f5;
3+
}
4+
15
#app {
26
min-height: 100vh;
37
position: relative;
@@ -29,20 +33,3 @@
2933
opacity: 0;
3034
}
3135

32-
[data-theme='dark'] {
33-
&,
34-
* {
35-
color-scheme: dark !important;
36-
}
37-
}
38-
39-
[data-theme='light'] {
40-
&,
41-
* {
42-
color-scheme: light !important;
43-
}
44-
45-
body {
46-
background-color: #eff2f5;
47-
}
48-
}

src/views/index.vue

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,20 @@
11
<script setup lang="ts">
2-
import { useStore } from '@/stores'
3-
import { localStorage } from '@/utils/local-storage'
4-
52
definePage({
63
name: 'index',
74
meta: {
85
level: 1,
96
},
107
})
118
12-
const store = useStore()
13-
const themeStore = localStorage.get('theme')
14-
const checked = ref<boolean>(themeStore === 'dark')
15-
16-
watch(checked, (val) => {
17-
if (val) {
18-
store.mode = 'dark'
19-
localStorage.set('theme', 'dark')
20-
}
21-
else {
22-
store.mode = 'light'
23-
localStorage.set('theme', 'light')
24-
}
25-
})
9+
const checked = ref<boolean>(false)
2610
</script>
2711

2812
<template>
2913
<div class="container">
3014
<VanCellGroup title="一个集成最新技术栈、完整干净的移动端模板" inset>
3115
<VanCell center title="🌗 暗黑模式">
3216
<template #right-icon>
33-
<VanSwitch v-model="checked" size="23px" />
17+
<VanSwitch v-model="checked" size="23px" disabled />
3418
</template>
3519
</VanCell>
3620

0 commit comments

Comments
 (0)