Shannon_mu před 3 roky
rodič
revize
ae980b226c

+ 19 - 0
userCenter/src/assets/css/main.scss

@@ -710,3 +710,22 @@ a {
         @include searchTextBotton;
     }
 }
+// 异常页面
+div.box-40 {
+    position: absolute;
+    top: 50%;
+    left: 50%;
+    transform: translate(-50%, -50%);
+    .title {
+        text-align: center;
+        margin-top: 40px;
+        h2 {
+            color: #424656;
+            font-size: 24px;
+        }
+        .text-title {
+            color: #aaadba;
+            margin: 10px 0 20px 0;
+        }
+    }
+}

binární
userCenter/src/assets/img/403.png


binární
userCenter/src/assets/img/404.png


+ 6 - 20
userCenter/src/components/common/Sidebar.vue

@@ -18,7 +18,7 @@
                 router
                 :style="collapse ? 'width:84px' : 'width:220px'"
             >
-                <template v-for="item in siderMenuList">
+                <template v-for="item in thisMenuList">
                     <template v-if="item.children">
                         <el-submenu :index="item.linkPath" :key="item.linkPath">
                             <template slot="title">
@@ -90,7 +90,9 @@ export default {
         };
     },
     computed: {
-        ...mapState(['menuList']),
+        thisMenuList() {
+            return this.$store.getters['getThisMenuList'];
+        },
         onRoutes() {
             if (this.$route.path) {
                 let theme = darkTheme.has(this.$route.path) ? 'dark' : 'light';
@@ -107,30 +109,14 @@ export default {
             return this.$store.getters.getTheme;
         }
     },
-    watch: {
-        menuList(newVal) {
-            this.getMenuList();
-        }
-    },
+
     methods: {
         // 侧边栏折叠
         collapseChage() {
             this.$store.dispatch('collapse', !this.collapse);
-        },
-        getMenuList(resolve) {
-            this.$http.get('/user/findUserMenu', { appId: '1001' }).then(({ status, data, msg }) => {
-                if (0 === status) {
-                    this.siderMenuList = data[0].children;
-                    resolve && resolve(true);
-                }
-            });
         }
     },
-    created() {
-        new Promise((resolve) => {
-            this.getMenuList(resolve);
-        }).then((_) => {});
-    }
+    created() {}
 };
 </script>
 

+ 41 - 11
userCenter/src/main.js

@@ -38,34 +38,64 @@ Vue.use(ElementUI, {
 Vue.prototype.$http = http;
 Vue.prototype.$api = apiService(http);
 
-let defaultPath='';
+let defaultPath = '';
 Vue.prototype.routerLoad = {
-    findOne(arr){
-        return arr.map(v=>{
-            if(v.children){
+    findOne(arr) {
+        return arr.map(v => {
+            if (v.children) {
                 return this.findOne(v.children)
-            }else{
+            } else {
                 return {
-                    path:"/"+v.linkPath,
-                    name:v.name
+                    path: "/" + v.linkPath,
+                    name: v.name
                 }
             }
         })
     },
+    findMen(arr, indexPath) {
+        let status = false;
+        arr.map(v => {
+            if (v.children) {
+                this.findMen(v.children)
+            } else {
+                if (('/' + v.linkPath) === indexPath) {
+                    status = true
+                }
+            }
+        })
+        return status
+    },
+    close() {
+        let activeRout = localStorage.getItem('path');
+        let tagsList = store.getters['getTagsList'];
+        tagsList.forEach((item, index) => {
+            if (item.path == activeRout) {
+                tagsList.splice(index, 1);
+                return true;
+            }
+        });
+    },
     // 获取菜单
     loadMenus() {
         http.get('/user/findUserMenu', { appId: '1001' }).then(({ status, data, msg }) => {
             if (0 === status) {
                 let routerArr = this.findOne(data[0].children);
-                if(routerArr[0].length){
+                store.commit('setThisMenuList', data[0].children);
+                if (routerArr[0].length) {
                     defaultPath = routerArr[0][0].path;
-                }else{
+                } else {
                     defaultPath = routerArr[0].path;
-                }              
+                }
                 if (localStorage.getItem('path') == '/') {
                     localStorage.setItem('path', defaultPath)
                 }
-                router.push({ path: localStorage.getItem('path') })
+                if (this.findMen(data[0].children, localStorage.getItem('path'))) {
+                    router.push({ path: localStorage.getItem('path') })
+                } else {
+                    this.close();
+                    router.replace({ path: '403' })
+                }
+
             }
         });
     }

+ 5 - 1
userCenter/src/router/index.js

@@ -93,7 +93,11 @@ export default new Router({
                     component: () => import(/* webpackChunkName: "appVersionManage" */ '@views/sysManage/appVersionManage'),
                     meta: { title: 'APP版本管理' }
                 },
-
+                {
+                    path: '/403',
+                    component: () => import(/* webpackChunkName: "404" */ '@views/system/403'),
+                    meta: { title: '403' }
+                },
                 {
                     path: '/404',
                     component: () => import(/* webpackChunkName: "404" */ '@views/system/404'),

+ 9 - 0
userCenter/src/store/store.js

@@ -22,6 +22,7 @@ const store = new Vuex.Store({
     permissionList: [],
     //菜单列表
     menuList:[],
+    thisMenuList:[],
     // 当前登录用户信息
     cruUserInfo:{},
     //查询是否有未读消息
@@ -70,6 +71,10 @@ const store = new Vuex.Store({
     getMenuList(state){
       return state.menuList;
     },
+    getThisMenuList(state){
+      return state.thisMenuList;
+    },
+    
     // 获取当前登录用户信息
     getCruUserInfo(state){
       return state.cruUserInfo;
@@ -100,6 +105,10 @@ const store = new Vuex.Store({
     setMenuList(state,data){
       state.menuList = data;
     },
+    setThisMenuList(state,data){
+      state.thisMenuList = data;
+    },
+    
     setcCruUserInfo(state,data){
       state.cruUserInfo = data;
     },

+ 26 - 0
userCenter/src/views/system/403/index.vue

@@ -0,0 +1,26 @@
+<!--
+ * @Description: 
+ * @Date: 2020-11-13 13:30:36
+ * @LastEditTime: 2021-06-01 08:36:34
+ * @FilePath: \WEB\userCenter\src\views\system\404\index.vue
+-->
+<template>
+    <div class="box-40">
+        <img src="@/assets/img/403.png" alt="" />
+        <div class="title">
+            <h2>403</h2>
+            <div class="text-title">抱歉,您无权访问此页面</div>
+            <el-button type="primary" @click="goback()">返回</el-button>
+        </div>
+    </div>
+</template>
+
+<script>
+export default {
+    methods: {
+        goback() {
+            history.go(-1)
+        }
+    }
+};
+</script>

+ 14 - 23
userCenter/src/views/system/404/index.vue

@@ -1,29 +1,20 @@
-<!--
- * @Description: 
- * @Date: 2020-11-13 13:30:36
- * @LastEditTime: 2021-06-01 08:36:34
- * @FilePath: \WEB\userCenter\src\views\system\404\index.vue
--->
 <template>
-    <div class="box-404">
-        <img src="@/assets/img/404.png" alt="">
+    <div class="box-40">
+        <img src="@/assets/img/404.png" alt="" />
+        <div class="title">
+            <h2>404</h2>
+            <div class="text-title">抱歉,您访问的页面不存在</div>
+            <el-button type="primary" @click="goback()">返回</el-button>
+        </div>
     </div>
 </template>
 
-<style lang="scss" scope>
-    div.box-404{
-        width: 100%;
-        height: 100%;
-        img{
-            display: block;
-            width: 500px;
-            height: 156px;
-            position: absolute;
-            left: 0;
-            top: 0;
-            right: 0;
-            bottom: 0;
-            margin: auto;
+<script>
+export default {
+    methods: {
+        goback() {
+            history.go(-1)
         }
     }
-</style>
+};
+</script>