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
shenshaokai
jinfa-platform
Commits
7d102618
Commit
7d102618
authored
Jun 25, 2021
by
GuanHua
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 登录问题修改
parent
7eda8acf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletion
+10
-1
app.tsx
src/app.tsx
+3
-0
auth.ts
src/utils/auth.ts
+7
-1
No files found.
src/app.tsx
View file @
7d102618
...
...
@@ -92,6 +92,7 @@ const whiteLists = [
...
userLoginLists
,
// ...mallLists,
// '/memberCenter',
'/'
,
'/memberCenter/noAuth'
,
'/403'
,
'/404'
,
...
...
@@ -200,6 +201,7 @@ export function onRouteChange({ routes, matchedRoutes, location, action }) {
setRouters
(
urls
)
}
const
{
pathname
}
=
location
console
.
log
(
pathname
,
'pathname'
)
if
(
userLoginLists
.
includes
(
pathname
))
{
// 当登录过, 并且尝试访问登录相关页面, 需重定向到首页
history
.
replace
(
'/memberCenter/home'
)
...
...
@@ -216,6 +218,7 @@ export function onRouteChange({ routes, matchedRoutes, location, action }) {
}
// 无权限访问时
// console.log(pathname)
console
.
log
(
'无权限访问时'
)
history
.
replace
(
'/memberCenter/noAuth'
)
}
else
{
if
(
whiteLists
.
includes
(
location
.
pathname
))
{
...
...
src/utils/auth.ts
View file @
7d102618
...
...
@@ -5,6 +5,7 @@ import { getCookie, removeCookie, setCookie } from './cookie'
import
{
getUserCookie
,
setUserCookie
}
from
'./siteCookie'
export
interface
AuthInfo
{
urls
:
string
[]
userId
:
number
,
memberId
:
number
,
name
:
string
,
...
...
@@ -12,7 +13,9 @@ export interface AuthInfo {
logo
:
string
,
levelTag
:
string
,
creditPoint
:
number
,
urls
:
string
[]
memberRoleType
:
number
,
memberRoleId
:
number
,
roles
:
any
,
}
const
AUTH_KEY
=
'AUTH'
...
...
@@ -27,6 +30,7 @@ export const setAuth = (info: AuthInfo) => {
creditPoint
:
info
.
creditPoint
}
setCookie
(
AUTH_KEY
,
JSON
.
stringify
(
auth
),
{
domain
:
TOP_DOMAIN
})
setCookie
(
'AUTH_ROLES'
,
JSON
.
stringify
(
info
.
roles
),
{
domain
:
TOP_DOMAIN
})
setLocalAuth
(
info
)
setRouters
(
info
.
urls
)
}
...
...
@@ -40,6 +44,8 @@ export const setLocalAuth = (info: AuthInfo) => {
export
const
getAuth
=
():
AuthInfo
=>
{
try
{
// const localAuth: AuthInfo = getCookie('AUTH') as unknown as AuthInfo
// return (localAuth || {}) as AuthInfo
const
localAuth
=
JSON
.
parse
(
window
.
localStorage
.
getItem
(
AUTH_KEY
))
return
(
localAuth
||
{}
)
as
AuthInfo
}
catch
(
error
)
{
...
...
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