|
@@ -5,8 +5,8 @@ import { emitter } from "@/utils/mitt";
|
|
import SidebarItem from "./sidebarItem.vue";
|
|
import SidebarItem from "./sidebarItem.vue";
|
|
import leftCollapse from "./leftCollapse.vue";
|
|
import leftCollapse from "./leftCollapse.vue";
|
|
import { useNav } from "@/layout/hooks/useNav";
|
|
import { useNav } from "@/layout/hooks/useNav";
|
|
-import { storageLocal } from "@pureadmin/utils";
|
|
|
|
import { responsiveStorageNameSpace } from "@/config";
|
|
import { responsiveStorageNameSpace } from "@/config";
|
|
|
|
+import { storageLocal, isAllEmpty } from "@pureadmin/utils";
|
|
import { findRouteByPath, getParentPaths } from "@/router/utils";
|
|
import { findRouteByPath, getParentPaths } from "@/router/utils";
|
|
import { usePermissionStoreHook } from "@/store/modules/permission";
|
|
import { usePermissionStoreHook } from "@/store/modules/permission";
|
|
import { ref, computed, watch, onMounted, onBeforeUnmount } from "vue";
|
|
import { ref, computed, watch, onMounted, onBeforeUnmount } from "vue";
|
|
@@ -32,7 +32,13 @@ const loading = computed(() =>
|
|
pureApp.layout === "mix" ? false : menuData.value.length === 0 ? true : false
|
|
pureApp.layout === "mix" ? false : menuData.value.length === 0 ? true : false
|
|
);
|
|
);
|
|
|
|
|
|
-function getSubMenuData(path: string) {
|
|
|
|
|
|
+const defaultActive = computed(() =>
|
|
|
|
+ !isAllEmpty(route.meta?.activePath) ? route.meta.activePath : route.path
|
|
|
|
+);
|
|
|
|
+
|
|
|
|
+function getSubMenuData() {
|
|
|
|
+ let path = "";
|
|
|
|
+ path = defaultActive.value;
|
|
subMenuData.value = [];
|
|
subMenuData.value = [];
|
|
// path的上级路由组成的数组
|
|
// path的上级路由组成的数组
|
|
const parentPathArr = getParentPaths(
|
|
const parentPathArr = getParentPaths(
|
|
@@ -48,18 +54,18 @@ function getSubMenuData(path: string) {
|
|
subMenuData.value = parenetRoute?.children;
|
|
subMenuData.value = parenetRoute?.children;
|
|
}
|
|
}
|
|
|
|
|
|
-getSubMenuData(route.path);
|
|
|
|
-
|
|
|
|
watch(
|
|
watch(
|
|
() => [route.path, usePermissionStoreHook().wholeMenus],
|
|
() => [route.path, usePermissionStoreHook().wholeMenus],
|
|
() => {
|
|
() => {
|
|
if (route.path.includes("/redirect")) return;
|
|
if (route.path.includes("/redirect")) return;
|
|
- getSubMenuData(route.path);
|
|
|
|
|
|
+ getSubMenuData();
|
|
menuSelect(route.path);
|
|
menuSelect(route.path);
|
|
}
|
|
}
|
|
);
|
|
);
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
|
+ getSubMenuData();
|
|
|
|
+
|
|
emitter.on("logoChange", key => {
|
|
emitter.on("logoChange", key => {
|
|
showLogo.value = key;
|
|
showLogo.value = key;
|
|
});
|
|
});
|
|
@@ -87,7 +93,7 @@ onBeforeUnmount(() => {
|
|
mode="vertical"
|
|
mode="vertical"
|
|
class="outer-most select-none"
|
|
class="outer-most select-none"
|
|
:collapse="isCollapse"
|
|
:collapse="isCollapse"
|
|
- :default-active="route.path"
|
|
|
|
|
|
+ :default-active="defaultActive"
|
|
:collapse-transition="false"
|
|
:collapse-transition="false"
|
|
>
|
|
>
|
|
<sidebar-item
|
|
<sidebar-item
|