|
|
|
@ -1,8 +1,7 @@ |
|
|
|
|
import Setting from "@/setting"; |
|
|
|
|
import util from "@/libs/util"; |
|
|
|
|
import { post, get, del, put } from "@/plugins/requests/index.js"; |
|
|
|
|
import { post } from "@/plugins/requests/index.js"; |
|
|
|
|
import api from "@/api"; |
|
|
|
|
import addRoutes from "@/libs/route/addRoutes"; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 用户信息 |
|
|
|
@ -10,7 +9,6 @@ import addRoutes from "@/libs/route/addRoutes"; |
|
|
|
|
export default { |
|
|
|
|
namespaced: true, |
|
|
|
|
state: { |
|
|
|
|
customer: false, // true:为客户,没有个人中心
|
|
|
|
|
customerName: "", // 客户名称
|
|
|
|
|
title: "", |
|
|
|
|
logoUrl: "", |
|
|
|
@ -32,9 +30,6 @@ export default { |
|
|
|
|
state.roleId = info.roleId; |
|
|
|
|
state.dataTime = info.dataTime; |
|
|
|
|
}, |
|
|
|
|
SET_CUSTOMER: (state, customer) => { |
|
|
|
|
state.customer = customer; |
|
|
|
|
}, |
|
|
|
|
SET_CUSTOMER_NAME: (state, customerName) => { |
|
|
|
|
state.customerName = customerName; |
|
|
|
|
}, |
|
|
|
@ -72,12 +67,7 @@ export default { |
|
|
|
|
post(api.logins, userInfo).then(res => { |
|
|
|
|
// console.log(JSON.stringify(res));
|
|
|
|
|
if (res.status == 200) { |
|
|
|
|
let { data } = res; |
|
|
|
|
// 生成路由权限
|
|
|
|
|
// 每个系统都是用这套角色权限代码的,后端也是基本一样,除了个别字段可能会不一样
|
|
|
|
|
// 总体来说就两个步骤: 1是生成能够访问的路由的数组集合,2是生成能看到的按钮的数组集合
|
|
|
|
|
// res.message.listValue && Setting.dynamicRoute && addRoutes(res.message.listValue)
|
|
|
|
|
// 2021-10-13重做权限,因权限系统封装
|
|
|
|
|
let { data } = res |
|
|
|
|
util.local.set(Setting.tokenKey, data.token, Setting.tokenExpires); |
|
|
|
|
commit("SET_CUSTOMER", data.customer); |
|
|
|
|
commit("SET_CUSTOMER_NAME", data.customerName); |
|
|
|
@ -97,8 +87,9 @@ export default { |
|
|
|
|
}, |
|
|
|
|
logout ({ commit, state, dispatch }) { |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
util.local.remove(Setting.storeKey); |
|
|
|
|
util.local.remove(Setting.tokenKey); |
|
|
|
|
post(api.logout).then(() => { |
|
|
|
|
util.local.remove(Setting.storeKey) |
|
|
|
|
util.local.remove(Setting.tokenKey) |
|
|
|
|
if (state.fromClient) { |
|
|
|
|
util.cookies.remove('serverLogin') |
|
|
|
|
location.href = Setting.isDev |
|
|
|
@ -109,8 +100,11 @@ export default { |
|
|
|
|
} else { |
|
|
|
|
location.reload() |
|
|
|
|
} |
|
|
|
|
resolve(); |
|
|
|
|
}); |
|
|
|
|
resolve() |
|
|
|
|
}).catch(error => { |
|
|
|
|
reject(error) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
setInfo ({ state, commit }, info) { |
|
|
|
|
commit("SET_INFO", info); |
|
|
|
@ -121,9 +115,6 @@ export default { |
|
|
|
|
setLogoUrl ({ state, commit }, logoUrl) { |
|
|
|
|
commit("SET_LOGO_URL", logoUrl); |
|
|
|
|
}, |
|
|
|
|
setCustomer({ state, commit }, customer) { |
|
|
|
|
commit("SET_CUSTOMER", customer); |
|
|
|
|
}, |
|
|
|
|
setCustomerName ({ state, commit }, customerName) { |
|
|
|
|
commit("SET_CUSTOMER_NAME", customerName); |
|
|
|
|
}, |
|
|
|
|