Skip to content

Commit 8c5ec2c

Browse files
committed
chore: Improved app page display in light mode (#51)
1 parent bb91814 commit 8c5ec2c

File tree

11 files changed

+45
-48
lines changed

11 files changed

+45
-48
lines changed

index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
<link rel="icon" href="/favicon.ico" />
77
<script>
88
;(function () {
9-
const prefersDark =
10-
window.matchMedia &&
11-
window.matchMedia('(prefers-color-scheme: dark)').matches
9+
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
1210
const setting = localStorage.getItem('vueuse-color-scheme') || 'auto'
13-
if (setting === 'dark' || (prefersDark && setting !== 'light'))
11+
12+
if (setting === 'dark' || (prefersDark && setting !== 'light')) {
1413
document.documentElement.classList.toggle('dark', true)
14+
} else {
15+
document.documentElement.classList.toggle('light', true)
16+
}
1517
})()
1618
</script>
1719
</head>

src/components.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ export {}
88
declare module 'vue' {
99
export interface GlobalComponents {
1010
Chart: typeof import('./components/chart/index.vue')['default']
11+
Container: typeof import('./components/container/index.vue')['default']
1112
RouterLink: typeof import('vue-router')['RouterLink']
1213
RouterView: typeof import('vue-router')['RouterView']
1314
VanButton: typeof import('vant/es')['Button']
1415
VanCell: typeof import('vant/es')['Cell']
1516
VanCellGroup: typeof import('vant/es')['CellGroup']
1617
VanConfigProvider: typeof import('vant/es')['ConfigProvider']
1718
VanEmpty: typeof import('vant/es')['Empty']
18-
VanLoading: typeof import('vant/es')['Loading']
1919
VanNavBar: typeof import('vant/es')['NavBar']
20+
VanSpace: typeof import('vant/es')['Space']
2021
VanSwitch: typeof import('vant/es')['Switch']
2122
VanTag: typeof import('vant/es')['Tag']
2223
}

src/components/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## Components
1+
# Components
22

33
Components in this dir will be auto-registered and on-demand, powered by [`unplugin-vue-components`](https://github.com/antfu/unplugin-vue-components).

src/components/container/index.vue

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

src/components/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export { default as Container } from './container/index.vue'
2+
13
// charts
24
export { default as Chart } from './chart/index.vue'
35
export type { SeriesDataItem, RadarDataItem, RadarIndicatorItem } from './chart/typing'

src/typed-router.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ import type {
3939

4040
declare module 'vue-router/auto/routes' {
4141
export interface RouteNamedMap {
42-
'index': RouteRecordInfo<'index', '/', Record<never, never>, Record<never, never>>,
42+
'main': RouteRecordInfo<'main', '/', Record<never, never>, Record<never, never>>,
4343
'charts': RouteRecordInfo<'charts', '/charts', Record<never, never>, Record<never, never>>,
4444
'counter': RouteRecordInfo<'counter', '/counter', Record<never, never>, Record<never, never>>,
4545
'mock': RouteRecordInfo<'mock', '/mock', Record<never, never>, Record<never, never>>,

src/views/charts/index.vue

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,29 +71,23 @@ const onClickLeft = () => history.back()
7171
<div>
7272
<VanNavBar title="📊 Echarts" left-arrow fixed @click-left="onClickLeft" />
7373

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

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

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

9090
<style lang="less" scoped>
91-
.container {
92-
width: 100%;
93-
height: 100%;
94-
padding: 60px 16px;
95-
}
96-
9791
.chart {
9892
width: 100%;
9993
height: 300px;

src/views/counter/index.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ const onClickLeft = () => history.back()
2121
</script>
2222

2323
<template>
24-
<div>
24+
<div class="h-full w-full">
2525
<VanNavBar title="🍍 持久化 Pinia 状态" left-arrow fixed @click-left="onClickLeft" />
2626

27-
<div class="h-100vh w-full px-20 py-60">
27+
<Container>
2828
<h1 class="text-6xl color-pink font-semibold">
2929
Hello, Pinia!
3030
</h1>
@@ -38,6 +38,6 @@ const onClickLeft = () => history.back()
3838
<button class="btn border-none btn-green" @click="add">
3939
Add
4040
</button>
41-
</div>
41+
</Container>
4242
</div>
4343
</template>

src/views/index.vue

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
import useAppStore from '@/stores/modules/app'
33
44
definePage({
5-
name: 'index',
5+
name: 'main',
66
meta: {
77
level: 1,
88
},
99
})
10+
1011
const appStore = useAppStore()
1112
const checked = ref<boolean>(isDark.value)
1213
@@ -17,11 +18,11 @@ function toggle() {
1718
</script>
1819

1920
<template>
20-
<div class="h-full w-full pt-30 light:bg-[#eff2f5]">
21-
<VanCellGroup title="一个集成最新技术栈、完整干净的移动端模板" inset>
21+
<div class="h-full w-full py-60" light="bg-[--van-gray-1]">
22+
<VanCellGroup inset title="一个集成最新技术栈、完整干净的移动端模板">
2223
<VanCell center title="🌗 暗黑模式">
2324
<template #right-icon>
24-
<VanSwitch v-model="checked" size="23px" @click="toggle()" />
25+
<VanSwitch v-model="checked" size="20px" @click="toggle()" />
2526
</template>
2627
</VanCell>
2728

@@ -32,7 +33,7 @@ function toggle() {
3233

3334
<VanCell center>
3435
<template #title>
35-
<span class="custom-title">🎨 欢迎补充</span>
36+
<span class="mr-4 v-middle">🎨 欢迎补充</span>
3637
<VanTag type="primary">
3738
PR
3839
</VanTag>
@@ -41,10 +42,3 @@ function toggle() {
4142
</VanCellGroup>
4243
</div>
4344
</template>
44-
45-
<style lang="less" scoped>
46-
.custom-title {
47-
margin-right: 4px;
48-
vertical-align: middle;
49-
}
50-
</style>

src/views/mock/index.vue

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,27 @@ const onClickLeft = () => history.back()
2727
<div class="h-full w-full">
2828
<VanNavBar title="💿 Mock 指南" left-arrow fixed @click-left="onClickLeft" />
2929

30-
<div class="h-full w-full px-30 py-74 light:bg-[#eff2f5]">
30+
<Container>
3131
<div class="data-label">
3232
来自异步请求的数据
3333
</div>
34+
3435
<div class="data-content dark:bg-[--van-background-2] light:bg-white">
3536
<div v-if="messages">
3637
{{ messages }}
3738
</div>
3839
<VanEmpty v-else description="暂无数据" />
3940
</div>
4041

41-
<VanButton round block type="primary" @click="pull">
42-
请求
43-
</VanButton>
44-
<VanButton round block type="default" @click="reset">
45-
清空
46-
</VanButton>
47-
</div>
42+
<van-space class="m-10" direction="vertical" fill>
43+
<VanButton type="primary" round block @click="pull">
44+
请求
45+
</VanButton>
46+
<VanButton type="default" round block @click="reset">
47+
清空
48+
</VanButton>
49+
</van-space>
50+
</Container>
4851
</div>
4952
</template>
5053

@@ -66,8 +69,4 @@ const onClickLeft = () => history.back()
6669
align-items: center;
6770
justify-content: center;
6871
}
69-
70-
.van-button--block {
71-
margin-top: 15px;
72-
}
7372
</style>

0 commit comments

Comments
 (0)