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' {