web
2025-03-18 5eb6903bde0b9be730b35fc116eabf808f8f64e0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!--
 * @Author: hqs elkers@163.com
 * @Date: 2024-05-16 11:24:17
 * @LastEditors: hqs elkers@163.com
 * @LastEditTime: 2024-08-13 14:15:01
 * @FilePath: \wisdom-water-factory-web\src\layout\components\Sidebar\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div :class="{ 'has-logo': showLogo }" :style="{ backgroundColor: sideTheme === 'theme-dark' ? variables.menuBackground : variables.menuLightBackground }">
    <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"
      >
<!--        <app-link :to="'/index'">-->
<!--          <el-menu-item :index="'/index'" >-->
<!--            <svg-icon :icon-class="'dashboard'" />-->
<!--            <template #title><span class="menu-title" :title="'首页'">首页</span></template>-->
<!--          </el-menu-item>-->
<!--        </app-link>-->
 
        <!-- <app-link :to="'/knowledge'">
          <el-menu-item :index="'/knowledge'" >
            <svg-icon :icon-class="'dashboard'" />
            <template #title><span class="menu-title" :title="'首页'">知识库</span></template>
          </el-menu-item>
        </app-link> -->
        <!-- <app-link :to="'/swagger'">
          <el-menu-item :index="'/swagger'" >
            <svg-icon :icon-class="'dashboard'" />
            <template #title><span class="menu-title" :title="'接口文档'">接口文档</span></template>
          </el-menu-item>
        </app-link>
        <app-link :to="'/dict'">
          <el-menu-item :index="'/dict'" >
            <svg-icon :icon-class="'dashboard'" />
            <template #title><span class="menu-title" :title="'数据字典'">数据字典</span></template>
          </el-menu-item>
        </app-link>  -->
        <sidebar-item
          v-for="(route, index) in sidebarRouters"
          :key="route.path + index"
          :item="route"
          :base-path="route.path"
        />
      </el-menu>
    </el-scrollbar>
  </div>
</template>
 
<script setup>
import Logo from './Logo'
import AppLink from './Link'
import SidebarItem from './SidebarItem'
import variables from '@/assets/styles/variables.module.scss'
import useAppStore from '@/store/modules/app'
import useSettingsStore from '@/store/modules/settings'
import usePermissionStore from '@/store/modules/permission'
import { onMounted } from 'vue'
 
const route = useRoute();
const router = useRouter();
 
const appStore = useAppStore()
const settingsStore = useSettingsStore()
const permissionStore = usePermissionStore()
 
const sidebarRouters =  computed(() => permissionStore.sidebarRouters);
const showLogo = computed(() => settingsStore.sidebarLogo);
const sideTheme = computed(() => settingsStore.sideTheme);
const theme = computed(() => settingsStore.theme);
const isCollapse = computed(() => !appStore.sidebar.opened);
 
const activeMenu = computed(() => {
  const { meta, path } = route;
  // if set path, the sidebar will highlight the path you set
  if (meta.activeMenu) {
    return meta.activeMenu;
  }
  return path;
})
onMounted(()=>{
  // console.log('menu, router', router.getRoutes())
})
</script>