From 72200430568a1b5315394a56ac466b3c31abc089 Mon Sep 17 00:00:00 2001 From: Wisdom Date: Wed, 29 May 2024 13:23:15 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9D=84=EF=B8=8F=20refactor:=20provider=20nai?= =?UTF-8?q?ve=20wrapper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc-auto-import.json | 6 +++- auto-imports.d.ts | 12 ++++++++ src/App.vue | 3 +- src/components/Layout/LayoutArea.vue | 14 ++++++---- src/components/Layout/LayoutView.vue | 18 ++---------- src/components/Navigation/NavBar.vue | 38 +++++++++++++++----------- src/hooks/useForceReload.ts | 41 ++++++++++++++++++++++++++++ src/{ => provider}/NaiveProvider.vue | 24 ++++++++++------ src/provider/context.ts | 25 +++++++++++++++++ src/router/child-routes.ts | 32 ++++++++++++---------- src/store/utils/mixin.ts | 6 ++-- vite.config.ts | 7 +++++ 12 files changed, 159 insertions(+), 67 deletions(-) create mode 100644 src/hooks/useForceReload.ts rename src/{ => provider}/NaiveProvider.vue (61%) create mode 100644 src/provider/context.ts diff --git a/.eslintrc-auto-import.json b/.eslintrc-auto-import.json index 8cf65fd..744668a 100644 --- a/.eslintrc-auto-import.json +++ b/.eslintrc-auto-import.json @@ -325,6 +325,10 @@ "watchThrottled": true, "watchTriggerable": true, "watchWithFilter": true, - "whenever": true + "whenever": true, + "NotificationPlacement": true, + "reloadRouterViewInjectionKey": true, + "useApplyForceReload": true, + "useRegisterForceReload": true } } diff --git a/auto-imports.d.ts b/auto-imports.d.ts index 365b236..f9c372d 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -95,6 +95,7 @@ declare global { const refDefault: typeof import('@vueuse/core')['refDefault'] const refThrottled: typeof import('@vueuse/core')['refThrottled'] const refWithControl: typeof import('@vueuse/core')['refWithControl'] + const reloadRouterViewInjectionKey: typeof import('./src/hooks/useForceReload')['reloadRouterViewInjectionKey'] const render: typeof import('vue')['render'] const resolveComponent: typeof import('vue')['resolveComponent'] const resolveRef: typeof import('@vueuse/core')['resolveRef'] @@ -128,6 +129,7 @@ declare global { const until: typeof import('@vueuse/core')['until'] const useActiveElement: typeof import('@vueuse/core')['useActiveElement'] const useAnimate: typeof import('@vueuse/core')['useAnimate'] + const useApplyForceReload: typeof import('./src/hooks/useForceReload')['useApplyForceReload'] const useArrayDifference: typeof import('@vueuse/core')['useArrayDifference'] const useArrayEvery: typeof import('@vueuse/core')['useArrayEvery'] const useArrayFilter: typeof import('@vueuse/core')['useArrayFilter'] @@ -241,6 +243,7 @@ declare global { const usePrevious: typeof import('@vueuse/core')['usePrevious'] const useRafFn: typeof import('@vueuse/core')['useRafFn'] const useRefHistory: typeof import('@vueuse/core')['useRefHistory'] + const useRegisterForceReload: typeof import('./src/hooks/useForceReload')['useRegisterForceReload'] const useResizeObserver: typeof import('@vueuse/core')['useResizeObserver'] const useRoute: typeof import('vue-router')['useRoute'] const useRouter: typeof import('vue-router')['useRouter'] @@ -319,6 +322,9 @@ declare global { // @ts-ignore export type { RouteRecordRaw, RouteLocationRaw, LocationQuery, RouteParams, RouteLocationNormalizedLoaded, RouteRecordName, NavigationGuard } from 'vue-router' import('vue-router') + // @ts-ignore + export type { NotificationPlacement } from 'naive-ui' + import('naive-ui') } // for vue template auto import import { UnwrapRef } from 'vue' @@ -415,6 +421,7 @@ declare module 'vue' { readonly refDefault: UnwrapRef readonly refThrottled: UnwrapRef readonly refWithControl: UnwrapRef + readonly reloadRouterViewInjectionKey: UnwrapRef readonly render: UnwrapRef readonly resolveComponent: UnwrapRef readonly resolveRef: UnwrapRef @@ -448,6 +455,7 @@ declare module 'vue' { readonly until: UnwrapRef readonly useActiveElement: UnwrapRef readonly useAnimate: UnwrapRef + readonly useApplyForceReload: UnwrapRef readonly useArrayDifference: UnwrapRef readonly useArrayEvery: UnwrapRef readonly useArrayFilter: UnwrapRef @@ -561,6 +569,7 @@ declare module 'vue' { readonly usePrevious: UnwrapRef readonly useRafFn: UnwrapRef readonly useRefHistory: UnwrapRef + readonly useRegisterForceReload: UnwrapRef readonly useResizeObserver: UnwrapRef readonly useRoute: UnwrapRef readonly useRouter: UnwrapRef @@ -725,6 +734,7 @@ declare module '@vue/runtime-core' { readonly refDefault: UnwrapRef readonly refThrottled: UnwrapRef readonly refWithControl: UnwrapRef + readonly reloadRouterViewInjectionKey: UnwrapRef readonly render: UnwrapRef readonly resolveComponent: UnwrapRef readonly resolveRef: UnwrapRef @@ -758,6 +768,7 @@ declare module '@vue/runtime-core' { readonly until: UnwrapRef readonly useActiveElement: UnwrapRef readonly useAnimate: UnwrapRef + readonly useApplyForceReload: UnwrapRef readonly useArrayDifference: UnwrapRef readonly useArrayEvery: UnwrapRef readonly useArrayFilter: UnwrapRef @@ -871,6 +882,7 @@ declare module '@vue/runtime-core' { readonly usePrevious: UnwrapRef readonly useRafFn: UnwrapRef readonly useRefHistory: UnwrapRef + readonly useRegisterForceReload: UnwrapRef readonly useResizeObserver: UnwrapRef readonly useRoute: UnwrapRef readonly useRouter: UnwrapRef diff --git a/src/App.vue b/src/App.vue index f6001d8..eb33249 100644 --- a/src/App.vue +++ b/src/App.vue @@ -13,7 +13,8 @@