From 019e1dd93371374ba11bc827bbb6ed0f2bda66bd Mon Sep 17 00:00:00 2001 From: fangyunong Date: Wed, 13 Aug 2025 15:05:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AEVITE=5FAPI=5FBASE=5FURL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 2 +- .env.production | 2 +- src/utils/permission.ts | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.env.development b/.env.development index d0ccee5..7f414c5 100644 --- a/.env.development +++ b/.env.development @@ -1,2 +1,2 @@ -VITE_API_BASE_URL=http://zeronode.cn +VITE_API_BASE_URL=https://api.zeronode.cn VITE_FRONTEND_CALLBACK_URL=http://localhost:5173/callback \ No newline at end of file diff --git a/.env.production b/.env.production index 1b7268b..0713992 100644 --- a/.env.production +++ b/.env.production @@ -1,3 +1,3 @@ # .env.production (生产环境) -VITE_API_BASE_URL=http://zeronode.cn +VITE_API_BASE_URL=https://api.zeronode.cn VITE_FRONTEND_CALLBACK_URL=http://zeronode.cn/callback # 或者你的生产环境前端URL \ No newline at end of file diff --git a/src/utils/permission.ts b/src/utils/permission.ts index aca4453..dce46b9 100644 --- a/src/utils/permission.ts +++ b/src/utils/permission.ts @@ -15,20 +15,21 @@ interface MenuItem { children?: MenuItem[]; } function getComponent(componentPath: string) { - // 处理view-router特殊路由 - if (componentPath === 'view-router') { + // 如果没有组件路径,返回 RouterView + if (!componentPath) { return RouterView } // 动态导入组件,添加错误处理 return () => { try { - // 尝试动态导入组件 - const componentPromise = import(`../views/${componentPath}`) + // 确保路径包含 .vue 扩展名 + const fullPath = componentPath.endsWith('.vue') ? componentPath : `${componentPath}.vue` + const componentPromise = import(`../views/${fullPath}`) // 成功加载则返回组件 return componentPromise.catch(() => { - console.error(`组件加载失败: @/views/${componentPath}, 回退到404页面`) + console.error(`组件加载失败: @/views/${fullPath}, 回退到404页面`) return NotFound })