Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
H
haoban-3
Overview
Overview
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
office
haoban-3
Commits
0dd6c1f6
Commit
0dd6c1f6
authored
Aug 05, 2022
by
caoyanzhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: keep alive
parent
2815c37c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
8 deletions
+11
-8
index.vue
src/components/layout/index.vue
+11
-8
No files found.
src/components/layout/index.vue
View file @
0dd6c1f6
...
...
@@ -6,7 +6,7 @@
<bread-menu
v-if=
"activedMenu.length > 3"
:menu-list=
"activedMenu.slice(2)"
></bread-menu>
<div
class=
"hb-layout-pager"
id=
"hb-layout-pager-one"
:style=
"
{ height: activedMenu.length > 3 ? `calc(100% - 30px)` : '100%', 'padding-bottom': pagePaddingBottom }">
<!-- 页面内容 -->
<keep-alive
:
ex
clude=
"keepAlive"
>
<keep-alive
:
in
clude=
"keepAlive"
>
<router-view
:key=
"$route.path"
:brand-id=
"enterpriseId"
></router-view>
</keep-alive>
</div>
...
...
@@ -27,7 +27,7 @@ export default {
provide
:
()
=>
provideData
,
beforeRouteUpdate
(
to
,
from
,
next
)
{
if
(
Array
.
isArray
(
to
.
meta
.
fromPath
))
{
to
.
meta
.
fromPath
.
some
(
el
=>
{
const
isKeepAlive
=
to
.
meta
.
fromPath
.
some
(
el
=>
{
let
menuUrlReg
=
el
;
let
pathConfigReg
=
/
(
:.*
)(\/?)
/
;
const
pathRegStr
=
'([
\\
d
\\
w]+[
\\
-]*[
\\
d
\\
w]*)'
;
...
...
@@ -39,15 +39,15 @@ export default {
menuUrlReg
=
menuUrlReg
.
replace
(
pathConfigReg
,
`
${
pathRegStr
}
$2`
);
}
const
reg
=
new
RegExp
(
`^
${
menuUrlReg
}
$`
);
if
(
reg
.
test
(
from
.
path
))
{
this
.
keepAlive
=
[];
}
else
{
this
.
keepAlive
=
[
to
.
meta
.
componentName
];
}
return
reg
.
test
(
from
.
path
);
});
if
(
!
isKeepAlive
)
{
this
.
keepAlive
=
this
.
keepAlive
.
filter
(
el
=>
el
!=
to
.
meta
.
componentName
);
}
setTimeout
(()
=>
{
this
.
keepAlive
=
[];
if
(
this
.
keepAlive
.
every
(
el
=>
el
!=
to
.
meta
.
componentName
))
{
this
.
keepAlive
.
push
(
to
.
meta
.
componentName
);
}
},
100
);
}
next
();
...
...
@@ -91,6 +91,9 @@ export default {
}
},
created
()
{
if
(
Array
.
isArray
(
this
.
$route
.
meta
.
fromPath
))
{
this
.
keepAlive
.
push
(
this
.
$route
.
meta
.
componentName
);
}
this
.
$router
.
beforeEach
((
to
,
from
,
next
)
=>
{
this
.
activedMenu
=
this
.
getActivedMenu
(
this
.
getMenuByPath
(
to
.
path
.
slice
(
1
)));
next
();
...
...
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