Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TF-MOM-WEB
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
TFMOM
TF-MOM-WEB
Commits
7b0c1690
Commit
7b0c1690
authored
Nov 07, 2024
by
jingnan
👀
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
历史页签缓存至localstorage
parent
2e589749
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
21 deletions
+25
-21
index.vue
...architecture-dee/src/layout/components/TagsView/index.vue
+19
-19
tagsView.js
applications/architecture-dee/src/store/modules/tagsView.js
+6
-2
No files found.
applications/architecture-dee/src/layout/components/TagsView/index.vue
View file @
7b0c1690
...
...
@@ -214,25 +214,25 @@ export default {
},
getVisitedViews
()
{
setTimeout
(()
=>
{
if
(
!
this
.
$utils
.
_get
(
this
.
showViews
,
this
.
activeModel
.
id
))
{
this
.
visitedViews
=
[]
}
else
{
// this.$set(this, 'visitedViews', this.$store.state.tagsView.visitedViews[this.activeModel.id].filter(x => (x.path !== '/dee-task-center/workflow/task-center/home')))
let
list
=
[]
Object
.
keys
(
this
.
$store
.
state
.
tagsView
.
visitedViews
).
forEach
(
key
=>
{
list
=
[...
list
,
...
this
.
$store
.
state
.
tagsView
.
visitedViews
[
key
]]
})
const
filterViews
=
list
.
filter
(
x
=>
(
x
.
path
!==
'/home'
&&
x
.
path
!==
'/businessHome'
&&
x
.
path
!==
'/systemHome'
&&
x
.
path
!==
'/DevopsHome'
&&
x
.
path
!==
'/safeHome'
))
const
tempViews
=
filterViews
.
reduce
((
acc
,
current
)
=>
{
const
exists
=
acc
.
find
(
item
=>
item
.
title
===
current
.
title
)
if
(
!
exists
)
{
acc
.
push
(
current
)
}
return
acc
},
[])
this
.
$set
(
this
,
'visitedViews'
,
tempViews
)
// this.$set(this, 'visitedViews', list.filter(x => (x.path !== '/home' && x.path !== '/businessHome' && x.path !== '/systemHome' && x.path !== '/DevopsHome' && x.path !== '/safeHome')))
}
//
if (!this.$utils._get(this.showViews, this.activeModel.id)) {
//
this.visitedViews = []
//
} else {
// this.$set(this, 'visitedViews', this.$store.state.tagsView.visitedViews[this.activeModel.id].filter(x => (x.path !== '/dee-task-center/workflow/task-center/home')))
let
list
=
[]
Object
.
keys
(
this
.
$store
.
state
.
tagsView
.
visitedViews
).
forEach
(
key
=>
{
list
=
[...
list
,
...
this
.
$store
.
state
.
tagsView
.
visitedViews
[
key
]]
})
const
filterViews
=
list
.
filter
(
x
=>
(
x
.
path
!==
'/home'
&&
x
.
path
!==
'/businessHome'
&&
x
.
path
!==
'/systemHome'
&&
x
.
path
!==
'/DevopsHome'
&&
x
.
path
!==
'/safeHome'
))
const
tempViews
=
filterViews
.
reduce
((
acc
,
current
)
=>
{
const
exists
=
acc
.
find
(
item
=>
item
.
title
===
current
.
title
)
if
(
!
exists
)
{
acc
.
push
(
current
)
}
return
acc
},
[])
this
.
$set
(
this
,
'visitedViews'
,
tempViews
)
// this.$set(this, 'visitedViews', list.filter(x => (x.path !== '/home' && x.path !== '/businessHome' && x.path !== '/systemHome' && x.path !== '/DevopsHome' && x.path !== '/safeHome')))
//
}
},
0
)
},
// 更新标签 title
...
...
applications/architecture-dee/src/store/modules/tagsView.js
View file @
7b0c1690
const
state
=
{
visitedViews
:
sessionStorage
.
getItem
(
'visitedViews'
)
?
JSON
.
parse
(
session
Storage
.
getItem
(
'visitedViews'
))
:
{},
visitedViews
:
localStorage
.
getItem
(
'visitedViews'
)
?
JSON
.
parse
(
local
Storage
.
getItem
(
'visitedViews'
))
:
{},
cachedViews
:
[],
previousRouter
:
[],
cachedMenuPages
:
{}
...
...
@@ -8,7 +8,7 @@ const state = {
const
mutations
=
{
ADD_VISITED_VIEW
:
(
state
,
view
)
=>
{
if
(
view
.
belongModel
!==
'todoTask'
&&
view
.
path
.
includes
(
'/dee-task-center/workflow/task-center/home'
))
return
if
(
view
.
belongModel
!==
'todoTask'
&&
view
.
path
.
includes
(
'/dee-task-center/workflow/task-center/home'
))
return
state
.
previousRouter
.
unshift
({
...
view
})
// 记录前一路由地址
state
.
previousRouter
=
state
.
previousRouter
.
splice
(
0
,
2
)
const
belongModel
=
sessionStorage
.
getItem
(
'activePageModel'
)
?
JSON
.
parse
(
sessionStorage
.
getItem
(
'activePageModel'
)).
id
:
'todoTask'
...
...
@@ -40,6 +40,7 @@ const mutations = {
state.visitedViews[belongModel].shift()
}*/
sessionStorage
.
setItem
(
'visitedViews'
,
JSON
.
stringify
(
state
.
visitedViews
))
localStorage
.
setItem
(
'visitedViews'
,
JSON
.
stringify
(
state
.
visitedViews
))
},
ADD_CACHED_VIEW
:
(
state
,
view
)
=>
{
if
(
state
.
cachedViews
.
includes
(
view
.
name
)
||
view
.
name
===
'navigation'
)
return
...
...
@@ -61,6 +62,7 @@ const mutations = {
}
}
sessionStorage
.
setItem
(
'visitedViews'
,
JSON
.
stringify
(
state
.
visitedViews
))
localStorage
.
setItem
(
'visitedViews'
,
JSON
.
stringify
(
state
.
visitedViews
))
},
DEL_CACHED_VIEW
:
(
state
,
view
)
=>
{
const
index
=
state
.
cachedViews
.
indexOf
(
view
.
name
)
...
...
@@ -76,6 +78,7 @@ const mutations = {
return
v
.
meta
.
affix
||
v
.
path
===
view
.
path
})
sessionStorage
.
setItem
(
'visitedViews'
,
JSON
.
stringify
(
state
.
visitedViews
))
localStorage
.
setItem
(
'visitedViews'
,
JSON
.
stringify
(
state
.
visitedViews
))
},
DEL_OTHERS_CACHED_VIEWS
:
(
state
,
view
)
=>
{
const
index
=
state
.
cachedViews
.
indexOf
(
view
.
name
)
...
...
@@ -90,6 +93,7 @@ const mutations = {
DEL_ALL_VISITED_VIEWS
:
state
=>
{
state
.
visitedViews
=
{}
sessionStorage
.
setItem
(
'visitedViews'
,
'{}'
)
// localStorage.setItem('visitedViews', '{}')
},
DEL_ALL_CACHED_VIEWS
:
state
=>
{
state
.
cachedViews
=
[]
...
...
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