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';
export const access: {
@ -11,6 +11,17 @@ export const access: {
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' {
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;
};
}
}

View File

@ -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<NavigationGuardReturn>;
}
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' {