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(() => {
2020
2121<template >
2222 <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 >
2927 </VanConfigProvider >
3028</template >
Original file line number Diff line number Diff line change @@ -5,15 +5,15 @@ const route = useRoute()
55
66const active = ref (0 )
77
8- const display = computed (() => {
8+ const show = computed (() => {
99 if (route .name && names .includes (route .name ))
1010 return true
1111 return false
1212})
1313 </script >
1414
1515<template >
16- <van-tabbar v-show = " display " v-model =" active" route >
16+ <van-tabbar v-if = " show " v-model =" active" route placeholder fixed >
1717 <van-tabbar-item replace to =" /" >
1818 <span >{{ $t('tabbar.home') }}</span >
1919 <template #icon >
Original file line number Diff line number Diff line change 11<script setup lang="ts">
2+ import { useAppFooterRouteNames as routeWhiteList } from ' ~/config'
3+
24const route = useRoute ()
35const router = useRouter ()
46
@@ -16,14 +18,15 @@ const title = computed(() => {
1618 return ' '
1719 return route .meta .i18n ? t (route .meta .i18n ) : (route .meta .title || ' ' )
1820})
21+
22+ const showLeftArrow = computed (() => route .name && routeWhiteList .includes (route .name ))
1923 </script >
2024
2125<template >
2226 <VanNavBar
23- v-show =" title"
2427 :title =" title"
25- :fixed = " true "
26- clickable left-arrow
28+ :left-arrow = " !showLeftArrow "
29+ placeholder clickable fixed
2730 @click-left =" onBack"
2831 />
2932</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-
111<template >
12- <main >
13- <AppHeader />
2+ <main class = " flex flex-col min-h-svh " >
3+ <AppHeader class = " h-[var(--van-nav-bar-height)] " />
144
15- <div : class =" classNames " >
5+ <div class =" flex-1 p-16 pb-[var(--van-nav-bar-height)] " >
166 <slot />
177 </div >
188
Original file line number Diff line number Diff line change @@ -4,6 +4,12 @@ import type { PickerColumn } from 'vant'
44import type { ComputedRef } from ' vue'
55import { Locale } from ' vant'
66
7+ definePageMeta ({
8+ layout: ' default' ,
9+ title: ' 主页' ,
10+ i18n: ' menu.home' ,
11+ })
12+
713const color = useColorMode ()
814
915useHead ({
@@ -17,14 +23,10 @@ useHead({
1723const checked = computed ({
1824 get : () => color .value === ' dark' ,
1925 set : (val : boolean ) => {
20- return val
26+ color . preference = val ? ' dark ' : ' light '
2127 },
2228})
2329
24- function toggleDark() {
25- color .preference = color .value === ' dark' ? ' light' : ' dark'
26- }
27-
2830const { setLocale, t } = useI18n ()
2931const i18n = useNuxtApp ().$i18n
3032
@@ -57,12 +59,13 @@ function onLanguageConfirm(event: { selectedOptions: PickerColumn }) {
5759 <VanCellGroup inset >
5860 <VanCell :title =" $t('menu.darkMode')" center >
5961 <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 >
6669 </template >
6770 </VanCell >
6871
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+
19<template >
210 <div mx-auto mb-60 pt-15 text-center text-16 text-dark dark:text-white >
311 {{ $t('profile_page.txt') }}
Original file line number Diff line number Diff line change 11: root : root {
22 --van-primary-color : var (--c-primary );
3+ --van-cell-group-inset-padding : 0 ;
34}
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 11{
22 "menu" : {
3+ "home" : " Home" ,
4+ "profile" : " Profile" ,
35 "darkMode" : " 🌗 Dark Mode" ,
46 "language" : " 📚 Language" ,
57 "404Demo" : " 🙅 Page 404 Demo" ,
Original file line number Diff line number Diff line change 11{
22 "menu" : {
3+ "home" : " 主页" ,
4+ "profile" : " 我的" ,
35 "darkMode" : " 🌗 暗黑模式" ,
46 "language" : " 📚 语言" ,
57 "404Demo" : " 🙅 404页 演示" ,
You can’t perform that action at this time.
0 commit comments