Browse Source

添加路由守卫

lisiyan 2 years ago
parent
commit
8550c6a6a2

+ 14 - 0
src/router/index.js

@@ -1,5 +1,6 @@
 import Vue from "vue"
 import VueRouter from "vue-router"
+import { userStore } from '@/store/userInfo'
 
 Vue.use(VueRouter)
 
@@ -118,5 +119,18 @@ const router = new VueRouter({
     },
   ],
 })
+router.beforeEach((to, from, next) => {
+  const whiteList = '/login'
+  if (to.path !== whiteList && to.path !== '/creat' && to.path !== '/noadmin') {
+    if (parseInt(userStore().user.role) === 1 || parseInt(userStore().user.role) === 2) {
+      next()
+    } else {
+      next('/noadmin')
+    }
+  } else {
+    next()
+  }
+  next()
+})
 
 export default router

+ 8 - 2
src/views/Assignlicense.vue

@@ -77,7 +77,7 @@ export default {
       || this.memberId === '' || this.memberId == undefined || this.memberId == null || this.memberId.length <= 0
       || this.signleProduct === '' || this.signleProduct == undefined || this.signleProduct == null || this.signleProduct.length <= 0
       ) {
-        this.$message.error('Missing required information')
+        this.$message.error({message: 'Missing required information', duration: 5000})
         return
       }
       if (this.singleLoading) return
@@ -95,15 +95,18 @@ export default {
         }, 1000)
         if (res.data.code === 200 && res.data.msg == ' Assign Success!') {
           this.$message({
+            duration: 5000,
             message: 'Assign Success!',
             type: 'success'
           })
         } else if(res.data.code === 700 && res.data.msg == 'Please add the user to a team which has remaining license first'){
           this.$message.error({
+            duration: 5000,
             message: 'Please add the user to a team which has remaining license first',
           })
         } else if(res.data.code === 700 && res.data.msg == 'Please allocate more license to the team first'){
           this.$message.error({
+            duration: 5000,
             message: 'Please allocate more license to the team first',
           })
         }
@@ -113,7 +116,7 @@ export default {
       if (this.teamAssign === ''
       || this.teamProduct === '' || this.teamProduct == undefined || this.teamProduct == null || this.teamProduct.length <= 0
       ) {
-        this.$message.error('Missing required information')
+        this.$message.error({duration: 5000,message: 'Missing required information'})
         return
       }
       if (this.teamLoading) return
@@ -130,15 +133,18 @@ export default {
         }, 1000)
         if (res.data.code === 200 && res.data.msg == ' Assign Success!') {
           this.$message({
+            duration: 5000,
             message: 'Assign Success!',
             type: 'success'
           })
         } else if(res.data.code === 700 && res.data.msg == 'Please add the user to a team which has remaining license first'){
           this.$message.error({
+            duration: 5000,
             message: 'Please add the user to a team which has remaining license first',
           })
         } else if(res.data.code === 700 && res.data.msg == 'Please allocate more license to the team first'){
           this.$message.error({
+            duration: 5000,
             message: 'Please allocate more license to the team first',
           })
         }

+ 6 - 0
src/views/Create.vue

@@ -111,6 +111,7 @@ export default {
               ) {
                 this.verificationCodeError = true
                 this.$message.error({
+                  duration: 5000,
                   message: 'False Code,please check again'
                 })
               } else if (
@@ -120,6 +121,7 @@ export default {
                 this.passwordError = true
                 this.passwordConfirmError = true
                 this.$message.error({
+                  duration: 5000,
                   message: 'Password must between 6-24 characters'
                 })
               } else if (
@@ -129,6 +131,7 @@ export default {
                 this.passwordError = true
                 this.passwordConfirmError = true
                 this.$message.error({
+                  duration: 5000,
                   message: 'Different Password'
                 })
               } else if (
@@ -137,6 +140,7 @@ export default {
               ) {
                 this.EmailCodeError = true
                 this.$message.error({
+                  duration: 5000,
                   message: 'Email has been created'
                 })
               } else if (
@@ -144,6 +148,7 @@ export default {
                 res.data.msg === '注册成功'
               ) {
                 this.$message({
+                  duration: 5000,
                   message: 'Create Success',
                   type: 'success'
                 })
@@ -155,6 +160,7 @@ export default {
       } else {
         this.checkBox = true
         this.$message.error({
+          duration: 5000,
           message:
             'Please read and confirm POLICY OF PRIVACY and TERMS OF USE first'
         })

+ 1 - 1
src/views/Dashboard.vue

@@ -114,7 +114,7 @@ export default {
           })
           this.drawLine()
         } else {
-          this.$message.error(res.data.msg)
+          this.$message.error({duration: 5000, message: res.data.msg})
         }
       })
     },

+ 1 - 0
src/views/Device.vue

@@ -115,6 +115,7 @@ export default {
           if (res.data.code === 200 && res.data.msg == ' Canceled!') {
             this.dialogVisible = false
             this.$message({
+              duration: 5000,
               message: 'Canceled',
               type: 'success'
             })

+ 1 - 0
src/views/LicenseManage.vue

@@ -141,6 +141,7 @@ const cancelAssign = () => {
       if (res.data.code === 200 && res.data.msg == ' Assign Success!') {
         dialogVisible.value = false
         proxy.$message({
+          duration: 5000,
           message: 'Assign Success!',
           type: 'success'
         })

+ 8 - 0
src/views/Login.vue

@@ -112,6 +112,7 @@ export default {
                 this.passwordError = true
                 this.ruleForm.password = ''
                 this.$message.error({
+                  duration: 5000,
                   message: 'Please Check your password'
                 })
               } else if (
@@ -123,6 +124,7 @@ export default {
                 this.ruleForm.password = ''
                 this.ruleForm.email = ''
                 this.$message.error({
+                  duration: 5000,
                   message: 'Please Create your Account first'
                 })
               }
@@ -143,6 +145,12 @@ export default {
       } else {
         this.empty = true
       }
+      if (this.ruleForm.email.trim() !== '') {
+        this.emailError = false
+      }
+      if (this.ruleForm.password.trim() !== '') {
+        this.passwordError = false
+      }
     }
   }
 }

+ 2 - 0
src/views/MenageAdmin/addAdmin.vue

@@ -34,11 +34,13 @@ export default {
           post('/pdf-tech/vppTeam/sendEmailForAddTeamAdmin', urlencoded).then((res)=>{
             if(res.data.code === 200){
               this.$message({
+                duration: 5000,
                 message: 'Change Success',
                 type: "success",
               })
             } else if(res.data.msg === "Member has joined a non-default team"){
               this.$message({
+                duration: 5000,
                 message: 'Member has joined a non-default team',
                 type: "error",
               })

+ 2 - 1
src/views/MenageAdmin/editAdmin.vue

@@ -39,11 +39,12 @@ export default {
         urlencoded.append("memberId", this.memberId)
         urlencoded.append("teamIds", this.formData.TeamAdmin)
         if (this.formData.TeamAdmin.length === 0) {
-          this.$message.error('Please choose a team')
+          this.$message.error({duration: 5000, message: 'Please choose a team'})
         } else {
           post( '/pdf-tech/vppTeam/editTeamAdmin',urlencoded ).then((res)=>{
             if(res.data.code === 200){
                 this.$message({
+                  duration: 5000,
                   message: 'Change Success',
                   type: "success",
                 })

+ 6 - 0
src/views/Settings.vue

@@ -62,6 +62,7 @@ export default {
               res.data.msg === 'Password updated successfully'
             ) {
               this.$message({
+                duration: 5000,
                 message: 'Change Success',
                 type: 'success'
               })
@@ -71,6 +72,7 @@ export default {
               res.data.msg === 'Old Password error'
             ) {
               this.$message.error({
+                duration: 5000,
                 message: 'Old Password error'
               })
             } else if (
@@ -78,6 +80,7 @@ export default {
               res.data.msg === 'Please Create your Account first'
             ) {
               this.$message.error({
+                duration: 5000,
                 message: 'Please Create your Account first'
               })
             }
@@ -102,6 +105,7 @@ export default {
             }, 1000)
             if (res.data.code === 200 && res.data.msg === 'success') {
               this.$message({
+                duration: 5000,
                 message: 'Change Success',
                 type: 'success'
               })
@@ -111,6 +115,7 @@ export default {
               res.data.msg === '账号或者密码错误'
             ) {
               this.$message.error({
+                duration: 5000,
                 message: 'Please Check your password'
               })
             } else if (
@@ -118,6 +123,7 @@ export default {
               res.data.msg === 'Please Create your Account first'
             ) {
               this.$message.error({
+                duration: 5000,
                 message: 'Please Create your Account first'
               })
             }

+ 4 - 1
src/views/TeamManagement/ManageMember/AddManageMember.vue

@@ -26,7 +26,7 @@ export default {
       if(this.click){
         this.click = false
         if (this.formData.memberEmail.trim() === '' || this.formData.teamId.trim() === '') {
-          this.$message.error('Missing required information')
+          this.$message.error({duration: 5000, message: 'Missing required information'})
           //限制点击
           setTimeout(() => {
             this.click = true
@@ -39,11 +39,13 @@ export default {
             }, 3000)
             if(res.data.code === 200){
               this.$message({
+                duration: 5000,
                 message: 'Add Success!',
                 type: "success",
               })
             } else if(res.data.msg === "Member has joined a non-default team"){
               this.$message({
+                duration: 5000,
                 message: 'Member has joined a non-default team',
                 type: "error",
               })
@@ -66,6 +68,7 @@ export default {
           }, 1000)
           if(res.data.code === 200){
             this.$message({
+              duration: 5000,
               message: 'Add Success!',
               type: "success",
             })

+ 1 - 0
src/views/TeamManagement/ManageMember/EditManageMember.vue

@@ -63,6 +63,7 @@ export default {
           if(res.data.code === 200){
             this.dialogVisible = false
             this.$message({
+              duration: 5000,
               message: 'Change Success!',
               type: "success",
             })

+ 1 - 0
src/views/TeamManagement/ManageTeam.vue

@@ -101,6 +101,7 @@ function handleDelete() {
   }).then((res) => {
     if (res.data.code === 200) {
       proxy.$message({
+        duration: 5000,
         message: 'Delete Success',
         type: 'success'
       })

+ 4 - 2
src/views/TeamManagement/ManageTeamOperate.vue

@@ -65,7 +65,7 @@ export default {
         }
         emptyFlag = productArr.includes('')
         if (this.formData.teamName.trim() === '' || emptyFlag) {
-          this.$message.error('Missing required information')
+          this.$message.error({duration: 5000, message: 'Missing required information'})
           //限制点击
           setTimeout(() => {
             this.click = true
@@ -109,12 +109,13 @@ export default {
         }, 1000)
         if (res.data.code === 200) {
           this.$message({
+            duration: 5000,
             message: 'Change Success',
             type: 'success'
           })
           this.$router.push({name:'ManageTeam'})
         } else (
-          this.$message.error(res.data.msg)
+          this.$message.error({duration: 5000, message:res.data.msg})
         )
       })
     },
@@ -132,6 +133,7 @@ export default {
         }, 1000)
         if (res.data.code === 200) {
           this.$message({
+            duration: 5000,
             message: 'Change Success',
             type: 'success'
           })

+ 1 - 0
src/views/VolumeCancel.vue

@@ -27,6 +27,7 @@ export default {
         }, 1000)
         if(res.data.code === 200){
           this.$message({
+            duration: 5000,
             message: 'Assign Success!',
             type: "success",
           })

+ 2 - 0
src/views/forgotpassword.vue

@@ -48,6 +48,7 @@ export default {
                 'Email sent successful, please confirm your new password in email'
             ) {
               this.$message({
+                duration: 5000,
                 message:
                   'Email sent successful, please confirm your new password in email',
                 type: 'success'
@@ -58,6 +59,7 @@ export default {
               res.data.msg === 'Please create account first'
             ) {
               this.$message.error({
+                duration: 5000,
                 message: 'Please create account first'
               })
               this.$router.push("/login")