From e03d73bb48872b8851fad71af2b2c52afd85fa60 Mon Sep 17 00:00:00 2001 From: hxr <1490493387@qq.com> Date: Tue, 15 Aug 2023 05:35:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20:bug:=20=E8=A1=A5=E5=85=85=20basePath=20?= =?UTF-8?q?=E7=88=B6=E7=BA=A7=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: cce921b52b3f93fb9be8d9619c788a5b1b585fe9 --- src/layout/components/Sidebar/LeftMenu.vue | 27 ++++++++++++++++++- src/layout/components/Sidebar/SidebarItem.vue | 2 ++ src/layout/components/Sidebar/index.vue | 2 +- src/layout/index.vue | 14 +++++----- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/layout/components/Sidebar/LeftMenu.vue b/src/layout/components/Sidebar/LeftMenu.vue index bae939cf..16d13282 100644 --- a/src/layout/components/Sidebar/LeftMenu.vue +++ b/src/layout/components/Sidebar/LeftMenu.vue @@ -5,6 +5,9 @@ import { useSettingsStore } from "@/store/modules/settings"; import { useAppStore } from "@/store/modules/app"; import variables from "@/styles/variables.module.scss"; +import path from "path-browserify"; +import { isExternal } from "@/utils/index"; + const settingsStore = useSettingsStore(); const appStore = useAppStore(); const currRoute = useRoute(); @@ -17,7 +20,29 @@ const props = defineProps({ }, type: Array, }, + basePath: { + type: String, + required: true, + }, }); + +/** + * 解析路径 + * + * @param routePath 路由路径 + */ +function resolvePath(routePath: string) { + if (isExternal(routePath)) { + return routePath; + } + if (isExternal(props.basePath)) { + return props.basePath; + } + + // 完整路径 = 父级路径(/level/level_3) + 路由路径 + const fullPath = path.resolve(props.basePath, routePath); // 相对路径 → 绝对路径 + return fullPath; +}