Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
zghywpc-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
李苏
zghywpc-vue
Commits
616c1b38
Commit
616c1b38
authored
Aug 12, 2024
by
李苏
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
路由基础页调整,需要功能页定义name对应路由name实现动态缓存
parent
b6c9b8c6
Pipeline
#279
canceled with stages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
73 deletions
+3
-73
AppMain.vue
src/layout/components/AppMain.vue
+3
-73
No files found.
src/layout/components/AppMain.vue
View file @
616c1b38
<
template
>
<!--
当每个页面赋值name
并且二级目录的路由标签组件也赋值name
name 对应路由name 使用include生效
换成如下方案
<
template
>
<
template
>
<section
class=
"app-main"
>
<section
class=
"app-main"
>
<transition
name=
"fade-transform"
mode=
"out-in"
>
<transition
name=
"fade-transform"
mode=
"out-in"
>
...
@@ -17,6 +13,7 @@
...
@@ -17,6 +13,7 @@
<
script
>
<
script
>
export
default
{
export
default
{
name
:
'AppMain'
,
name
:
'AppMain'
,
computed
:
{
computed
:
{
...
@@ -30,75 +27,8 @@
...
@@ -30,75 +27,8 @@
}
}
</
script
>
</
script
>
-->
<section
class=
"app-main"
>
<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
}
},
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
)
{
if
(
val
.
meta
.
noCache
){
this
.
showCache
=
false
}
else
{
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
>
<
style
lang=
"scss"
scoped
>
.app-main
{
.app-main
{
...
...
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