Browse Source

代码上传

zhangqi 1 year ago
parent
commit
292524b1fc
2 changed files with 24 additions and 17 deletions
  1. 13 15
      src/router/index.js
  2. 11 2
      src/utils/utils.js

+ 13 - 15
src/router/index.js

@@ -5,7 +5,8 @@ import HDrpManagement from './HDrpManagement.js'
 import SDrpManagement from './SDrpManagement.js'
 import ARDrpManagement from './ARDrpManagement.js'
 import Customized from './DrpCustomized.js'
-
+import utils from '@/utils/utils.js'
+import { message } from 'ant-design-vue';
 
 
 const routes = [
@@ -26,7 +27,7 @@ const routes = [
         meta: {
           title: '数据看板',
           name: 'dataDashboard',
-          keepAlive:true
+          keepAlive:false
         },
         component: ()=>import(/* webpackChunkName: "about" */ '@/views/dataDashboard/index.vue'),
       },
@@ -100,25 +101,22 @@ const router = createRouter({
   routes
 })
 
-router.beforeEach((to, from)=> {
+router.beforeEach((to, from,next)=> {
   useAuthStore().appData(to.meta.name)
   let app = useAuthStore().app
   if (to.name !== '404' && to.name !== 'login') {
-    if (app && app.isneedpay) {
-      return { name: 'modulesPay' }
+    if (!utils.hasAuth(app)) {
+      message.error('未授权该应用,无法访问!')
+    } else {
+      if (app && app.isneedpay) {
+        return { name: 'modulesPay' }
+      }
+      next()
     }
+  } else {
+    next()
   }
   
   
 })
-// router.beforeEach((to, from, next) => {
-//   let str = JSON.stringify(useAuthStore().system)
-//   if(str.includes(to.meta.name) || !to.meta.name) {
-//     next()
-//   } else {
-//     next({
-//       path:'/404'
-//     })
-//   }
-// })
 export default router

+ 11 - 2
src/utils/utils.js

@@ -3,7 +3,7 @@ import { message } from 'ant-design-vue';
 import { create, all } from 'mathjs'
 import { useAuthStore } from "@/stores/modules/auth";
 import { useBaseStore } from '@/stores/modules/base'
-import utils from '@/utils/utils'
+import router from "@/router/index";
 const config = { 
   number: 'BigNumber',
   precision: 20
@@ -13,7 +13,15 @@ let time = null
 const hide = null
 let questArray = [];
 export default {
-
+  // 判断应用是否授权
+  hasAuth (app) {
+    if (!app) {      
+      return false
+    } else {
+      return  true
+    }
+    
+  },
   // 检查权限是否存在
   hasPermission (permission) {
     let hasPermission = true
@@ -172,6 +180,7 @@ export default {
 
   // 金额格式化
   formatAmount(amount, fn) {
+    console.log(fn,'------')
     if (fn !== undefined && !fn) return '****'
     const { hiddenSensitiveFields } = useAuthStore()
     if (hiddenSensitiveFields) return '****'