瀏覽代碼

登录系统后,挂机等待token失效后,点击系统右上角的“退出”按钮。目前的现象是弹出"token失效"弹框后退出登录,绍明建议改成直接退出不弹框。

CzRger 1 周之前
父節點
當前提交
50df55db74
共有 5 個文件被更改,包括 157 次插入127 次删除
  1. 1 0
      .gitignore
  2. 1 1
      package.json
  3. 17 0
      src/assets/scss/aui.scss
  4. 14 10
      src/utils/request.js
  5. 124 116
      src/views/pages/login.vue

+ 1 - 0
.gitignore

@@ -21,3 +21,4 @@ yarn-error.log*
 *.sw*
 *.lock
 html/
+html.zip

+ 1 - 1
package.json

@@ -27,7 +27,7 @@
     "js-cookie": "^2.2.0",
     "lodash": "^4.17.11",
     "moment": "^2.24.0",
-    "node-sass": "^4.14.1",
+    "sass": "1.56.1",
     "qs": "^6.5.2",
     "quill": "^1.3.6",
     "sass-loader": "^7.3.1",

+ 17 - 0
src/assets/scss/aui.scss

@@ -30,3 +30,20 @@
     }
   }
 }
+// 登陆后的提示弹窗样式
+.https-msg {
+  width: 730px;
+  .el-message-box__title {
+    text-align: center;
+    font-size: 30px;
+    margin-top: 10px;
+  }
+  .el-message-box__message {
+    margin-top: 20px;
+    font-size: 30px;
+    text-indent: 2em;
+    >p {
+      line-height: 40px;
+    }
+  }
+}

+ 14 - 10
src/utils/request.js

@@ -4,7 +4,7 @@ import router from '@/router'
 import qs from 'qs'
 import { clearLoginInfo } from '@/utils'
 import isPlainObject from 'lodash/isPlainObject'
-import {MessageBox} from "element-ui";
+import {MessageBox} from 'element-ui'
 
 const http = axios.create({
   baseURL: window.SITE_CONFIG['apiURL'],
@@ -54,17 +54,21 @@ http.interceptors.request.use(config => {
  */
 http.interceptors.response.use(response => {
   if (response.data.code === 401 || response.data.code === 402 || response.data.code === 403 || response.data.code === 10001) {
-    if(localStorage.getItem('pathCopy')) {
-      localStorage.setItem('pathCopyshow',true)
+    if (localStorage.getItem('pathCopy')) {
+      localStorage.setItem('pathCopyshow', true)
     }
     clearLoginInfo()
-    MessageBox.confirm(response.data.msg, '提示',{
-      showClose: false,
-      showCancelButton: false,
-      callback: () => {
-        router.replace({ name: 'login' })
-      }
-    })
+    if (response.request.responseURL.includes('logout')) {
+      router.replace({ name: 'login' })
+    } else {
+      MessageBox.confirm(response.data.msg, '提示', {
+        showClose: false,
+        showCancelButton: false,
+        callback: () => {
+          router.replace({ name: 'login' })
+        }
+      })
+    }
     return Promise.reject(response.data.msg)
   }
   return response

+ 124 - 116
src/views/pages/login.vue

@@ -6,7 +6,7 @@
           <!--<div class="login-header">-->
             <!--<h2 class="login-brand">{{ $t('brand.lg') }}</h2>-->
           <!--</div>-->
-          <div class="login-body">
+          <div class="login-body" v-if="isHttps">
             <!--<h3 class="login-title">{{ $t('login.title') }}</h3>-->
             <img src="~@/assets/img/logo.png" style="width:50%;margin-bottom: 40px;">
             <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmitHandle()" status-icon>
@@ -44,7 +44,7 @@
               </el-form-item>
               <el-form-item v-if="showOnPhone" prop="validsmsCode" >
                 <el-input v-model="dataForm.validsmsCode"  placeholder="请输入验证码">
-                  <template #append> <div class="verView" @click="verCodeClick()">{{codeTitle}}</div></template>        
+                  <template #append> <div class="verView" @click="verCodeClick()">{{codeTitle}}</div></template>
                 </el-input>
               </el-form-item>
               <el-form-item>
@@ -83,26 +83,29 @@ import {
   IsAddonAvailable,
   GetSignAndToken,
   form1T9,
-  GetSignAndTokenCb,
+  GetSignAndTokenCb
 } from './onenethelper'
+import {MessageBox} from 'element-ui'
+import router from '@/router'
+import fa from 'element-ui/src/locale/lang/fa'
 export default {
   data () {
     return {
       i18nMessages: messages,
       showOnPhone: false,
       showUsername: true,
-      show:false,
-      codeTitle:"获取验证码",
-      time_count:60,
-      timer:null,
+      show: false,
+      codeTitle: '获取验证码',
+      time_count: 60,
+      timer: null,
       captchaPath: '',
       dataForm: {
         username: '',
         password: '',
         deviceId: '',
         validCode: '',
-        phoneNumber:'',
-        validsmsCode:'',
+        phoneNumber: '',
+        validsmsCode: ''
       }
     }
   },
@@ -123,21 +126,34 @@ export default {
         ],
         phoneNumber: [
           { required: true, message: '请输入手机号码', trigger: 'blur' }
-        ],
+        ]
       }
+    },
+    isHttps () {
+      return location.protocol.includes('https')
     }
   },
   created () {
-    this.getCaptcha()
+    if (this.isHttps) {
+      this.getCaptcha()
+    } else {
+      MessageBox.confirm('<div>根据网络安全管理要求,系统计划于2025年3月28日14时30分至23时进行升级改造,期间系统无法使用,敬请谅解。</div><div>升级后,请通过新地址进行登录<a href="https://10.110.35.47" style="cursor: pointer">(点击跳转)</a>,感谢您的理解和支持。</div>', '通知', {
+        showClose: false,
+        showCancelButton: false,
+        showConfirmButton: false,
+        dangerouslyUseHTMLString: true,
+        customClass: 'https-msg'
+      })
+    }
   },
   methods: {
-    //证书插件下载
+    // 证书插件下载
     handleCommand (filename) {
-      const a = document.createElement('a');
-      a.href = filename;
-      a.download = filename;
-      document.body.appendChild(a);
-      a.click();
+      const a = document.createElement('a')
+      a.href = filename
+      a.download = filename
+      document.body.appendChild(a)
+      a.click()
     },
     // 获取验证码
     getCaptcha () {
@@ -146,36 +162,34 @@ export default {
     },
     // 获取手机验证码
     verCodeClick () {
-      if(!this.show){
-      this.$http.post('/idaas/sso/smsvalidate',{
-        phoneNumber:this.dataForm.phoneNumber,
-        deviceId:this.dataForm.deviceId,
-        validCode:this.dataForm.validCode,
-      }).then(({ data: res }) => {
+      if (!this.show) {
+        this.$http.post('/idaas/sso/smsvalidate', {
+          phoneNumber: this.dataForm.phoneNumber,
+          deviceId: this.dataForm.deviceId,
+          validCode: this.dataForm.validCode
+        }).then(({ data: res }) => {
           // this.show = true
-            if (res.code !== 0) {
-                return this.$message.error(res.msg)
-              }
-              if(res.code==0) {
-                if(!this.timer) {
-                  this.timer = setInterval ( () => {
-                    if(this.time_count>0) {
-                    this.time_count--
-                    this.codeTitle = this.time_count +'秒后重新获取'
-                  }
-                  else {
-                    this.codeTitle = '获取验证码'
-                    clearInterval(this.timer)
-                    this.timer = null
-                    this.time_count = 60
-                    this.show = false
-                  }
-                  },1000)
-                 
+          if (res.code !== 0) {
+            return this.$message.error(res.msg)
+          }
+          if (res.code == 0) {
+            if (!this.timer) {
+              this.timer = setInterval(() => {
+                if (this.time_count > 0) {
+                  this.time_count--
+                  this.codeTitle = this.time_count + '秒后重新获取'
+                } else {
+                  this.codeTitle = '获取验证码'
+                  clearInterval(this.timer)
+                  this.timer = null
+                  this.time_count = 60
+                  this.show = false
                 }
-              }
+              }, 1000)
+            }
+          }
         }).catch(() => {})
-    }
+      }
     },
     onUserName () {
       this.showUsername = true
@@ -187,41 +201,39 @@ export default {
       this.showUsername = false
     },
     CertLogin () {
-      if(IsAddonAvailable()) {
-              this.$http.post('/webservice/generatorchallenge', {}).then(({ data: res }) => {
+      if (IsAddonAvailable()) {
+        this.$http.post('/webservice/generatorchallenge', {}).then(({ data: res }) => {
           if (res.code == 0) {
-             GetSignAndToken(res.msg)
+            GetSignAndToken(res.msg)
             //  console.log(GetSignAndTokenCb(),"GetSignAndTokenCb()")
             // console.log(form1T9,"登陆页")
             setTimeout(() => {
-              if(form1T9.signandtoken) {
-                      this.$http.post('/webservice/verifyIdentityTicket', {
-                        challenge: res.msg,//随机挑战数
-                        identityTicket:form1T9.signandtoken,//组合令牌数据
-                        appServerID:'0'//服务器ID
-                      }).then(({ data: res }) => {
-                          if (res.expiresIn==7200) { 
-                            Cookies.set('token', res.sessionToken)
-                            this.$router.replace({ name: 'home' })
-                               // 发送用户登录成功MQ消息
-                                this.$http.get('/mq/user/login').then(({ data: res }) => {
-                                  if (res.code !== 0) {
-                                    return this.$message.error(res.msg)
-                                  }
-                                }).catch(() => {})
-                          }else {
-                            this.$message.error(res.msg)
-                          }
-                      })
-              }
-              else {
-                this.$message.error("获取令牌错误 请刷新重试!")
+              if (form1T9.signandtoken) {
+                this.$http.post('/webservice/verifyIdentityTicket', {
+                  challenge: res.msg, // 随机挑战数
+                  identityTicket: form1T9.signandtoken, // 组合令牌数据
+                  appServerID: '0'// 服务器ID
+                }).then(({ data: res }) => {
+                  if (res.expiresIn == 7200) {
+                    Cookies.set('token', res.sessionToken)
+                    this.$router.replace({ name: 'home' })
+                    // 发送用户登录成功MQ消息
+                    this.$http.get('/mq/user/login').then(({ data: res }) => {
+                      if (res.code !== 0) {
+                        return this.$message.error(res.msg)
+                      }
+                    }).catch(() => {})
+                  } else {
+                    this.$message.error(res.msg)
+                  }
+                })
+              } else {
+                this.$message.error('获取令牌错误 请刷新重试!')
               }
-            },800)
+            }, 800)
             // form1.T8.value = res.data.msg//获取随机挑战数
           }
         })
-
       }
     },
     // 表单提交
@@ -230,58 +242,54 @@ export default {
         if (!valid) {
           return false
         }
-        if(this.showOnPhone) {
+        if (this.showOnPhone) {
           this.$http.post('idaas/sso/smslogin', {
-            deviceId:this.dataForm.deviceId,
-            phoneNumber:this.dataForm.phoneNumber,
-            validCode:this.dataForm.validCode,
-            validsmsCode:this.dataForm.validsmsCode,
+            deviceId: this.dataForm.deviceId,
+            phoneNumber: this.dataForm.phoneNumber,
+            validCode: this.dataForm.validCode,
+            validsmsCode: this.dataForm.validsmsCode
           })
-          .then(({ data: res }) => {
-          if (res.code !== 0) {
-            this.getCaptcha()
-            return this.$message.error(res.msg)
-          }
-          Cookies.set('token', res.sessionToken)
-          Cookies.set('loginMsg', 1)
-          // 发送用户登录成功MQ消息
-           this.$http.get('/mq/user/login').then(({ data: res }) => {
+            .then(({ data: res }) => {
+              if (res.code !== 0) {
+                this.getCaptcha()
+                return this.$message.error(res.msg)
+              }
+              Cookies.set('token', res.sessionToken)
+              Cookies.set('loginMsg', 1)
+              // 发送用户登录成功MQ消息
+              this.$http.get('/mq/user/login').then(({ data: res }) => {
+                if (res.code !== 0) {
+                  return this.$message.error(res.msg)
+                }
+              }).catch(() => {})
+              if (localStorage.getItem('pathCopyshow') && localStorage.getItem('pathCopy')) {
+                this.$router.push(localStorage.getItem('pathCopy'))
+              } else {
+                this.$router.replace({ name: 'home' })
+              }
+            }).catch(() => {})
+        } else {
+          this.$http.post('/idaas/sso/login', this.dataForm).then(({ data: res }) => {
             if (res.code !== 0) {
+              this.getCaptcha()
               return this.$message.error(res.msg)
             }
-          }).catch(() => {})
-          if(localStorage.getItem('pathCopyshow') && localStorage.getItem('pathCopy')) {
-            this.$router.push(localStorage.getItem('pathCopy'))
-          }
-          else{
-            this.$router.replace({ name: 'home' })
-          }
-        }).catch(() => {})
-          
-        }else {
-          this.$http.post('/idaas/sso/login', this.dataForm).then(({ data: res }) => {
-          if (res.code !== 0) {
-            this.getCaptcha()
-            return this.$message.error(res.msg)
-          }
-          Cookies.set('token', res.sessionToken)
-          Cookies.set('loginMsg', 1)
+            Cookies.set('token', res.sessionToken)
+            Cookies.set('loginMsg', 1)
 
-          // 发送用户登录成功MQ消息
-          this.$http.get('/mq/user/login').then(({ data: res }) => {
-            if (res.code !== 0) {
-              return this.$message.error(res.msg)
+            // 发送用户登录成功MQ消息
+            this.$http.get('/mq/user/login').then(({ data: res }) => {
+              if (res.code !== 0) {
+                return this.$message.error(res.msg)
+              }
+            }).catch(() => {})
+            if (localStorage.getItem('pathCopyshow') && localStorage.getItem('pathCopy')) {
+              this.$router.push(localStorage.getItem('pathCopy'))
+            } else {
+              this.$router.replace({ name: 'home' })
             }
           }).catch(() => {})
-          if(localStorage.getItem('pathCopyshow') && localStorage.getItem('pathCopy')) {
-            this.$router.push(localStorage.getItem('pathCopy'))
-          }
-          else{
-            this.$router.replace({ name: 'home' })
-          }
-        }).catch(() => {})
         }
-       
       })
     }, 1000, { 'leading': true, 'trailing': false })
   }
@@ -296,7 +304,7 @@ export default {
             display: flex;
             align-items: center;
             justify-content: space-between;
-          
+
 }
 .cert {
               cursor: pointer;
@@ -320,4 +328,4 @@ export default {
   color: #3E8EF7;
  cursor: pointer;
 }
-</style>
+</style>