File tree Expand file tree Collapse file tree 11 files changed +64
-36
lines changed Expand file tree Collapse file tree 11 files changed +64
-36
lines changed Original file line number Diff line number Diff line change @@ -20,11 +20,9 @@ const keepAliveRouteNames = computed(() => {
20
20
21
21
<template >
22
22
<VanConfigProvider :theme =" mode" >
23
- <ColorScheme tag =" div" >
24
- <NuxtLoadingIndicator color =" repeating-linear-gradient(to right,var(--c-primary) 0%,var(--c-primary-active) 100%)" />
25
- <NuxtLayout >
26
- <NuxtPage :keepalive =" { include: keepAliveRouteNames }" />
27
- </NuxtLayout >
28
- </ColorScheme >
23
+ <NuxtLoadingIndicator color =" repeating-linear-gradient(to right,var(--c-primary) 0%,var(--c-primary-active) 100%)" />
24
+ <NuxtLayout >
25
+ <NuxtPage :keepalive =" { include: keepAliveRouteNames }" />
26
+ </NuxtLayout >
29
27
</VanConfigProvider >
30
28
</template >
Original file line number Diff line number Diff line change @@ -5,15 +5,15 @@ const route = useRoute()
5
5
6
6
const active = ref (0 )
7
7
8
- const display = computed (() => {
8
+ const show = computed (() => {
9
9
if (route .name && names .includes (route .name ))
10
10
return true
11
11
return false
12
12
})
13
13
</script >
14
14
15
15
<template >
16
- <van-tabbar v-show = " display " v-model =" active" route >
16
+ <van-tabbar v-if = " show " v-model =" active" route placeholder fixed >
17
17
<van-tabbar-item replace to =" /" >
18
18
<span >{{ $t('tabbar.home') }}</span >
19
19
<template #icon >
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
+ import { useAppFooterRouteNames as routeWhiteList } from ' ~/config'
3
+
2
4
const route = useRoute ()
3
5
const router = useRouter ()
4
6
@@ -16,14 +18,15 @@ const title = computed(() => {
16
18
return ' '
17
19
return route .meta .i18n ? t (route .meta .i18n ) : (route .meta .title || ' ' )
18
20
})
21
+
22
+ const showLeftArrow = computed (() => route .name && routeWhiteList .includes (route .name ))
19
23
</script >
20
24
21
25
<template >
22
26
<VanNavBar
23
- v-show =" title"
24
27
:title =" title"
25
- :fixed = " true "
26
- clickable left-arrow
28
+ :left-arrow = " !showLeftArrow "
29
+ placeholder clickable fixed
27
30
@click-left =" onBack"
28
31
/>
29
32
</template >
Original file line number Diff line number Diff line change 1
- <script setup lang="ts">
2
- import { useAppFooterRouteNames as names } from ' ~/config'
3
-
4
- const route = useRoute ()
5
-
6
- const classNames = computed (() => {
7
- return route .name && names .includes (route .name ) ? ' py-20' : ' px-10 pt-60'
8
- })
9
- </script >
10
-
11
1
<template >
12
- <main >
13
- <AppHeader />
2
+ <main class = " flex flex-col min-h-svh " >
3
+ <AppHeader class = " h-[var(--van-nav-bar-height)] " />
14
4
15
- <div : class =" classNames " >
5
+ <div class =" flex-1 p-16 pb-[var(--van-nav-bar-height)] " >
16
6
<slot />
17
7
</div >
18
8
Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ import type { PickerColumn } from 'vant'
4
4
import type { ComputedRef } from ' vue'
5
5
import { Locale } from ' vant'
6
6
7
+ definePageMeta ({
8
+ layout: ' default' ,
9
+ title: ' 主页' ,
10
+ i18n: ' menu.home' ,
11
+ })
12
+
7
13
const color = useColorMode ()
8
14
9
15
useHead ({
@@ -17,14 +23,10 @@ useHead({
17
23
const checked = computed ({
18
24
get : () => color .value === ' dark' ,
19
25
set : (val : boolean ) => {
20
- return val
26
+ color . preference = val ? ' dark ' : ' light '
21
27
},
22
28
})
23
29
24
- function toggleDark() {
25
- color .preference = color .value === ' dark' ? ' light' : ' dark'
26
- }
27
-
28
30
const { setLocale, t } = useI18n ()
29
31
const i18n = useNuxtApp ().$i18n
30
32
@@ -57,12 +59,13 @@ function onLanguageConfirm(event: { selectedOptions: PickerColumn }) {
57
59
<VanCellGroup inset >
58
60
<VanCell :title =" $t('menu.darkMode')" center >
59
61
<template #right-icon >
60
- <VanSwitch
61
- v-model =" checked"
62
- size =" 20px"
63
- aria-label =" on/off Dark Mode"
64
- @click =" toggleDark"
65
- />
62
+ <ClientOnly >
63
+ <VanSwitch
64
+ v-model =" checked"
65
+ size =" 20px"
66
+ aria-label =" on/off Dark Mode"
67
+ />
68
+ </ClientOnly >
66
69
</template >
67
70
</VanCell >
68
71
Original file line number Diff line number Diff line change
1
+ <script setup lang="ts">
2
+ definePageMeta ({
3
+ layout: ' default' ,
4
+ title: ' 我的' ,
5
+ i18n: ' menu.profile' ,
6
+ })
7
+ </script >
8
+
1
9
<template >
2
10
<div mx-auto mb-60 pt-15 text-center text-16 text-dark dark:text-white >
3
11
{{ $t('profile_page.txt') }}
Original file line number Diff line number Diff line change 1
1
: root : root {
2
2
--van-primary-color : var (--c-primary );
3
+ --van-cell-group-inset-padding : 0 ;
3
4
}
Original file line number Diff line number Diff line change
1
+ export default function preload ( ) {
2
+ return `
3
+ ;(function() {
4
+ const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
5
+ const setting = localStorage.getItem('nuxt-color-mode') || 'auto';
6
+ if (setting === 'dark' || (prefersDark && setting !== 'light'))
7
+ document.documentElement.classList.toggle('van-theme-dark', true);
8
+ })()
9
+ `
10
+ }
Original file line number Diff line number Diff line change 1
1
{
2
2
"menu" : {
3
+ "home" : " Home" ,
4
+ "profile" : " Profile" ,
3
5
"darkMode" : " 🌗 Dark Mode" ,
4
6
"language" : " 📚 Language" ,
5
7
"404Demo" : " 🙅 Page 404 Demo" ,
Original file line number Diff line number Diff line change 1
1
{
2
2
"menu" : {
3
+ "home" : " 主页" ,
4
+ "profile" : " 我的" ,
3
5
"darkMode" : " 🌗 暗黑模式" ,
4
6
"language" : " 📚 语言" ,
5
7
"404Demo" : " 🙅 404页 演示" ,
You can’t perform that action at this time.
0 commit comments