Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
lxyl-vue
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
李苏
lxyl-vue
Commits
98268ca7
Commit
98268ca7
authored
Jun 06, 2024
by
李苏
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自定义页面缓存
parent
5b6b09c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
34 deletions
+77
-34
AppMain.vue
src/layout/components/AppMain.vue
+77
-34
No files found.
src/layout/components/AppMain.vue
View file @
98268ca7
<
template
>
<section
class=
"app-main"
>
<keep-alive
v-if=
"cachedViews.includes(key)"
>
<router-view
:key=
"key
"
/>
</keep-alive>
<router-view
v-else
:key=
"key
"
/>
<keep-alive
>
<router-view
v-if=
"showCache
"
/>
</keep-alive>
<router-view
v-if=
"!showCache
"
/>
</section>
</
template
>
<
script
>
export
default
{
name
:
'AppMain'
,
computed
:
{
cachedViews
()
{
return
this
.
$store
.
state
.
tagsView
.
cachedViews
export
default
{
name
:
'AppMain'
,
computed
:
{
cachedViews
()
{
return
this
.
$store
.
state
.
tagsView
.
cachedViews
}
},
key
()
{
return
this
.
$route
.
name
watch
:
{
/* 监听cache*/
cachedViews
(
val
)
{
this
.
JSONcachedViews
=
JSON
.
stringify
(
val
)
},
/* 监听tagADD*/
JSONcachedViews
(
nv
,
ov
)
{
let
nvobj
=
JSON
.
parse
(
nv
)
let
ovobj
=
JSON
.
parse
(
ov
||
'{}'
)
this
.
oldCachedViews
=
ovobj
if
(
nvobj
.
length
>
ovobj
.
length
)
{
this
.
addBz
=
true
}
else
{
this
.
addBz
=
false
}
},
/* 监听路由*/
$route
(
val
)
{
let
name
=
val
.
name
if
(
this
.
addBz
)
{
if
(
this
.
cacheList
.
includes
(
name
))
{
this
.
showCache
=
false
}
else
{
this
.
cacheList
.
push
(
name
)
this
.
showCache
=
true
}
this
.
addBz
=
false
}
else
{
this
.
showCache
=
true
}
}
},
data
()
{
return
{
/* 缓存标记*/
showCache
:
true
,
/* 存储新旧缓存列表*/
JSONcachedViews
:
''
,
/* tag新增标记*/
addBz
:
false
,
/* cache列表*/
cacheList
:
[],
}
}
}
}
</
script
>
<
style
lang=
"scss"
scoped
>
.app-main
{
/* 50= navbar 50 */
min-height
:
calc
(
100vh
-
50px
);
width
:
100%
;
position
:
relative
;
overflow
:
hidden
;
}
.fixed-header
+
.app-main
{
padding-top
:
50px
;
}
.hasTagsView
{
.app-main
{
/* 84 = navbar + tags-view = 50 + 34 */
min-height
:
calc
(
100vh
-
84px
);
/* 50= navbar 50 */
min-height
:
calc
(
100vh
-
50px
);
width
:
100%
;
position
:
relative
;
overflow
:
hidden
;
}
.fixed-header
+
.app-main
{
padding-top
:
84px
;
padding-top
:
50px
;
}
.hasTagsView
{
.app-main
{
/* 84 = navbar + tags-view = 50 + 34 */
min-height
:
calc
(
100vh
-
84px
);
}
.fixed-header
+
.app-main
{
padding-top
:
84px
;
}
}
}
</
style
>
<
style
lang=
"scss"
>
// fix css style bug in open el-dialog
.el-popup-parent--hidden
{
.fixed-header
{
padding-right
:
17px
;
// fix css style bug in open el-dialog
.el-popup-parent--hidden
{
.fixed-header
{
padding-right
:
17px
;
}
}
}
</
style
>
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