Quellcode durchsuchen

build: 路由调整

chaooo vor 2 Jahren
Ursprung
Commit
4786f9677a

+ 2 - 2
src/layout/components/Navbar.vue

@@ -86,11 +86,11 @@ watch(
   <div class="navbar">
     <!-- 左侧面包屑 -->
     <div class="flex">
-      <hamburger
+      <Hamburger
         :is-active="appStore.sidebar.opened"
         @toggle-click="toggleSideBar"
       />
-      <breadcrumb />
+      <Breadcrumb />
     </div>
     <!-- 右侧导航设置 -->
     <div class="flex">

+ 11 - 8
src/layout/components/Sidebar/SidebarItem.vue

@@ -13,7 +13,6 @@ const props = defineProps({
     type: Object,
     required: true,
   },
-
   /**
    * 父层级完整路由路径(eg:/level/level_3/level_3_1)
    */
@@ -24,7 +23,6 @@ const props = defineProps({
 });
 
 const onlyOneChild = ref(); // 临时变量,唯一子路由
-
 /**
  * 判断当前路由是否只有一个子路由
  *
@@ -41,13 +39,21 @@ function hasOneShowingChild(children = [], parent: any) {
       return false; // 过滤不显示的子路由
     } else {
       onlyOneChild.value = item; // 唯一子路由赋值(多个子路由情况 onlyOneChild 变量是用不上的)
+      //console.log(item);
       return true;
     }
   });
 
   // 1:如果只有一个子路由, 返回 true
   if (showingChildren.length === 1) {
-    return true;
+    if (showingChildren[0].children) {
+      return hasOneShowingChild(
+        showingChildren[0].children,
+        showingChildren[0]
+      );
+    } else {
+      return true;
+    }
   }
 
   // 2:如果无子路由, 复制当前路由信息作为其子路由,满足只拥有一个子路由的条件,所以返回 true
@@ -77,13 +83,13 @@ function resolvePath(routePath: string) {
 </script>
 <template>
   <div v-if="!item.meta || !item.meta.hidden">
-    <!-- 只包含一个子路由节点的路由,显示其【唯一子路由】 -->
     <template
       v-if="
         hasOneShowingChild(item.children, item) &&
         (!onlyOneChild.children || onlyOneChild.noShowingChildren)
       "
     >
+      <!-- 只包含一个子路由节点的路由,显示其【唯一子路由】 -->
       <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
         <el-menu-item :index="resolvePath(onlyOneChild.path)">
           <svg-icon
@@ -96,18 +102,15 @@ function resolvePath(routePath: string) {
         </el-menu-item>
       </app-link>
     </template>
-
-    <!-- 包含多个子路由  -->
     <el-sub-menu v-else :index="resolvePath(item.path)" teleported>
+      <!-- 包含多个子路由  -->
       <template #title>
         <svg-icon
           v-if="item.meta && item.meta.icon"
           :icon-class="item.meta.icon"
         />
         <span v-if="item.meta && item.meta.title">{{ item.meta.title }}</span>
-        <!--        <el-icon><ArrowRightBold color="#ffffff" /></el-icon>-->
       </template>
-
       <sidebar-item
         v-for="child in item.children"
         :key="child.path"

+ 77 - 12
src/store/modules/permission.ts

@@ -13,17 +13,23 @@ const schoolRoutes: RouteRecordRaw[] = JSON.parse(
     {
       path: "/",
       redirect: "/areaboard",
-      meta: { hidden: true },
+      meta: { hidden: true, name: "Home" },
     },
     {
       path: "/areaboard",
       component: "AdminIndex",
       redirect: "/areaboard/index",
+      meta: { title: "数据看板", name: "Dashboard" },
       children: [
         {
           path: "index",
           component: "areaboard/index",
-          meta: { title: "区域级数据看板", icon: "board", keepAlive: true },
+          meta: {
+            title: "区域级数据看板",
+            name: "DashboardArea",
+            icon: "board",
+            keepAlive: true,
+          },
         },
       ],
     },
@@ -35,22 +41,33 @@ const adminRoutes: RouteRecordRaw[] = JSON.parse(
     {
       path: "/",
       redirect: "/dashboard",
-      meta: { hidden: true },
+      meta: { hidden: true, name: "Home" },
     },
     {
       path: "/dashboard",
       component: "SchoolIndex",
       redirect: "/dashboard/index",
+      meta: { title: "数据看板", name: "Dashboard" },
       children: [
         {
           path: "index",
           component: "dashboard/index",
-          meta: { title: "数据看板", icon: "board", keepAlive: true },
+          meta: {
+            title: "数据看板",
+            name: "DashboardIndex",
+            icon: "board",
+            keepAlive: true,
+            breadcrumb: false,
+          },
         },
         {
           path: "example",
           component: "dashboard/example",
-          meta: { title: "数据看板示例", hidden: true },
+          meta: {
+            title: "数据看板示例",
+            name: "DashboardExample",
+            hidden: true,
+          },
         },
       ],
     },
@@ -58,11 +75,18 @@ const adminRoutes: RouteRecordRaw[] = JSON.parse(
       path: "/class",
       component: "SchoolIndex",
       redirect: "/class/index",
+      meta: { title: "班级管理", name: "ClassManage" },
       children: [
         {
           path: "index",
           component: "class/index",
-          meta: { title: "班级管理", icon: "class", keepAlive: true },
+          meta: {
+            title: "班级管理",
+            name: "ClassIndex",
+            icon: "class",
+            keepAlive: true,
+            breadcrumb: false,
+          },
         },
       ],
     },
@@ -70,11 +94,18 @@ const adminRoutes: RouteRecordRaw[] = JSON.parse(
       path: "/teacher",
       component: "SchoolIndex",
       redirect: "/teacher/index",
+      meta: { title: "教师管理", name: "TeacherManage" },
       children: [
         {
           path: "index",
           component: "teacher/index",
-          meta: { title: "教师管理", icon: "teacher", keepAlive: true },
+          meta: {
+            title: "教师管理",
+            name: "TeacherIndex",
+            icon: "teacher",
+            keepAlive: true,
+            breadcrumb: false,
+          },
         },
       ],
     },
@@ -82,11 +113,23 @@ const adminRoutes: RouteRecordRaw[] = JSON.parse(
       path: "/student",
       component: "SchoolIndex",
       redirect: "/student/index",
+      meta: { title: "学生管理", name: "StudentManage" },
       children: [
         {
           path: "index",
           component: "student/index",
-          meta: { title: "学生管理", icon: "student", keepAlive: true },
+          meta: {
+            title: "学生管理",
+            name: "StudentIndex",
+            icon: "student",
+            keepAlive: true,
+            breadcrumb: false,
+          },
+        },
+        {
+          path: "result",
+          component: "student/result",
+          meta: { title: "训练效果分析", name: "StudentResult", hidden: true },
         },
       ],
     },
@@ -94,11 +137,18 @@ const adminRoutes: RouteRecordRaw[] = JSON.parse(
       path: "/equipment",
       component: "SchoolIndex",
       redirect: "/equipment/index",
+      meta: { title: "设备管理", name: "EquipmentManage" },
       children: [
         {
           path: "index",
           component: "equipment/index",
-          meta: { title: "设备管理", icon: "equipment", keepAlive: true },
+          meta: {
+            title: "设备管理",
+            name: "EquipmentIndex",
+            icon: "equipment",
+            keepAlive: true,
+            breadcrumb: false,
+          },
         },
       ],
     },
@@ -106,11 +156,18 @@ const adminRoutes: RouteRecordRaw[] = JSON.parse(
       path: "/training",
       component: "SchoolIndex",
       redirect: "/training/index",
+      meta: { title: "训练管理", name: "TrainingManage" },
       children: [
         {
-          path: "inxdex",
+          path: "index",
           component: "training/index",
-          meta: { title: "训练管理", icon: "training", keepAlive: true },
+          meta: {
+            title: "训练管理",
+            name: "TrainingIndex",
+            icon: "training",
+            keepAlive: true,
+            breadcrumb: false,
+          },
         },
       ],
     },
@@ -118,11 +175,18 @@ const adminRoutes: RouteRecordRaw[] = JSON.parse(
       path: "/evaluation",
       component: "SchoolIndex",
       redirect: "/evaluation/index",
+      meta: { title: "测评数据看板", name: "EvaluateManage" },
       children: [
         {
           path: "index",
           component: "evaluation/index",
-          meta: { title: "测评数据看板", icon: "evaluation", keepAlive: true },
+          meta: {
+            title: "测评数据看板",
+            name: "EvaluateIndex",
+            icon: "evaluation",
+            keepAlive: true,
+            breadcrumb: false,
+          },
         },
       ],
     },
@@ -145,6 +209,7 @@ const filterAsyncRoutes = (routes: RouteRecordRaw[], roles: string[]) => {
       tmpRoute.component = Layout;
       console.log("SchoolIndex");
     } else if (tmpRoute.component?.toString() == "AdminIndex") {
+      tmpRoute.component = Admin;
       console.log("AdminIndex");
     } else {
       const component = modules[`../../views/${tmpRoute.component}.vue`];

+ 24 - 0
src/views/student/result.vue

@@ -0,0 +1,24 @@
+<script setup lang="ts">
+defineOptions({
+  name: "EvaluationViews",
+  inheritAttrs: false,
+});
+import { watch } from "vue";
+import { useUserStore } from "@/store/modules/user";
+const userStore = useUserStore();
+watch(
+  () => userStore.schoolId,
+  (newValue, oldValue) => {
+    console.log(newValue, oldValue);
+  }
+);
+</script>
+
+<template>
+  <div class="container">
+    <h1>训练效果分析</h1>
+    <div>{{ userStore.schoolId }}</div>
+  </div>
+</template>
+
+<style lang="scss" scoped></style>