fix: 修复plugin-access和plugin-layout中noFoundHandler和unAccessHandler的类型错误问题

This commit is contained in:
wanchun 2023-03-14 14:56:07 +08:00
parent 425a04568b
commit b1adca9f11
2 changed files with 28 additions and 6 deletions

View File

@ -1,4 +1,4 @@
import { Router, NavigationGuard } from 'vue-router'; import { Router, RouteLocationNormalized, NavigationGuardNext, NavigationGuardReturn, NavigationGuard } from 'vue-router';
import { Ref } from 'vue'; import { Ref } from 'vue';
export const access: { export const access: {
@ -11,6 +11,17 @@ export const access: {
export function useAccess(accessId: Array<string | number>): Ref<boolean>; export function useAccess(accessId: Array<string | number>): Ref<boolean>;
interface CustomNavigationGuardOption {
router: Router;
to: RouteLocationNormalized;
from: RouteLocationNormalized;
next: NavigationGuardNext;
}
interface CustomNavigationGuard {
(option: CustomNavigationGuardOption): NavigationGuardReturn | Promise<NavigationGuardReturn>;
}
declare module '@fesjs/fes' { declare module '@fesjs/fes' {
interface PluginBuildConfig { interface PluginBuildConfig {
access?: access?:
@ -22,8 +33,8 @@ declare module '@fesjs/fes' {
interface PluginRuntimeConfig { interface PluginRuntimeConfig {
access?: { access?: {
noFoundHandler: (param: { router: Router } & NavigationGuard) => void; noFoundHandler: NavigationGuard;
unAccessHandler: (param: { router: Router } & NavigationGuard) => void; unAccessHandler: CustomNavigationGuard;
}; };
} }
} }

View File

@ -1,5 +1,16 @@
import { Component, VNode, Ref } from 'vue'; 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<NavigationGuardReturn>;
}
interface Menu { interface Menu {
name: string; name: string;
@ -31,8 +42,8 @@ interface LayoutRuntimeConfig {
accordion?: boolean; accordion?: boolean;
}; };
renderCustom?: () => VNode | VNode[]; renderCustom?: () => VNode | VNode[];
noFoundHandler?: (param: { router: Router } & NavigationGuard) => void; noFoundHandler?: CustomNavigationGuard;
unAccessHandler?: (param: { router: Router } & NavigationGuard) => void; unAccessHandler?: CustomNavigationGuard;
} }
declare module '@fesjs/fes' { declare module '@fesjs/fes' {