perf: 完善useTagsView
This commit is contained in:
parent
175abd0aa3
commit
e0c55f40d4
|
@ -13,6 +13,7 @@ import { useTemplateRefsList } from '@vueuse/core'
|
||||||
import { ElScrollbar } from 'element-plus'
|
import { ElScrollbar } from 'element-plus'
|
||||||
import { useScrollTo } from '@/hooks/event/useScrollTo'
|
import { useScrollTo } from '@/hooks/event/useScrollTo'
|
||||||
import { useTagsView } from '@/hooks/web/useTagsView'
|
import { useTagsView } from '@/hooks/web/useTagsView'
|
||||||
|
import { cloneDeep } from 'lodash-es'
|
||||||
|
|
||||||
const { getPrefixCls } = useDesign()
|
const { getPrefixCls } = useDesign()
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ const initTags = () => {
|
||||||
for (const tag of unref(affixTagArr)) {
|
for (const tag of unref(affixTagArr)) {
|
||||||
// Must have tag name
|
// Must have tag name
|
||||||
if (tag.name) {
|
if (tag.name) {
|
||||||
tagsViewStore.addVisitedView(tag)
|
tagsViewStore.addVisitedView(cloneDeep(tag))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,8 +47,8 @@ export const useTagsView = () => {
|
||||||
callback?.()
|
callback?.()
|
||||||
}
|
}
|
||||||
|
|
||||||
const setTitle = (title: string) => {
|
const setTitle = (title: string, path?: string) => {
|
||||||
tagsViewStore.setTitle(title)
|
tagsViewStore.setTitle(title, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -141,9 +141,9 @@ export const useTagsViewStore = defineStore('tagsView', {
|
||||||
setSelectedTag(tag: RouteLocationNormalizedLoaded) {
|
setSelectedTag(tag: RouteLocationNormalizedLoaded) {
|
||||||
this.selectedTag = tag
|
this.selectedTag = tag
|
||||||
},
|
},
|
||||||
setTitle(title: string) {
|
setTitle(title: string, path?: string) {
|
||||||
for (const v of this.visitedViews) {
|
for (const v of this.visitedViews) {
|
||||||
if (v.path === this.selectedTag?.path) {
|
if (v.path === (path ?? this.selectedTag?.path)) {
|
||||||
v.meta.title = title
|
v.meta.title = title
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,16 +40,21 @@ const closeCurrentTab = () => {
|
||||||
const setTabTitle = () => {
|
const setTabTitle = () => {
|
||||||
setTitle(new Date().getTime().toString())
|
setTitle(new Date().getTime().toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const setAnalysisTitle = () => {
|
||||||
|
setTitle(`分析页-${new Date().getTime().toString()}`, '/dashboard/analysis')
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<ContentWrap title="useTagsView">
|
<ContentWrap title="useTagsView">
|
||||||
<ElButton @click="closeAllTabs"> 关闭所有标签页 </ElButton>
|
<ElButton type="primary" @click="closeAllTabs"> 关闭所有标签页 </ElButton>
|
||||||
<ElButton @click="closeLeftTabs"> 关闭左侧标签页 </ElButton>
|
<ElButton type="primary" @click="closeLeftTabs"> 关闭左侧标签页 </ElButton>
|
||||||
<ElButton @click="closeRightTabs"> 关闭右侧标签页 </ElButton>
|
<ElButton type="primary" @click="closeRightTabs"> 关闭右侧标签页 </ElButton>
|
||||||
<ElButton @click="closeOtherTabs"> 关闭其他标签页 </ElButton>
|
<ElButton type="primary" @click="closeOtherTabs"> 关闭其他标签页 </ElButton>
|
||||||
<ElButton @click="closeCurrentTab"> 关闭当前标签页 </ElButton>
|
<ElButton type="primary" @click="closeCurrentTab"> 关闭当前标签页 </ElButton>
|
||||||
<ElButton @click="refresh"> 刷新当前标签页 </ElButton>
|
<ElButton type="primary" @click="refresh"> 刷新当前标签页 </ElButton>
|
||||||
<ElButton @click="setTabTitle"> 修改当前标题 </ElButton>
|
<ElButton type="primary" @click="setTabTitle"> 修改当前标题 </ElButton>
|
||||||
|
<ElButton type="primary" @click="setAnalysisTitle"> 修改分析页标题 </ElButton>
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue