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
981c80a1
Commit
981c80a1
authored
Aug 20, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限修改
parent
7a9690b5
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
7 deletions
+30
-7
app.tsx
src/app.tsx
+25
-7
index.tsx
src/utils/index.tsx
+5
-0
No files found.
src/app.tsx
View file @
981c80a1
...
...
@@ -9,7 +9,7 @@ import '@/global/styles/global.less'; // 导入全局样式
import
'antd/dist/antd.less'
import
{
isDev
}
from
'@/constants'
import
{
setup
}
from
'@formily/antd-components'
;
import
{
getRouters
,
getAuth
,
asyncRouter
,
setAuth
,
setRouters
}
from
'./utils/auth'
;
import
{
getRouters
,
getAuth
,
asyncRouter
,
setAuth
,
setRouters
,
removeAuth
,
removeRouters
}
from
'./utils/auth'
;
import
{
PublicApi
}
from
'./services/api'
;
setup
()
...
...
@@ -66,13 +66,20 @@ export function render(oldRender: Function) {
const
authInfo
=
getAuth
()
if
(
authInfo
)
{
PublicApi
.
getMemberLoginReget
().
then
(
res
=>
{
const
{
data
}
=
res
const
{
data
,
code
}
=
res
if
(
code
===
1000
)
{
setAuth
({
memberId
:
data
.
memberId
,
userId
:
data
.
userId
,
token
:
data
.
token
})
setRouters
(
data
.
urls
)
}
else
{
removeAuth
()
removeRouters
()
history
.
push
(
'/user/login'
)
}
oldRender
()
})
}
else
{
...
...
@@ -89,22 +96,33 @@ export function render(oldRender: Function) {
*/
export
function
onRouteChange
({
routes
,
matchedRoutes
,
location
,
action
})
{
console
.
log
(
'onRouteChange'
)
console
.
log
(
window
.
location
.
search
)
if
(
isDev
)
{
return
;
}
if
(
whiteLists
.
includes
(
location
.
pathname
))
return
;
const
routeAuthUrls
=
getRouters
()
// 是否登录
if
(
getAuth
())
{
console
.
log
(
location
)
console
.
log
(
matchedRoutes
)
if
(
routeAuthUrls
.
includes
(
location
.
pathname
))
{
const
{
query
,
pathname
}
=
location
}
else
{
// return ;
// // 固定配置, 出现此参数说明需携带参数校验权限路由
// if (query.page_type && routeAuthUrls.find(authPath => {
// })) {
// return ;
// }
// console.log(query)
// 是否在路由权限列表里
if
(
routeAuthUrls
.
includes
(
pathname
))
{
return
;
}
// 无权限访问时
history
.
replace
(
'/memberCenter/noAuth'
)
}
}
else
{
history
.
replace
(
'/user/login'
)
}
...
...
src/utils/index.tsx
View file @
981c80a1
...
...
@@ -330,6 +330,11 @@ export const getFieldType = (field) => {
}
}
export
const
getQueryStringParams
=
(
url
?:
string
)
=>
{
const
nowUrl
=
url
||
window
.
location
.
href
const
splitUrl
=
nowUrl
.
split
(
'?'
)
const
searchParam
=
[
1
]
}
export
default
{
isArray
,
isObject
,
...
...
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