Sidebar.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <div class="sidebar">
  3. <el-menu
  4. class="sidebar-el-menu"
  5. :default-active="onRoutes"
  6. :collapse="collapse"
  7. background-color="#000000"
  8. text-color="#bfcbd9"
  9. active-text-color="#20a0ff"
  10. unique-opened
  11. router
  12. >
  13. <template v-for="item in items">
  14. <template v-if="item.subs">
  15. <el-submenu :index="item.index" :key="item.index">
  16. <template #title>
  17. <i :class="item.icon"></i>
  18. <span>{{ item.title }}</span>
  19. </template>
  20. <template v-for="subItem in item.subs">
  21. <el-submenu v-if="subItem.subs" :index="subItem.index" :key="subItem.index">
  22. <template #title>{{ subItem.title }}</template>
  23. <el-menu-item v-for="(threeItem, i) in subItem.subs" :key="i" :index="threeItem.index">
  24. {{ threeItem.title }}</el-menu-item>
  25. </el-submenu>
  26. <el-menu-item v-else :index="subItem.index" :key="subItem.index">{{ subItem.title }}
  27. </el-menu-item>
  28. </template>
  29. </el-submenu>
  30. </template>
  31. <template v-else>
  32. <el-menu-item :index="item.index.toString()" :key="item.index">
  33. <i :class="item.icon"></i>
  34. <template #title>{{ item.title }}</template>
  35. </el-menu-item>
  36. </template>
  37. </template>
  38. </el-menu>
  39. </div>
  40. </template>
  41. <script>
  42. import { computed } from "vue";
  43. import { useStore } from "vuex";
  44. import { useRoute, useRouter } from "vue-router";
  45. export default {
  46. setup() {
  47. const items = [
  48. // {
  49. // icon: "el-icon-lx-file",
  50. // title: "我的文件",
  51. // index:3,
  52. // subs: [
  53. // {
  54. // index: "/fileList",
  55. // title: "我的文件"
  56. // },
  57. // {
  58. // index: "/fileDetail",
  59. // title: "文件详情",
  60. // },
  61. // {
  62. // index: "/upload",
  63. // title: "文件上传",
  64. // },
  65. // ]
  66. // },
  67. {
  68. icon: "el-icon-lx-file",
  69. index: "/fileList",
  70. title: "我的文件",
  71. },
  72. {
  73. icon: "el-icon-lx-cascades",
  74. title: "配置",
  75. index: 1,
  76. subs: [
  77. {
  78. index: "/config",
  79. title: "模型配置"
  80. },
  81. {
  82. index: "/analysisConfig",
  83. title: "数据统计配置",
  84. },
  85. ]
  86. },
  87. // {
  88. // icon: "el-icon-star-off",
  89. // index: "/modelDetail",
  90. // title: "模型训练",
  91. // },
  92. {
  93. icon: "el-icon-coin",
  94. index: "/modelList",
  95. title:"机器学习模型",
  96. },
  97. // {
  98. // icon: "el-icon-coin",
  99. // index: "/dlModelList",
  100. // title:"深度学习模型",
  101. // },
  102. // {
  103. // icon: "el-icon-data-board",
  104. // index: "/charts",
  105. // title: "预测结果",
  106. // },
  107. {
  108. icon: "el-icon-pie-chart",
  109. index: "/analysis",
  110. title: "数据分析",
  111. },
  112. {
  113. icon: "el-icon-odometer",
  114. title: "流水线",
  115. index: 2,
  116. subs: [
  117. {
  118. index: "/mlPipeline",
  119. title: "机器学习流水线"
  120. },
  121. {
  122. index: "/analysisPipeline",
  123. title: "数据分析流水线",
  124. },
  125. ]
  126. },
  127. {
  128. icon: "el-icon-office-building",
  129. index: "/square",
  130. title: "数据广场",
  131. },
  132. // 无用组件
  133. // {
  134. // icon: "el-icon-user",
  135. // index: "/user",
  136. // title: "个人中心",
  137. // },
  138. // {
  139. // icon: "el-icon-lx-calendar",
  140. // index: "3",
  141. // title: "表单相关",
  142. // subs: [
  143. // {
  144. // index: "/form",
  145. // title: "基本表单",
  146. // },
  147. // {
  148. // index: "/upload",
  149. // title: "文件上传",
  150. // },
  151. // {
  152. // index: "4",
  153. // title: "三级菜单",
  154. // subs: [
  155. // {
  156. // index: "/editor",
  157. // title: "富文本编辑器",
  158. // },
  159. // ],
  160. // },
  161. // ],
  162. // },
  163. // {
  164. // icon: "el-icon-lx-emoji",
  165. // index: "/icon",
  166. // title: "自定义图标",
  167. // },
  168. // {
  169. // icon: "el-icon-lx-global",
  170. // index: "/i18n",
  171. // title: "国际化功能",
  172. // },
  173. // {
  174. // icon: "el-icon-lx-warn",
  175. // index: "7",
  176. // title: "错误处理",
  177. // subs: [
  178. // {
  179. // index: "/permission",
  180. // title: "权限测试",
  181. // },
  182. // {
  183. // index: "/404",
  184. // title: "404页面",
  185. // },
  186. // ],
  187. // },
  188. // {
  189. // icon: "el-icon-lx-redpacket_fill",
  190. // index: "/donate",
  191. // title: "支持作者",
  192. // }
  193. ];
  194. const route = useRoute();
  195. //const router = useRouter();
  196. const onRoutes = computed(() => {
  197. return route.path;
  198. });
  199. // const onRouters = computed(() => {
  200. // return router.path;
  201. // });
  202. const store = useStore();
  203. const collapse = computed(() => store.state.collapse);
  204. return {
  205. items,
  206. onRoutes,
  207. //onRouters,
  208. collapse,
  209. };
  210. },
  211. };
  212. </script>
  213. <style scoped>
  214. .sidebar {
  215. display: block;
  216. position: absolute;
  217. left: 0;
  218. top: 70px;
  219. bottom: 0;
  220. overflow-y: scroll;
  221. }
  222. .sidebar::-webkit-scrollbar {
  223. width: 0;
  224. }
  225. .sidebar-el-menu:not(.el-menu--collapse) {
  226. width: 250px;
  227. }
  228. .sidebar > ul {
  229. height: 100%;
  230. }
  231. </style>