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
01b63a8f
Commit
01b63a8f
authored
Aug 18, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of
http://10.0.0.22:3000/lingxi/lingxi-business-paltform
into dev
parents
42951395
e62623ae
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
10 deletions
+17
-10
index.ts
config/routes/index.ts
+2
-1
app.tsx
src/app.tsx
+10
-6
403.tsx
src/pages/403.tsx
+0
-1
LoginWrap.tsx
src/pages/user/components/LoginWrap.tsx
+2
-1
request.ts
src/utils/request.ts
+3
-1
No files found.
config/routes/index.ts
View file @
01b63a8f
...
...
@@ -38,12 +38,13 @@ const memberCenterRoute = {
},
...
routes
,
{
path
:
'/noAuth'
,
path
:
'/
memberCenter/
noAuth'
,
auth
:
false
,
component
:
'@/pages/403'
,
},
// 能力中心的404页
{
path
:
'/*'
,
auth
:
false
,
component
:
'@/pages/404'
,
},
...
...
src/app.tsx
View file @
01b63a8f
...
...
@@ -22,13 +22,16 @@ const whiteLists = [
'/user/login'
,
'/user/register'
,
'/memberCenter'
,
'/memberCenter/noAuth'
,
'/commodity'
,
'/shops'
,
'/shop/commodity/detail'
,
'/shop/commodity'
,
'/shop'
,
'/infomation'
,
'/403'
,
'/404'
,
'/500'
,
'/noAuth'
]
...
...
@@ -70,10 +73,12 @@ export function render(oldRender: Function) {
token
:
data
.
token
})
setRouters
(
data
.
urls
)
oldRender
()
})
}
else
{
history
.
push
(
'/user/login'
)
oldRender
()
}
oldRender
()
}
/**
...
...
@@ -84,21 +89,20 @@ export function render(oldRender: Function) {
* @param {*} { routes, matchedRoutes, location, action }
*/
export
function
onRouteChange
({
routes
,
matchedRoutes
,
location
,
action
})
{
console
.
log
(
`当前可访问的路由为`
)
console
.
log
(
routes
,
matchedRoutes
,
location
)
console
.
log
(
'onRouteChange'
)
if
(
isDev
)
{
return
;
}
if
(
whiteLists
.
includes
(
location
.
pathname
))
return
;
const
routeAuthUrls
=
getRouters
()
console
.
log
(
routeAuthUrls
,
"routeAuthUrls"
)
// 是否登录
if
(
getAuth
())
{
if
(
routeAuthUrls
.
includes
(
location
.
pathname
))
{
}
else
{
// history.replace('/')
// 无权限访问时
history
.
replace
(
'/memberCenter/noAuth'
)
}
}
else
{
history
.
replace
(
'/user/login'
)
...
...
src/pages/403.tsx
View file @
01b63a8f
...
...
@@ -14,7 +14,6 @@ const NoFoundPage: React.FC<{}> = () => {
return
(
<
div
className=
{
styles
.
wrapper
}
>
<
UserHeader
logo=
{
GlobalConfig
.
global
.
logo
}
/>
<
div
className=
{
styles
.
errorBox
}
>
<
Row
>
<
Col
span=
{
12
}
>
...
...
src/pages/user/components/LoginWrap.tsx
View file @
01b63a8f
...
...
@@ -23,7 +23,8 @@ const LoginWrap: React.FC = () => {
token
:
data
.
token
})
setRouters
(
data
.
urls
)
history
.
push
(
'/memberCenter/home'
)
// 此处需使用href跳转, 否则无法触发app.ts中的路由初始化校验
window
.
location
.
href
=
'/memberCenter/home'
})
}
...
...
src/utils/request.ts
View file @
01b63a8f
...
...
@@ -4,6 +4,7 @@ import { IRequestError, IRequestSuccess } from '..';
import
{
history
}
from
'umi'
import
{
message
}
from
'antd'
import
{
getAuth
,
removeAuth
}
from
'./auth'
;
import
{
GlobalConfig
}
from
'@/global/config'
;
export
type
CtlType
=
'none'
|
'message'
// 根前缀请求路径
...
...
@@ -52,7 +53,8 @@ const errorHandler = (error: ResponseError): IRequestError => {
const
defaultHeaders
=
{
'Content-Type'
:
'Application/json'
,
'source'
:
'1'
'source'
:
'1'
,
'site'
:
GlobalConfig
.
global
.
siteId
.
toString
()
}
/**
...
...
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