Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
2a029ba3
authored
Oct 31, 2023
by
xingyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add useTagsView hooks
parent
57e8256e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
src/hooks/web/useTagsView.ts
+63
-0
No files found.
src/hooks/web/useTagsView.ts
0 → 100644
View file @
2a029ba3
import
{
useTagsViewStoreWithOut
}
from
'@/store/modules/tagsView'
import
{
RouteLocationNormalizedLoaded
,
useRouter
}
from
'vue-router'
import
{
computed
,
nextTick
,
unref
}
from
'vue'
export
const
useTagsView
=
()
=>
{
const
tagsViewStore
=
useTagsViewStoreWithOut
()
const
{
replace
,
currentRoute
}
=
useRouter
()
const
selectedTag
=
computed
(()
=>
tagsViewStore
.
getSelectedTag
)
const
closeAll
=
(
callback
?:
Fn
)
=>
{
tagsViewStore
.
delAllViews
()
callback
?.()
}
const
closeLeft
=
(
callback
?:
Fn
)
=>
{
tagsViewStore
.
delLeftViews
(
unref
(
selectedTag
)
as
RouteLocationNormalizedLoaded
)
callback
?.()
}
const
closeRight
=
(
callback
?:
Fn
)
=>
{
tagsViewStore
.
delRightViews
(
unref
(
selectedTag
)
as
RouteLocationNormalizedLoaded
)
callback
?.()
}
const
closeOther
=
(
callback
?:
Fn
)
=>
{
tagsViewStore
.
delOthersViews
(
unref
(
selectedTag
)
as
RouteLocationNormalizedLoaded
)
callback
?.()
}
const
closeCurrent
=
(
view
?:
RouteLocationNormalizedLoaded
,
callback
?:
Fn
)
=>
{
if
(
view
?.
meta
?.
affix
)
return
tagsViewStore
.
delView
(
view
||
unref
(
currentRoute
))
callback
?.()
}
const
refreshPage
=
async
(
view
?:
RouteLocationNormalizedLoaded
,
callback
?:
Fn
)
=>
{
tagsViewStore
.
delCachedView
()
const
{
path
,
query
}
=
view
||
unref
(
currentRoute
)
await
nextTick
()
replace
({
path
:
'/redirect'
+
path
,
query
:
query
})
callback
?.()
}
const
setTitle
=
(
title
:
string
,
path
?:
string
)
=>
{
tagsViewStore
.
setTitle
(
title
,
path
)
}
return
{
closeAll
,
closeLeft
,
closeRight
,
closeOther
,
closeCurrent
,
refreshPage
,
setTitle
}
}
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