Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ems3.3
Project
Project
Details
Activity
Releases
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
wuhao
ems3.3
Commits
ca9e3cf5
Commit
ca9e3cf5
authored
Sep 25, 2023
by
左玲玲
😬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1452
parent
c5029e04
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
6 deletions
+50
-6
app.jsx
src/app.jsx
+34
-1
index.jsx
src/components/TagView/Tags/index.jsx
+1
-1
index.jsx
src/components/TagView/index.jsx
+15
-4
No files found.
src/app.jsx
View file @
ca9e3cf5
...
...
@@ -25,6 +25,21 @@ function strToHump(str) {
return
res
+
'Outlined'
;
}
function
getChildren
(
data
)
{
let
arr
=
[];
function
loop
(
data
)
{
data
.
map
(
it
=>
{
if
(
it
.
routes
?.
length
>
0
)
{
loop
(
it
.
routes
);
}
else
{
arr
.
push
(
it
);
}
});
}
loop
(
data
);
return
arr
;
}
export
async
function
getInitialState
()
{
let
token
=
localStorage
.
getItem
(
'TOKENES'
);
const
fetchUserInfo
=
async
()
=>
{
...
...
@@ -152,10 +167,28 @@ export const layout = ({ initialState, setInitialState }) => {
noFound
:
<
div
>
noFound
</
div
>,
// 增加一个 loading 的状态
childrenRender
:
(
children
,
props
)
=>
{
let
home
,
items
=
getChildren
(
initialState
?.
newMenu
?.
userHavePermList
??
[]);
items
?.
unshift
({
path
:
"/welcome"
,
name
:
"首页"
,
icon
:
"smile"
,
component
:
"./Welcome"
,
haveChildren
:
false
,
key
:
"000000"
,
parentKey
:
"0"
,
routes
:
[],
children
:
null
,
title
:
null
,
});
if
(
history
.
location
.
pathname
!=
"/welcome"
&&
history
.
location
.
pathname
!=
"/"
)
{
home
=
history
.
location
.
pathname
}
else
{
home
=
items
?.
length
>
0
?
items
[
0
].
path
.
indexOf
(
"/"
)
>
-
1
?
items
[
0
].
path
:
items
[
0
]?.
children
?.
length
>
0
?
items
[
0
]?.
children
[
0
]?.
path
:
""
:
""
;
}
return
(
<>
{
initialState
?.
currentUser
&&
location
.
pathname
!==
loginPath
?
(
<
TagView
home=
'/welcome'
>
{
children
}
</
TagView
>
<
TagView
home=
{
home
}
>
{
children
}
</
TagView
>
)
:
(
children
)
}
...
...
src/components/TagView/Tags/index.jsx
View file @
ca9e3cf5
...
...
@@ -85,7 +85,7 @@ const Tags = ({ tagList, closeTag, closeAllTag, closeOtherTag, refreshTag, home
>
刷新
</
li
>
{
currentTag
.
path
!=
home
&&
currentTag
.
currentIndex
!=
0
&&
(
{
currentTag
.
path
!=
home
&&
(
<
li
onClick=
{
()
=>
{
setMenuVisible
(
false
);
...
...
src/components/TagView/index.jsx
View file @
ca9e3cf5
...
...
@@ -30,10 +30,7 @@ const TagView = ({ home }) => {
// console.log(routeContext);
const
{
menuData
}
=
routeContext
;
if
(
tagList
.
length
===
0
&&
menuData
)
{
const
allarr
=
[];
treeForeach
(
menuData
,
(
node
)
=>
{
allarr
.
push
(
node
);
});
const
allarr
=
getChildren
(
menuData
);
const
firstTag
=
allarr
.
filter
((
el
)
=>
el
.
path
===
home
)[
0
];
if
(
firstTag
)
{
const
title
=
firstTag
.
name
;
...
...
@@ -144,6 +141,20 @@ const TagView = ({ home }) => {
setTagList
(
tagsCopy
);
},
10
);
};
function
getChildren
(
data
)
{
let
arr
=
[];
function
loop
(
data
)
{
data
.
map
(
it
=>
{
if
(
it
.
children
?.
length
>
0
)
{
loop
(
it
.
children
);
}
else
{
arr
.
push
(
it
);
}
});
}
loop
(
data
);
return
arr
;
}
return
(
<>
<
RouteContext
.
Consumer
>
...
...
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