Commit 3c854091 authored by Junling Bu's avatar Junling Bu
Browse files

update[litemall-admin]: 完善系统超时退出逻辑

parent b852418b
import axios from 'axios' import axios from 'axios'
import { Message } from 'element-ui' import { Message, MessageBox } from 'element-ui'
import store from '@/store' import store from '@/store'
import { getToken } from '@/utils/auth' import { getToken } from '@/utils/auth'
...@@ -27,23 +27,14 @@ service.interceptors.response.use( ...@@ -27,23 +27,14 @@ service.interceptors.response.use(
response => { response => {
const res = response.data const res = response.data
if (res.errno !== 0) { if (res.errno !== 0) {
Message({ MessageBox.alert('超时自动退出系统,请重新登录', '已退出', {
message: res.errno + ' ' + res.errmsg, confirmButtonText: '重新登录',
type: 'error', type: 'error'
duration: 5 * 1000 }).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') return Promise.reject('error')
} else { } else {
return response return response
...@@ -51,7 +42,7 @@ service.interceptors.response.use( ...@@ -51,7 +42,7 @@ service.interceptors.response.use(
}, error => { }, error => {
console.log('err' + error)// for debug console.log('err' + error)// for debug
Message({ Message({
message: error.message, message: '登录连接超时(后台不能连接,请联系系统管理员)',
type: 'error', type: 'error',
duration: 5 * 1000 duration: 5 * 1000
}) })
......
...@@ -87,7 +87,7 @@ export default { ...@@ -87,7 +87,7 @@ export default {
}, },
handleLogin() { handleLogin() {
this.$refs.loginForm.validate(valid => { this.$refs.loginForm.validate(valid => {
if (valid) { if (valid && !this.loading) {
this.loading = true this.loading = true
this.$store.dispatch('LoginByUsername', this.loginForm).then(() => { this.$store.dispatch('LoginByUsername', this.loginForm).then(() => {
this.loading = false this.loading = false
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment