Commit cea42e18 authored by Bill's avatar Bill

Merge branch 'fix-v2-220418' into 'v2-220418'

chore: 修改urls获取方法 See merge request linkseeks-design/pro-platform!281
parents 02c4709a 2aa3c0a7
......@@ -22,6 +22,14 @@ export interface AuthInfo extends GetMemberLoginRegetResponse {
const AUTH_KEY = 'AUTH'
const AUTH_ROLES_KEY = 'AUTH_ROLES'
const getUrls = (auths: AuthInfo['auth']): string[] => {
if (!Array.isArray(auths)) {
return []
}
return auths.map((item) => item.u)
}
export const setAuth = (info: AuthInfo) => {
const auth = {
userId: info.userId,
......@@ -37,10 +45,14 @@ export const setAuth = (info: AuthInfo) => {
memberType: info.memberType,
locales: info.locales,
}
const compoundedInfo: AuthInfo = {
...info,
urls: getUrls(info.auth),
}
setCookie(AUTH_KEY, JSON.stringify(auth), { domain: TOP_DOMAIN_NO_PORT})
setCookie(AUTH_ROLES_KEY, JSON.stringify(info.roles), { domain: TOP_DOMAIN_NO_PORT })
setLocalAuth(info)
setRouters(info.auth)
setCookie(AUTH_ROLES_KEY, JSON.stringify(compoundedInfo.roles), { domain: TOP_DOMAIN_NO_PORT })
setLocalAuth(compoundedInfo)
setRouters(compoundedInfo.auth)
}
/**
......
Markdown is supported
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