zhangjie 2 жил өмнө
parent
commit
6e87e3f71c

+ 29 - 0
src/constants/staticMenu.js

@@ -0,0 +1,29 @@
+export default [
+  {
+    id: "h01",
+    name: "首页",
+    url: "HomePage",
+    type: "MENU",
+    parentId: "-1",
+    sequence: 1,
+    enable: true
+  },
+  {
+    id: "h0101",
+    name: "我的工作台",
+    url: "work",
+    type: "MENU",
+    parentId: "h01",
+    sequence: 1,
+    enable: true
+  },
+  {
+    id: "h010101",
+    name: "待办任务",
+    url: "WaitTask",
+    type: "MENU",
+    parentId: "h0101",
+    sequence: 1,
+    enable: true
+  }
+];

+ 26 - 22
src/views/Home.vue

@@ -43,7 +43,7 @@
 
     <div class="home-navs">
       <div class="head-logo">
-        <div class="head-logo-content" @click="toHomePage">
+        <div class="head-logo-content">
           <img v-if="schoolLogo" :src="schoolLogo" alt="知学知考" />
           <h1 v-else>知学知考</h1>
         </div>
@@ -127,6 +127,7 @@ import localMenus from "@/constants/menus-data";
 import { sysMenu, logout } from "../modules/login/api";
 import ResetPwd from "../modules/base/components/ResetPwd";
 import { SYS_ADMIN_NAME } from "@/constants/enumerate";
+import staticMenu from "../constants/staticMenu";
 
 const MENU_ICONS = {
   base: "base",
@@ -134,6 +135,7 @@ const MENU_ICONS = {
   customer: "customer",
   stmms: "book"
 };
+const HOME_PAGE_ROUTE = "HomePage";
 
 export default {
   name: "home",
@@ -166,8 +168,7 @@ export default {
   watch: {
     $route(val) {
       if (val.name === "Home") return;
-      if (this.$route.name === "HomePage") {
-        this.curMenu = { url: "", children: [] };
+      if (this.$route.name === HOME_PAGE_ROUTE) {
         return;
       }
 
@@ -177,7 +178,7 @@ export default {
   computed: {
     ...mapState("exam", ["waitTaskCount"]),
     IS_HOME_PAGE() {
-      return this.$route.name === "HomePage";
+      return this.$route.name === HOME_PAGE_ROUTE;
     }
   },
   created() {
@@ -196,7 +197,7 @@ export default {
 
       if (this.$route.name === "Home") {
         this.$router.replace({
-          name: "HomePage"
+          name: HOME_PAGE_ROUTE
         });
         return;
       }
@@ -222,20 +223,22 @@ export default {
     },
     async initData() {
       const data = await sysMenu();
-      this.initPrivilegeMap(data.privileges);
-      this.privileges = this.transformMenu(data.privileges);
+      const privileges = [...staticMenu, ...data.privileges];
+      this.initPrivilegeMap(privileges);
+      this.privileges = this.transformMenu(privileges);
       this.menus = this.getMenu();
 
       if (this.IS_HOME_PAGE) return;
 
       if (this.$route.name === "Home") {
-        if (this.IS_SUPER_ADMIN) {
-          this.toMenu(this.menus[0]);
-        } else {
-          this.$router.replace({
-            name: "HomePage"
-          });
-        }
+        this.toMenu(this.menus[0]);
+        // if (this.IS_SUPER_ADMIN) {
+        //   this.toMenu(this.menus[0]);
+        // } else {
+        //   this.$router.replace({
+        //     name: HOME_PAGE_ROUTE
+        //   });
+        // }
         return;
       }
 
@@ -312,10 +315,6 @@ export default {
       let privilegeMap = {};
       const pageSetTypes = ["conditions", "buttons", "lists", "links"];
       data.forEach(item => {
-        // const isPage = [...pageSetTypes, "urls"].some(
-        //   type => item[type] && item[type].length
-        // );
-        // if (!isPage) return;
         privilegeMap[item.url] = [];
         pageSetTypes.forEach((type, index) => {
           if (item[type] && item[type].length) {
@@ -338,6 +337,15 @@ export default {
         .map(item => item.url);
     },
     toMenu(menu) {
+      if (menu.url === HOME_PAGE_ROUTE) {
+        if (this.$route.name !== HOME_PAGE_ROUTE) {
+          this.curMenu = menu;
+          this.$router.push({
+            name: HOME_PAGE_ROUTE
+          });
+        }
+        return;
+      }
       if (this.curMenu.url === menu.url) return;
       this.menuChange(menu);
       const firstRouteName = this.getCurMenuFirstRouter();
@@ -393,10 +401,6 @@ export default {
       this.$ls.clear();
       this.$router.push({ name: "Login" });
     },
-    toHomePage() {
-      if (this.IS_SUPER_ADMIN) return;
-      this.$router.push({ name: "HomePage" });
-    },
     toSelectSchool() {
       if (this.IS_SUPER_ADMIN) this.$router.push({ name: "SelectSchool" });
     },

+ 1 - 1
src/views/HomePage.vue

@@ -40,7 +40,7 @@
           </div>
         </div>
       </div>
-      <div v-if="shortcutList.length" class="tab-box tab-shortcut hp-top-right">
+      <div class="tab-box tab-shortcut hp-top-right">
         <h2 class="tab-box-title">快捷入口</h2>
         <div class="tab-box-body shortcut-list">
           <div