Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-admin
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-admin
Commits
56807783
Commit
56807783
authored
Aug 26, 2020
by
前端-许佳敏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复登录后访问登录相关页面报错
parent
d52978ce
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
8 deletions
+25
-8
app.tsx
src/app.tsx
+18
-4
index.tsx
src/components/ModalTable/index.tsx
+4
-3
index.tsx
src/components/TabTree/index.tsx
+2
-1
useTreeTabs.ts
src/hooks/useTreeTabs.ts
+1
-0
No files found.
src/app.tsx
View file @
56807783
...
...
@@ -16,9 +16,13 @@ import queryString from 'query-string';
setup
();
let
extraRoutes
:
never
[]
=
[];
// 与用户登录相关路由
const
userLoginLists
=
[
'/login'
,
]
const
whiteLists
=
[
'/'
,
'/login'
,
...
userLoginLists
,
'/noAuth'
]
/**
...
...
@@ -84,12 +88,16 @@ export function onRouteChange({ routes, matchedRoutes, location, action }) {
return
;
}
if
(
whiteLists
.
includes
(
location
.
pathname
))
return
;
const
routeAuthUrls
=
getRouters
()
// 是否登录
if
(
getAuth
())
{
const
{
query
,
pathname
}
=
location
const
routeAuthUrls
=
getRouters
()
if
(
userLoginLists
.
includes
(
pathname
))
{
// 当登录过, 并且尝试访问登录相关页面, 需重定向到首页
history
.
replace
(
'/memberCenter/home'
)
return
;
}
// 固定配置, 出现此参数说明需携带参数校验权限路由
if
(
query
.
page_type
&&
routeAuthUrls
.
find
(
authPath
=>
{
const
parseUrl
=
queryString
.
parseUrl
(
authPath
)
...
...
@@ -107,8 +115,14 @@ export function onRouteChange({ routes, matchedRoutes, location, action }) {
// 无权限访问时
history
.
replace
(
'/noAuth'
)
}
else
{
// 未登录
if
(
whiteLists
.
includes
(
location
.
pathname
))
{
// 访问路由在白名单里
}
else
{
history
.
replace
(
'/login'
)
}
}
}
/**
...
...
src/components/ModalTable/index.tsx
View file @
56807783
...
...
@@ -15,12 +15,13 @@ const ModalTable:React.FC<ModalTableProps> = (props) => {
const
{
width
=
704
,
modalTitle
,
confirm
,
cancel
,
visible
,
currentRef
,
...
resetTable
}
=
props
const
selfRef
=
currentRef
||
useRef
<
any
>
({})
useEffect
(()
=>
{
if
(
!
visible
)
{
if
(
visible
)
{
// 重新开启时需reload接口
selfRef
.
current
.
reload
&&
selfRef
.
current
.
reload
()
}
else
{
selfRef
.
current
.
resetField
&&
selfRef
.
current
.
resetField
({
validate
:
false
})
// 重新开启时需reload接口
selfRef
.
current
.
reload
&&
selfRef
.
current
.
reload
()
}
},
[
visible
,
selfRef
.
current
])
return
(
...
...
src/components/TabTree/index.tsx
View file @
56807783
...
...
@@ -67,7 +67,7 @@ export const createTreeActions = () => {
setSelectKeys
(){},
setExpandedKeys
(){},
getParentPath
(
id
){
return
''
},
getParent
(
id
){
return
null
}
getParent
(
id
){
console
.
log
(
'not init'
);
return
null
}
}
return
actions
}
...
...
@@ -205,6 +205,7 @@ const TabTree:React.FC<TabTreeProps> = (props) => {
}
selfActions
.
getParent
=
(
id
)
=>
{
console
.
log
(
id
)
const
reductData
=
treeReduction
(
treeData
)
const
targetInfo
=
reductData
[
id
]
const
parentInfo
=
reductData
[
targetInfo
.
parentId
]
...
...
src/hooks/useTreeTabs.ts
View file @
56807783
...
...
@@ -114,6 +114,7 @@ export const useTreeTabs = (options: useTreeTabOptions = {}) => {
const
toolsRender
=
{
addNode
(
node
)
{
const
activeParentId
=
treeActions
&&
treeActions
.
getParent
(
node
.
key
||
node
.
id
)?.
id
console
.
log
(
activeParentId
)
setNodeRecord
({
...
node
,
parentId
:
activeParentId
,
// 添加同级的时候 使用上一级的id作为parentId
...
...
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