From 3c854091f7c3699af2b8f3ce3f89290e083df402 Mon Sep 17 00:00:00 2001 From: Junling Bu Date: Sat, 7 Apr 2018 00:01:24 +0800 Subject: [PATCH] =?UTF-8?q?update[litemall-admin]:=20=E5=AE=8C=E5=96=84?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=B6=85=E6=97=B6=E9=80=80=E5=87=BA=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- litemall-admin/src/utils/request.js | 27 ++++++++---------------- litemall-admin/src/views/login/index.vue | 2 +- 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/litemall-admin/src/utils/request.js b/litemall-admin/src/utils/request.js index 68e4d5b1..1449a9b0 100644 --- a/litemall-admin/src/utils/request.js +++ b/litemall-admin/src/utils/request.js @@ -1,5 +1,5 @@ import axios from 'axios' -import { Message } from 'element-ui' +import { Message, MessageBox } from 'element-ui' import store from '@/store' import { getToken } from '@/utils/auth' @@ -27,23 +27,14 @@ service.interceptors.response.use( response => { const res = response.data if (res.errno !== 0) { - Message({ - message: res.errno + ' ' + res.errmsg, - type: 'error', - duration: 5 * 1000 + MessageBox.alert('超时自动退出系统,请重新登录', '已退出', { + confirmButtonText: '重新登录', + type: 'error' + }).then(() => { + store.dispatch('FedLogOut').then(() => { + location.reload() + }) }) - // 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了; - // if (res.errno === 50008 || res.errno === 50012 || res.errno === 50014) { - // Message.confirm('你已被登出,可以取消继续留在该页面,或者重新登录', '确定登出', { - // confirmButtonText: '重新登录', - // cancelButtonText: '取消', - // type: 'warning' - // }).then(() => { - // store.dispatch('FedLogOut').then(() => { - // location.reload() // 为了重新实例化vue-router对象 避免bug - // }) - // }) - // } return Promise.reject('error') } else { return response @@ -51,7 +42,7 @@ service.interceptors.response.use( }, error => { console.log('err' + error)// for debug Message({ - message: error.message, + message: '登录连接超时(后台不能连接,请联系系统管理员)', type: 'error', duration: 5 * 1000 }) diff --git a/litemall-admin/src/views/login/index.vue b/litemall-admin/src/views/login/index.vue index 0cad9c65..880f7328 100644 --- a/litemall-admin/src/views/login/index.vue +++ b/litemall-admin/src/views/login/index.vue @@ -87,7 +87,7 @@ export default { }, handleLogin() { this.$refs.loginForm.validate(valid => { - if (valid) { + if (valid && !this.loading) { this.loading = true this.$store.dispatch('LoginByUsername', this.loginForm).then(() => { this.loading = false