|
@@ -13,7 +13,7 @@ const state = () => ({});
|
|
const mutations = {};
|
|
const mutations = {};
|
|
|
|
|
|
const actions = {
|
|
const actions = {
|
|
- async login({ commit }, { user, router }) {
|
|
|
|
|
|
+ async login({ commit }, { user, router, path = '/', needReturn = false }) {
|
|
const res = await this.$axios.$post(`${api.interface}`, user);
|
|
const res = await this.$axios.$post(`${api.interface}`, user);
|
|
if (res.errcode === 0) {
|
|
if (res.errcode === 0) {
|
|
let user = jwt.decode(res.data);
|
|
let user = jwt.decode(res.data);
|
|
@@ -26,7 +26,10 @@ const actions = {
|
|
type: 'success',
|
|
type: 'success',
|
|
duration: 2000,
|
|
duration: 2000,
|
|
});
|
|
});
|
|
- router.push('/');
|
|
|
|
|
|
+ if (needReturn) return res;
|
|
|
|
+ else {
|
|
|
|
+ router.push(path);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
Notification({
|
|
Notification({
|
|
title: '请重新登陆',
|
|
title: '请重新登陆',
|
|
@@ -36,11 +39,14 @@ const actions = {
|
|
console.warn('非当前端用户,需要重新登陆');
|
|
console.warn('非当前端用户,需要重新登陆');
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- Notification({
|
|
|
|
- title: '登录失败',
|
|
|
|
- message: `失败原因:${res.errmsg}`,
|
|
|
|
- type: 'error',
|
|
|
|
- });
|
|
|
|
|
|
+ if (needReturn) return res;
|
|
|
|
+ else {
|
|
|
|
+ Notification({
|
|
|
|
+ title: '登录失败',
|
|
|
|
+ message: `失败原因:${res.errmsg}`,
|
|
|
|
+ type: 'error',
|
|
|
|
+ });
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
async update({ commit }, { id, ...info }) {
|
|
async update({ commit }, { id, ...info }) {
|