refactor: 切换路由都判断下403和404保证他们有权限

This commit is contained in:
wanchun 2023-04-11 20:37:33 +08:00
parent 4fd4abbcf8
commit b3b07f6c84

View File

@ -7,11 +7,15 @@ if (!accessApi) {
throw new Error('[plugin-layout]: plugin-layout depends on plugin-accessplease install plugin-access first');
}
const accessIds = accessApi.getAccess();
accessApi.setAccess(accessIds.concat(['/403', '/404']));
export const access = (memo) => {
const runtimeConfig = getConfig();
const accessIds = accessApi.getAccess();
if (!accessIds.includes('/403')) {
accessApi.setAccess(accessIds.concat('/403'));
}
if (!accessIds.includes('/404')) {
accessApi.setAccess(accessIds.concat('/404'));
}
return {
unAccessHandler({ router, to, from, next }) {
if (runtimeConfig.unAccessHandler && typeof runtimeConfig.unAccessHandler === 'function') {