feat:#1658 增加全局订阅 setQuery 用户可以动态变更当前页query而不产生新的tab
This commit is contained in:
parent
7835efbf37
commit
88f48baba1
|
@ -292,6 +292,18 @@ const initPage = () => {
|
||||||
emitter.on('collapse', (data) => {
|
emitter.on('collapse', (data) => {
|
||||||
isCollapse.value = data
|
isCollapse.value = data
|
||||||
})
|
})
|
||||||
|
|
||||||
|
emitter.on('setQuery', (data) => {
|
||||||
|
const index = historys.value.findIndex(
|
||||||
|
(item) => getFmtString(item) === activeValue.value
|
||||||
|
)
|
||||||
|
historys.value[index].query = data
|
||||||
|
activeValue.value = getFmtString(historys.value[index])
|
||||||
|
const currentUrl = window.location.href.split('?')[0]
|
||||||
|
const currentSearchParams = new URLSearchParams(data).toString()
|
||||||
|
window.history.pushState({}, '', `${currentUrl}?${currentSearchParams}`)
|
||||||
|
sessionStorage.setItem('historys', JSON.stringify(historys.value))
|
||||||
|
})
|
||||||
const initHistorys = [
|
const initHistorys = [
|
||||||
{
|
{
|
||||||
name: defaultRouter.value,
|
name: defaultRouter.value,
|
||||||
|
@ -302,6 +314,7 @@ const initPage = () => {
|
||||||
params: {},
|
params: {},
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
setTab(route)
|
||||||
historys.value =
|
historys.value =
|
||||||
JSON.parse(sessionStorage.getItem('historys')) || initHistorys
|
JSON.parse(sessionStorage.getItem('historys')) || initHistorys
|
||||||
if (!window.sessionStorage.getItem('activeValue')) {
|
if (!window.sessionStorage.getItem('activeValue')) {
|
||||||
|
@ -309,7 +322,6 @@ const initPage = () => {
|
||||||
} else {
|
} else {
|
||||||
activeValue.value = window.sessionStorage.getItem('activeValue')
|
activeValue.value = window.sessionStorage.getItem('activeValue')
|
||||||
}
|
}
|
||||||
setTab(route)
|
|
||||||
if (window.sessionStorage.getItem('needCloseAll') === 'true') {
|
if (window.sessionStorage.getItem('needCloseAll') === 'true') {
|
||||||
closeAll()
|
closeAll()
|
||||||
window.sessionStorage.removeItem('needCloseAll')
|
window.sessionStorage.removeItem('needCloseAll')
|
||||||
|
|
Loading…
Reference in New Issue