Skip to content

Commit 871d562

Browse files
committed
chore: Optimize interface for light mode (#51)
1 parent 1dd86e5 commit 871d562

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

index.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,8 @@
88
;(function () {
99
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
1010
const setting = localStorage.getItem('vueuse-color-scheme') || 'auto'
11-
12-
if (setting === 'dark' || (prefersDark && setting !== 'light')) {
11+
if (setting === 'dark' || (prefersDark && setting !== 'light'))
1312
document.documentElement.classList.toggle('dark', true)
14-
} else {
15-
document.documentElement.classList.toggle('light', true)
16-
}
1713
})()
1814
</script>
1915
</head>

src/components/container/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="h-full w-full p-16 py-60" light="bg-[--van-gray-1]">
2+
<main class="h-full w-full p-16 py-60">
33
<slot />
4-
</div>
4+
</main>
55
</template>

src/styles/app.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
overflow-x: hidden;
55
}
66

7+
html {
8+
background: var(--van-gray-1);
9+
color-scheme: light;
10+
}
11+
712
html.dark {
813
background: #121212;
914
color-scheme: dark;

src/views/charts/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ const onClickLeft = () => history.back()
7272
<VanNavBar title="📊 Echarts" left-arrow fixed @click-left="onClickLeft" />
7373

7474
<Container>
75-
<div class="chart light:bg-white">
75+
<div class="chart">
7676
<Chart :option="refBarOption" :style="{ height: '330px' }" />
7777
</div>
7878

79-
<div class="chart item light:bg-white">
79+
<div class="chart item">
8080
<Chart :option="refLineOption" :style="{ height: '330px' }" />
8181
</div>
8282

83-
<div class="chart item light:bg-white">
83+
<div class="chart item">
8484
<Chart :option="refScoreOption" :style="{ height: '330px' }" />
8585
</div>
8686
</Container>

src/views/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function toggle() {
1818
</script>
1919

2020
<template>
21-
<div class="h-full w-full py-60" light="bg-[--van-gray-1]">
21+
<main class="h-full w-full py-60">
2222
<VanCellGroup inset title="一个集成最新技术栈、完整干净的移动端模板">
2323
<VanCell center title="🌗 暗黑模式">
2424
<template #right-icon>
@@ -40,5 +40,5 @@ function toggle() {
4040
</template>
4141
</VanCell>
4242
</VanCellGroup>
43-
</div>
43+
</main>
4444
</template>

src/views/mock/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const onClickLeft = () => history.back()
3232
来自异步请求的数据
3333
</div>
3434

35-
<div class="data-content dark:bg-[--van-background-2] light:bg-white">
35+
<div class="data-content bg-white dark:bg-[--van-background-2]">
3636
<div v-if="messages">
3737
{{ messages }}
3838
</div>

0 commit comments

Comments
 (0)