Browse Source

首页调整

zhangjie 2 years ago
parent
commit
7b2f118997
5 changed files with 417 additions and 734 deletions
  1. 0 30
      src/assets/styles/home.scss
  2. 407 575
      src/constants/menus-data.js
  3. 1 9
      src/router.js
  4. 9 105
      src/views/Home.vue
  5. 0 15
      src/views/HomePage.vue

+ 0 - 30
src/assets/styles/home.scss

@@ -23,36 +23,6 @@
   min-height: 100%;
 }
 
-.home-page-main {
-  .home-navs {
-    bottom: auto;
-    height: 50px;
-    border-radius: 0;
-    background-color: transparent;
-
-    &::before {
-      display: none;
-    }
-
-    .head-logo-content {
-      padding: 5px 0;
-      border: none;
-    }
-
-    .el-menu {
-      display: none;
-    }
-  }
-
-  .home-breadcrumb {
-    display: none;
-  }
-
-  .home-body-content {
-    padding-left: 30px;
-  }
-}
-
 /* navs */
 .home-navs {
   position: absolute;

File diff suppressed because it is too large
+ 407 - 575
src/constants/menus-data.js


+ 1 - 9
src/router.js

@@ -2,7 +2,6 @@ import Vue from "vue";
 import Router from "vue-router";
 
 import Home from "./views/Home.vue";
-import HomePage from "./views/HomePage.vue";
 import NotFound from "./views/404.vue";
 
 import login from "./modules/login/router";
@@ -37,14 +36,7 @@ let router = new Router({
       path: "/home/:nextRouter?",
       name: "Home",
       component: Home,
-      children: [
-        {
-          path: "/home-page",
-          name: "HomePage",
-          component: HomePage
-        },
-        ...base
-      ]
+      children: [...base]
     },
     { ...login },
     { ...admin },

+ 9 - 105
src/views/Home.vue

@@ -1,5 +1,5 @@
 <template>
-  <div :class="['home', { 'home-page-main': IS_HOME_PAGE }]">
+  <div class="home">
     <div class="home-header">
       <div class="head-menu menu-list">
         <ul>
@@ -12,14 +12,6 @@
             ]"
             @click="toMenu(menu)"
           >
-            <!-- <i
-              :class="[
-                'icon',
-                MENU_ICONS[menu.url]
-                  ? `icon-${MENU_ICONS[menu.url]}`
-                  : 'icon-workspace'
-              ]"
-            ></i> -->
             <span>{{ menu.name }}</span>
           </li>
         </ul>
@@ -45,7 +37,7 @@
       <div class="head-logo">
         <div class="head-logo-content">
           <img v-if="schoolLogo" :src="schoolLogo" :alt="APP_TITLE" />
-          <h1 v-else>{{APP_TITLE}}</h1>
+          <h1 v-else>{{ APP_TITLE }}</h1>
         </div>
       </div>
 
@@ -122,22 +114,12 @@
 </template>
 
 <script>
-import { mapState, mapActions } from "vuex";
 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";
 import { APP_TITLE } from "@/constants/app";
 
-const MENU_ICONS = {
-  base: "base",
-  exam: "exam",
-  customer: "customer",
-  stmms: "book"
-};
-const HOME_PAGE_ROUTE = "HomePage";
-
 export default {
   name: "home",
   components: { ResetPwd },
@@ -146,7 +128,7 @@ export default {
     const IS_SUPER_ADMIN = user.loginName === SYS_ADMIN_NAME;
 
     return {
-      MENU_ICONS,APP_TITLE,
+      APP_TITLE,
       privileges: [],
       menus: [],
       curMenu: { url: "", children: [] },
@@ -169,37 +151,23 @@ export default {
   watch: {
     $route(val) {
       if (val.name === "Home") return;
-      if (this.$route.name === HOME_PAGE_ROUTE) {
-        return;
-      }
-
       this.routerChange();
     }
   },
-  computed: {
-    ...mapState("exam", ["waitTaskCount"]),
-    IS_HOME_PAGE() {
-      return this.$route.name === HOME_PAGE_ROUTE;
-    }
-  },
+  computed: {},
   created() {
-    // this.initData1();
-    this.initData();
+    this.initData1();
+    // this.initData();
   },
   methods: {
-    ...mapActions("exam", ["updateWaitTaskCount"]),
     initData1() {
       // 开发阶段专用
       this.initPrivilegeMap(localMenus);
       this.privileges = this.transformMenu(localMenus);
       this.menus = this.getMenu();
 
-      if (this.IS_HOME_PAGE) return;
-
       if (this.$route.name === "Home") {
-        this.$router.replace({
-          name: HOME_PAGE_ROUTE
-        });
+        this.toMenu(this.menus[0]);
         return;
       }
 
@@ -215,31 +183,15 @@ export default {
         menu => menu.url === this.breadcrumbs[0].url
       );
       this.menuChange(curMenu);
-      if (
-        this.validRoutes.includes("WaitTask") &&
-        this.curMenu.url === "exam"
-      ) {
-        this.updateWaitTaskCount();
-      }
     },
     async initData() {
       const data = await sysMenu();
-      const privileges = [...staticMenu, ...data.privileges];
-      this.initPrivilegeMap(privileges);
-      this.privileges = this.transformMenu(privileges);
+      this.initPrivilegeMap(data.privileges);
+      this.privileges = this.transformMenu(data.privileges);
       this.menus = this.getMenu();
 
-      if (this.IS_HOME_PAGE) return;
-
       if (this.$route.name === "Home") {
         this.toMenu(this.menus[0]);
-        // if (this.IS_SUPER_ADMIN) {
-        //   this.toMenu(this.menus[0]);
-        // } else {
-        //   this.$router.replace({
-        //     name: HOME_PAGE_ROUTE
-        //   });
-        // }
         return;
       }
 
@@ -255,13 +207,6 @@ export default {
         menu => menu.url === this.breadcrumbs[0].url
       );
       this.menuChange(curMenu);
-
-      if (
-        this.validRoutes.includes("WaitTask") &&
-        this.curMenu.url === "exam"
-      ) {
-        this.updateWaitTaskCount();
-      }
     },
     transformMenu(list) {
       return list.map(item => {
@@ -338,15 +283,6 @@ 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();
@@ -373,20 +309,6 @@ export default {
     },
     routerChange() {
       this.updateBreadcrumbs();
-      if (!this.curMenu.url) {
-        // 从HomePage快捷菜单跳转过来的
-        const curMenu = this.menus.find(
-          menu => menu.url === this.breadcrumbs[0].url
-        );
-        this.menuChange(curMenu);
-      }
-
-      if (
-        this.validRoutes.includes("WaitTask") &&
-        this.curMenu.url === "exam"
-      ) {
-        this.updateWaitTaskCount();
-      }
     },
     toLogout() {
       this.$confirm("确定要退出登录吗?", "提示", {
@@ -411,24 +333,6 @@ export default {
     },
     resetPwdModified() {
       this.logoutAction();
-    },
-    // other
-    getSubMenus(menu) {
-      return this.privileges.filter(
-        m => m.parentId === menu.id && m.type === "MENU"
-      );
-    },
-    getFirstRouter() {
-      let childNavs = this.privileges;
-      let firstRouteName = "";
-      while (childNavs.length) {
-        firstRouteName = childNavs[0].url;
-        childNavs = this.privileges.filter(
-          item => item.parentId === childNavs[0].id
-        );
-      }
-
-      return firstRouteName;
     }
   }
 };

+ 0 - 15
src/views/HomePage.vue

@@ -1,15 +0,0 @@
-<template>
-  <div class="home-page">
-    home-page
-  </div>
-</template>
-
-<script>
-export default {
-  name: "home-page",
-  data() {
-    return {};
-  },
-  methods: {}
-};
-</script>

Some files were not shown because too many files changed in this diff