From 049430b1619b44a21c0fae1c86c6e5bcb0b02f03 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Fri, 17 Sep 2021 11:29:26 +0800
Subject: [PATCH] 拦截其他用户查看页面

---
 src/views/util/test.vue         |    2 +-
 src/views/article/article.vue   |    3 ---
 src/store/modules/user.js       |    4 ++++
 src/router/views/index.js       |   11 +++++++++++
 src/page/index/tags.vue         |   31 ++++++++++++++++++++++++++++++-
 src/page/index/top/top-menu.vue |    4 ++--
 src/store/getters.js            |    1 +
 7 files changed, 49 insertions(+), 7 deletions(-)

diff --git a/src/page/index/tags.vue b/src/page/index/tags.vue
index ab14485..51d8a37 100644
--- a/src/page/index/tags.vue
+++ b/src/page/index/tags.vue
@@ -65,6 +65,35 @@
     },
     mounted() {
       this.setActive();
+      this.tagList.forEach((item, index) => {
+        if (item.label == "首页" && (this.userInfo.role_name == "policeAdmin" || this.userInfo.role_name == "administrator")){
+          this.$store.commit("set_hideHome", false);
+        }else if (item.label == "首页" && (this.userInfo.role_name == "操作员")) {
+          this.tagList.splice(index, 1);
+          this.$store.commit("set_hideHome", true);
+          var d = this.$router.options.routes,
+            path = "";
+          for (var k in d) {
+            if (d[k].peixun == true) {
+              // console.log(d[k]);
+              path = d[k].path;
+            }
+          }
+          this.$router.push({ path: path });
+        } else {
+          this.tagList.splice(index, 1);
+          this.$store.commit("set_hideHome", true);
+          var d = this.$router.options.routes,
+            path = "";
+          for (var k in d) {
+            if (d[k].kby == true) {
+              // console.log(d[k]);
+              path = d[k].path;
+            }
+          }
+          this.$router.push({ path: path });
+        }
+      });
     },
     watch: {
       tag() {
@@ -75,7 +104,7 @@
       }
     },
     computed: {
-      ...mapGetters(["tagWel", "tagList", "tag", "website"]),
+      ...mapGetters(["tagWel", "tagList", "tag", "website", "userInfo"]),
       ...mapState({
         showTag: state => state.common.showTag
       }),
diff --git a/src/page/index/top/top-menu.vue b/src/page/index/top/top-menu.vue
index 30cd4a6..8ae7d5c 100644
--- a/src/page/index/top/top-menu.vue
+++ b/src/page/index/top/top-menu.vue
@@ -1,7 +1,7 @@
 <template>
   <div class="top-menu">
     <el-menu :default-active="activeIndex" mode="horizontal" text-color="#333">
-      <el-menu-item index="0" @click.native="openHome(homeItem)" key="0">
+      <el-menu-item index="0" @click.native="openHome(homeItem)" key="0" v-if="!hideHome">
         <template slot="title">
           <i
             style="font-size: 20px !important"
@@ -117,7 +117,7 @@
     ...mapState({
       showMenu: (state) => state.dataL.showdataL,
     }),
-    ...mapGetters(["tagCurrent", "menu"]),
+    ...mapGetters(["tagCurrent", "menu", "hideHome"]),
   },
   methods: {
     openHome(itemHome) {
diff --git a/src/router/views/index.js b/src/router/views/index.js
index 0a8ab3c..b5de0f5 100644
--- a/src/router/views/index.js
+++ b/src/router/views/index.js
@@ -12,6 +12,15 @@
     },
     component: () =>
       import ( /* webpackChunkName: "views" */ '@/views/wel/home')
+  }, {
+    path: 'dashboard',
+    name: '控制台',
+    meta: {
+      i18n: 'dashboard',
+      menu: false,
+    },
+    component: () =>
+      import( /* webpackChunkName: "views" */ '@/views/article/article')
   }]
 },
 
@@ -55,6 +64,7 @@
   {
     path: '/test',
     component: Layout,
+    kby:true,
     redirect: '/test/index',
     children: [{
       path: 'index',
@@ -313,6 +323,7 @@
   }, {
     path: '/article',
     component: Layout,
+    peixun: true,
     redirect: '/article/index',
     children: [{
       path: 'index',
diff --git a/src/store/getters.js b/src/store/getters.js
index 143bd7e..4d948c4 100644
--- a/src/store/getters.js
+++ b/src/store/getters.js
@@ -19,6 +19,7 @@
   roles: state => state.user.roles,
   permission: state => state.user.permission,
   menu: state => state.user.menu,
+  hideHome: state => state.user.hideHome,
   menuId: state => state.user.menuId,
   menuAll: state => state.user.menuAll,
   logsList: state => state.logs.logsList,
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index 609ba23..2dc4e86 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -43,6 +43,7 @@
     menuAll: getStore({name: 'menuAll'}) || [],
     token: getStore({name: 'token'}) || '',
     refreshToken: getStore({name: 'refreshToken'}) || '',
+    hideHome: false,
   },
   actions: {
     //根据用户名登录
@@ -207,6 +208,9 @@
     },
   },
   mutations: {
+    set_hideHome: (state, val) => {
+      state.hideHome = val;
+    },
     SET_TOKEN: (state, token) => {
       setToken(token);
       state.token = token;
diff --git a/src/views/article/article.vue b/src/views/article/article.vue
index f714693..c0300be 100644
--- a/src/views/article/article.vue
+++ b/src/views/article/article.vue
@@ -177,9 +177,6 @@
             {
               label: "发布时间",
               prop: "createTime",
-              addDisplay: false,
-              editDisplay: false,
-              viewDisplay: false,
               type: "date",
               format: "yyyy-MM-dd HH:mm:ss",
               valueFormat: "yyyy-MM-dd HH:mm:ss",
diff --git a/src/views/util/test.vue b/src/views/util/test.vue
index 6609c25..52a0713 100644
--- a/src/views/util/test.vue
+++ b/src/views/util/test.vue
@@ -1,6 +1,6 @@
 <template>
   <div>
-    <basic-container>测试页</basic-container>
+    <basic-container></basic-container>
   </div>
 </template>
 

--
Gitblit v1.9.3