From 29f925b644ee6123f0e01432225b79570587105f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=AC=E6=B5=B7?= <445436867@qq.com> Date: Tue, 11 Apr 2023 20:38:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=91=BD=E5=90=8D=E6=8F=90=E7=A4=BA=20&=20?= =?UTF-8?q?=E4=BF=9D=E8=AF=81403=E5=92=8C404=E8=B7=AF=E7=94=B1=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E6=9C=89=E6=9D=83=E9=99=90=20(#186)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 完善提示 * refactor: 切换路由都判断下403和404保证他们有权限 --- packages/fes-plugin-layout/src/runtime/runtime.js | 10 +++++++--- .../src/plugins/core/route/index.js | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/fes-plugin-layout/src/runtime/runtime.js b/packages/fes-plugin-layout/src/runtime/runtime.js index e5022259..7f604de5 100644 --- a/packages/fes-plugin-layout/src/runtime/runtime.js +++ b/packages/fes-plugin-layout/src/runtime/runtime.js @@ -7,11 +7,15 @@ if (!accessApi) { throw new Error('[plugin-layout]: plugin-layout depends on plugin-access,please 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') { diff --git a/packages/fes-preset-built-in/src/plugins/core/route/index.js b/packages/fes-preset-built-in/src/plugins/core/route/index.js index 8cfc6433..2fe2039a 100644 --- a/packages/fes-preset-built-in/src/plugins/core/route/index.js +++ b/packages/fes-preset-built-in/src/plugins/core/route/index.js @@ -55,12 +55,12 @@ const getRoutePath = function (parentRoutePath, fileName, isFile = true) { } // /@id.vue -> /:id if (fileName.startsWith('@')) { - logger.warn(`[WARNING]: ${fileName} is deprecated, please use [slug]`); + logger.warn(`[WARNING]: filename or directory ${fileName} is deprecated, please use [${fileName.replace(/@/, '')}]`); fileName = fileName.replace(/@/, ':'); } // /*.vue -> :pathMatch(.*) if (fileName.includes('*')) { - logger.warn(`[WARNING]: ${fileName} is deprecated, please use [...slug]`); + logger.warn(`[WARNING]: filename or directory ${fileName} is deprecated, please use ${fileName.replace('*', '[...]')}`); fileName = fileName.replace('*', ':pathMatch(.*)'); } // /[slug].vue -> /:slug