马宇豪
2024-11-15 d8b570430066fae42d6884671cef541fc820de1c
src/layout/components/Sidebar/index.vue
@@ -3,20 +3,20 @@
    <logo v-if="showLogo" :collapse="isCollapse" />
    <el-scrollbar :class="sideTheme" wrap-class="scrollbar-wrapper">
      <el-menu
        :default-active="activeMenu"
        :collapse="isCollapse"
        :background-color="sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground"
        :text-color="sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor"
        :unique-opened="true"
        :active-text-color="theme"
        :collapse-transition="false"
        mode="vertical"
          :default-active="activeMenu"
          :collapse="isCollapse"
          :background-color="sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground"
          :text-color="sideTheme === 'theme-dark' ? variables.menuColor : variables.menuLightColor"
          :unique-opened="true"
          :active-text-color="theme"
          :collapse-transition="false"
          mode="vertical"
      >
        <sidebar-item
          v-for="(route, index) in sidebarRouters"
          :key="route.path + index"
          :item="route"
          :base-path="route.path"
            v-for="(route, index) in sidebarRouters"
            :key="route.path + index"
            :item="route"
            :base-path="route.path"
        />
      </el-menu>
    </el-scrollbar>
@@ -30,6 +30,8 @@
import useAppStore from '@/store/modules/app'
import useSettingsStore from '@/store/modules/settings'
import usePermissionStore from '@/store/modules/permission'
import {computed} from "vue";
import {useRoute} from "vue-router";
const route = useRoute();
const appStore = useAppStore()
@@ -37,6 +39,7 @@
const permissionStore = usePermissionStore()
const sidebarRouters =  computed(() => permissionStore.sidebarRouters);
console.log(sidebarRouters.value,789)
const showLogo = computed(() => settingsStore.sidebarLogo);
const sideTheme = computed(() => settingsStore.sideTheme);
const theme = computed(() => settingsStore.theme);
@@ -48,7 +51,14 @@
  if (meta.activeMenu) {
    return meta.activeMenu;
  }
  return path;
})
  const showRoute  = sidebarRouters.value.filter(item => !item.hidden);
  if(showRoute[0].path === '/'){
    return '/' + showRoute[0].children[0].path
  }else{
    return showRoute[0].path + '/' + showRoute[0].children[0].path
  }
  // return path
})
</script>