Browse Source

处理路由逻辑

zhangqiOMG 2 years ago
parent
commit
83b081f7e5

+ 13 - 5
src/components/layout/index.vue

@@ -5,11 +5,11 @@
         <div class="logo-avatar">
           <img v-show="img.usetype === 'actionlogo'" v-for="img in siteinfo.attinfos" :key="img.index" style="width:100%" :src="img.url" alt="">
         </div>
-        <div class="item" :class="routerName === '工作台'?'active':''" @click="($router.push('/home'),act_id = 0)">
+        <div class="item" :class="routerName === '工作台'?'active':''" @click="($router.push('/home'),act_id = null)">
           <img width="30" src="../../assets/nav_icon/work_station.svg" alt="">
           <p>工作台</p>
         </div>
-        <div class="item" :class="routerName === '消息中心'?'active':''" @click="($router.push('/message'),act_id = 0)">
+        <div class="item" :class="routerName === '消息中心'?'active':''" @click="($router.push('/message'),act_id = null)">
           <img width="30" src="../../assets/nav_icon/work_station.svg" alt="">
           <p>消息</p>
         </div>
@@ -33,7 +33,7 @@
         <el-button size="mini" @click="$router.go(-1)">返 回</el-button>
       </div>
       <el-container class="mymain">
-        <el-aside v-if="ast_nav" width="200px"><myaside></myaside></el-aside>
+        <el-aside v-if="ast_nav" width="200px"><myaside ref="aside"></myaside></el-aside>
         <el-container>
           <el-main>
             <router-view></router-view>
@@ -68,7 +68,7 @@ export default {
     return {
       routerName:'',
       modeuls:[],
-      act_id:0
+      act_id:null
     }
   },
   methods:{
@@ -85,9 +85,16 @@ export default {
     },
     redictToModules (item) {
       this.act_id = item.systemmoduleid
-      this.$router.push({path:item.apps[0].path})
+      // 保存当前进入的模块数据
       sessionStorage.setItem('active_modules',JSON.stringify(item))
+      // 跳转
+      this.$router.push({path:item.apps[0].path})
+
       window.sessionStorage.setItem('currentPath',item.apps[0].path)
+      // 查询侧边栏应用数据
+      setTimeout(() => {
+        this.$refs['aside'].getAuthList()
+      }, 0);
     },
     async deleteShortcut (item) {
       const res = await this.$api.requested({
@@ -98,6 +105,7 @@ export default {
         }
       })
       this.$store.dispatch('setUsershortcuts')
+      this.$router.go(-1)
     }
   },
   created () {

+ 1 - 1
src/components/layout/modules/aside.vue

@@ -45,7 +45,7 @@ export default {
     }
   },
   
-  created () {    
+  mounted () {    
     this.getAuthList()
   },
   watch:{

+ 4 - 3
src/components/socketMessage/index.vue

@@ -19,7 +19,8 @@
         id:'',
         path:"ws://121.37.152.76:8080/yos/webSocket/",
         panelIsShow:false,
-        list:[]
+        list:[],
+        total:0,
       }
     },
     created () {
@@ -73,7 +74,7 @@
           }
       },
       open: function (val) {
-          console.log("socket连接成功",val)
+          // console.log("socket连接成功",val)
       },
       error: function () {
           console.log("连接错误")
@@ -92,7 +93,7 @@
       contectIsLive () {
         const params = 'isalive'
         this.realTimeClData = setInterval(() => {
-          console.log('监测连接')
+          // console.log('监测连接')
           this.socket.send(JSON.stringify(params))
         }, 1000);
       }

+ 6 - 4
src/store/index.js

@@ -14,7 +14,8 @@ export default new Vuex.Store({
     },
     deplist:[],
     sys_options:[],
-    shortcutlist:[]
+    shortcutlist:[],
+    active_modules:{}
   },
   getters: {
     siteinfo:state => state.siteinfo,
@@ -22,7 +23,8 @@ export default new Vuex.Store({
     deplist:state =>  state.deplist,
     sys_options:state => state.sys_options,
     pageOnlyRead:state => state.pageOnlyRead,
-    shortcutlist:state => state.shortcutlist
+    shortcutlist:state => state.shortcutlist,
+    active_modules:state => state.active_modules
   },
   mutations: {
     setSiteInfo(state,res) {
@@ -36,7 +38,7 @@ export default new Vuex.Store({
     },
     setUsershortcuts (state,param) {
       state.shortcutlist = [...param]
-    },
+    }
   },
   actions: {
     // 系统选项分类查询
@@ -107,7 +109,7 @@ export default new Vuex.Store({
         })
       })
       commit('setUsershortcuts',arr)
-    },
+    }
   },
   modules: {
   },

+ 19 - 13
src/utils/tool.js

@@ -1,22 +1,28 @@
 import { Notification } from 'element-ui';
+import router from '@/router';
 
 export default {
   // 获取应用权限
   checkAuth (appname,auth) {
-    // 获取应用数据
-    let apps = JSON.parse(sessionStorage.getItem('active_modules'))
-    
-    let module_list =  apps.apps
-    // 获取当前应用数据
-    let active_modules = module_list.filter(item => {
-      return item.name === appname
-    })
-    // 获取当前应用权限
-    let auth_list = active_modules[0].meta.auth
-    // 判断是否拥有权限
-    let _haveAuth = auth_list.some(item=>item.option === auth)
+    try {
+      // 获取应用数据
+      let apps = JSON.parse(sessionStorage.getItem('active_modules'))
+      
+      let module_list =  apps.apps
+      // 获取当前应用数据
+      let active_modules = module_list.filter(item => {
+        return item.name === appname
+      })
+      // 获取当前应用权限
+      let auth_list = active_modules[0].meta.auth
+      // 判断是否拥有权限
+      let _haveAuth = auth_list.some(item=>item.option === auth)
 
-    return _haveAuth
+      return _haveAuth
+    } catch (error) {
+      router.replace('/home')
+    }
+   
   },
 
   // 获取应用表格

+ 1 - 2
src/views/mediaStock/index.vue

@@ -50,8 +50,7 @@ export default {
   methods:{
     // 监听新建按钮
     addClick () {
-      this.$refs.list.list.push({
-        newfolder:true,
+      this.$refs['add'].createFolderComplete({
         document:'新建文件夹',
         postfix:'FOLDER'
       })