From 39ba382fec2221b3acc965a35be4a64e0253e9a5 Mon Sep 17 00:00:00 2001 From: Hooray <304327508@qq.com> Date: Wed, 26 Feb 2025 14:47:52 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=88=B7=E6=96=B0=EF=BC=8C=E5=88=B7=E6=96=B0=E6=97=B6?= =?UTF-8?q?=E7=A6=81=E7=94=A8=E9=A1=B5=E9=9D=A2=E5=88=87=E6=8D=A2=E5=8A=A8?= =?UTF-8?q?=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Topbar/Toolbar/Breadcrumb/index.vue | 16 +++++++++++----- src/layouts/index.vue | 2 +- src/store/modules/settings.ts | 9 +++++++++ src/types/global.d.ts | 6 +++--- src/utils/composables/useMainPage.ts | 9 +++++++++ 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/layouts/components/Topbar/Toolbar/Breadcrumb/index.vue b/src/layouts/components/Topbar/Toolbar/Breadcrumb/index.vue index e0e5549c..2fd83c69 100644 --- a/src/layouts/components/Topbar/Toolbar/Breadcrumb/index.vue +++ b/src/layouts/components/Topbar/Toolbar/Breadcrumb/index.vue @@ -8,23 +8,29 @@ const route = useRoute() const settingsStore = useSettingsStore() -const breadcrumbList = computed(() => { - const breadcrumbList = [] +const breadcrumbList = ref<{ path: string, title: string }[]>([]) +watch(() => route.matched, () => { + if (route.name === 'reload') { + return + } + const list = [] if (settingsStore.settings.home.enable) { - breadcrumbList.push({ + list.push({ path: settingsStore.settings.home.fullPath, title: settingsStore.settings.home.title, }) } route.matched.forEach((item) => { if (item.meta?.breadcrumb !== false) { - breadcrumbList.push({ + list.push({ path: item.path, title: item.meta?.title, }) } }) - return breadcrumbList + breadcrumbList.value = list +}, { + immediate: true, }) function pathCompile(path: string) { diff --git a/src/layouts/index.vue b/src/layouts/index.vue index 91b1ff13..092958b6 100755 --- a/src/layouts/index.vue +++ b/src/layouts/index.vue @@ -132,7 +132,7 @@ const enableAppSetting = import.meta.env.VITE_APP_SETTING
- + diff --git a/src/store/modules/settings.ts b/src/store/modules/settings.ts index e8c4de93..a157a93d 100755 --- a/src/store/modules/settings.ts +++ b/src/store/modules/settings.ts @@ -87,6 +87,13 @@ const useSettingsStore = defineStore( break } + // 页面是否刷新 + const isReloading = ref(false) + // 切换当前页面是否刷新 + function setIsReloading(value?: boolean) { + isReloading.value = value ?? !isReloading.value + } + // 页面标题 const title = ref() // 记录页面标题 @@ -152,6 +159,8 @@ const useSettingsStore = defineStore( settings, currentColorScheme, os, + isReloading, + setIsReloading, title, setTitle, mode, diff --git a/src/types/global.d.ts b/src/types/global.d.ts index 45ac3ab8..d5b1dfc1 100755 --- a/src/types/global.d.ts +++ b/src/types/global.d.ts @@ -11,11 +11,11 @@ declare namespace Settings { interface app { /** * 颜色方案 - * @默认值 `''` 跟随系统 - * @可选值 `'light'` 明亮模式 + * @默认值 `'light'` 明亮模式 * @可选值 `'dark'` 暗黑模式 + * @可选值 `''` 跟随系统 */ - colorScheme?: '' | 'light' | 'dark' + colorScheme?: 'light' | 'dark' | '' /** * 圆角系数 * @默认值 `0.5` diff --git a/src/utils/composables/useMainPage.ts b/src/utils/composables/useMainPage.ts index 5d6600ce..6f35e452 100755 --- a/src/utils/composables/useMainPage.ts +++ b/src/utils/composables/useMainPage.ts @@ -1,9 +1,18 @@ +import useSettingsStore from '@/store/modules/settings' + export default function useMainPage() { const router = useRouter() + const settingsStore = useSettingsStore() + function reload() { + settingsStore.setIsReloading(true) router.push({ name: 'reload', + }).then(() => { + setTimeout(() => { + settingsStore.setIsReloading(false) + }, 100) }) }