From b1adca9f117234584bbe67d5d39f5ee91948fcf0 Mon Sep 17 00:00:00 2001 From: wanchun <445436867@qq.com> Date: Tue, 14 Mar 2023 14:56:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dplugin-access=E5=92=8C?= =?UTF-8?q?plugin-layout=E4=B8=ADnoFoundHandler=E5=92=8CunAccessHandler?= =?UTF-8?q?=E7=9A=84=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/fes-plugin-access/types.d.ts | 17 ++++++++++++++--- packages/fes-plugin-layout/types.d.ts | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/packages/fes-plugin-access/types.d.ts b/packages/fes-plugin-access/types.d.ts index 78c342fb..3e874b2f 100644 --- a/packages/fes-plugin-access/types.d.ts +++ b/packages/fes-plugin-access/types.d.ts @@ -1,4 +1,4 @@ -import { Router, NavigationGuard } from 'vue-router'; +import { Router, RouteLocationNormalized, NavigationGuardNext, NavigationGuardReturn, NavigationGuard } from 'vue-router'; import { Ref } from 'vue'; export const access: { @@ -11,6 +11,17 @@ export const access: { export function useAccess(accessId: Array): Ref; +interface CustomNavigationGuardOption { + router: Router; + to: RouteLocationNormalized; + from: RouteLocationNormalized; + next: NavigationGuardNext; +} + +interface CustomNavigationGuard { + (option: CustomNavigationGuardOption): NavigationGuardReturn | Promise; +} + declare module '@fesjs/fes' { interface PluginBuildConfig { access?: @@ -22,8 +33,8 @@ declare module '@fesjs/fes' { interface PluginRuntimeConfig { access?: { - noFoundHandler: (param: { router: Router } & NavigationGuard) => void; - unAccessHandler: (param: { router: Router } & NavigationGuard) => void; + noFoundHandler: NavigationGuard; + unAccessHandler: CustomNavigationGuard; }; } } diff --git a/packages/fes-plugin-layout/types.d.ts b/packages/fes-plugin-layout/types.d.ts index e33b2e46..880878b5 100644 --- a/packages/fes-plugin-layout/types.d.ts +++ b/packages/fes-plugin-layout/types.d.ts @@ -1,5 +1,16 @@ import { Component, VNode, Ref } from 'vue'; -import { Router, NavigationGuard } from 'vue-router'; +import { Router, RouteLocationNormalized, NavigationGuardNext, NavigationGuardReturn, NavigationGuard } from 'vue-router'; + +interface CustomNavigationGuardOption { + router: Router; + to: RouteLocationNormalized; + from: RouteLocationNormalized; + next: NavigationGuardNext; +} + +interface CustomNavigationGuard { + (option: CustomNavigationGuardOption): NavigationGuardReturn | Promise; +} interface Menu { name: string; @@ -31,8 +42,8 @@ interface LayoutRuntimeConfig { accordion?: boolean; }; renderCustom?: () => VNode | VNode[]; - noFoundHandler?: (param: { router: Router } & NavigationGuard) => void; - unAccessHandler?: (param: { router: Router } & NavigationGuard) => void; + noFoundHandler?: CustomNavigationGuard; + unAccessHandler?: CustomNavigationGuard; } declare module '@fesjs/fes' {