Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linweijiong
jinfa-platform
Commits
98e1af9d
Commit
98e1af9d
authored
Jul 03, 2021
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 用户信息清除方式
parent
84825218
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
6 deletions
+14
-6
index.ts
src/constants/index.ts
+2
-1
auth.ts
src/utils/auth.ts
+6
-4
index.tsx
src/utils/index.tsx
+6
-1
No files found.
src/constants/index.ts
View file @
98e1af9d
...
...
@@ -14,7 +14,8 @@ export const REQUEST_HEADER = 'http://'
/**
* 顶域
*/
export
const
TOP_DOMAIN
=
process
.
env
.
NODE_ENV
!==
'development'
?
getTopDomainByHost
(
GlobalConfig
.
global
.
siteInfo
.
siteUrl
)
:
'lingxidev.com'
// export const TOP_DOMAIN = process.env.NODE_ENV !== 'development' ? getTopDomainByHost(GlobalConfig.global.siteInfo.siteUrl) : 'lingxidev.com'
export
const
TOP_DOMAIN
=
getTopDomainByHost
(
GlobalConfig
.
global
.
siteInfo
.
siteUrl
)
/**
* 平台首页域名
...
...
src/utils/auth.ts
View file @
98e1af9d
...
...
@@ -19,6 +19,7 @@ export interface AuthInfo {
}
const
AUTH_KEY
=
'AUTH'
const
AUTH_ROLES_KEY
=
'AUTH_ROLES'
export
const
setAuth
=
(
info
:
AuthInfo
)
=>
{
const
auth
=
{
userId
:
info
.
userId
,
...
...
@@ -31,8 +32,9 @@ export const setAuth = (info: AuthInfo) => {
memberRoleType
:
info
.
memberRoleType
,
memberRoleId
:
info
.
memberRoleId
}
setCookie
(
AUTH_KEY
,
JSON
.
stringify
(
auth
),
{
domain
:
TOP_DOMAIN
})
setCookie
(
'AUTH_ROLES'
,
JSON
.
stringify
(
info
.
roles
),
{
domain
:
TOP_DOMAIN
})
console
.
log
(
getTopDomainByHost
(
TOP_DOMAIN
,
true
))
setCookie
(
AUTH_KEY
,
JSON
.
stringify
(
auth
),
{
domain
:
getTopDomainByHost
(
TOP_DOMAIN
,
true
)
})
setCookie
(
AUTH_ROLES_KEY
,
JSON
.
stringify
(
info
.
roles
),
{
domain
:
getTopDomainByHost
(
TOP_DOMAIN
,
true
)
})
setLocalAuth
(
info
)
setRouters
(
info
.
urls
)
}
...
...
@@ -77,8 +79,8 @@ export const removeRouters = () => {
}
export
const
removeAuth
=
()
=>
{
console
.
log
(
TOP_DOMAIN
)
removeCookie
(
AUTH_
KEY
,
{
path
:
'/'
,
domain
:
TOP_DOMAIN
})
removeCookie
(
AUTH_KEY
,
{
path
:
'/'
,
domain
:
getTopDomainByHost
(
TOP_DOMAIN
,
true
)
}
)
removeCookie
(
AUTH_
ROLES_KEY
,
{
path
:
'/'
,
domain
:
getTopDomainByHost
(
TOP_DOMAIN
,
true
)
})
window
.
localStorage
.
removeItem
(
AUTH_KEY
)
removeRouters
()
}
...
...
src/utils/index.tsx
View file @
98e1af9d
...
...
@@ -642,8 +642,13 @@ export const getIChannelInfo = () => {
* @param url 链接
* @returns
*/
export
const
getTopDomainByHost
=
(
url
:
string
):
string
=>
{
export
const
getTopDomainByHost
=
(
url
:
string
,
isPort
=
false
):
string
=>
{
if
(
!
url
)
return
''
// 如果后缀带有端口号, 可通过第二个参数把端口去掉
const
splitUrl
=
url
.
split
(
':'
)
if
(
splitUrl
.
length
>
1
&&
isPort
)
{
return
`
${
splitUrl
[
0
].
split
(
'.'
).
slice
(
-
2
).
join
(
'.'
)}
`
}
return
url
.
split
(
'.'
).
slice
(
-
2
).
join
(
'.'
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment