mirror of
https://github.com/zclzone/vue-naive-admin.git
synced 2026-01-09 09:40:21 +08:00
style: lint
This commit is contained in:
@@ -17,7 +17,7 @@ export const useTabStore = defineStore('tab', {
|
||||
}),
|
||||
getters: {
|
||||
activeIndex() {
|
||||
return this.tabs.findIndex((item) => item.path === this.activeTab)
|
||||
return this.tabs.findIndex(item => item.path === this.activeTab)
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
@@ -29,19 +29,22 @@ export const useTabStore = defineStore('tab', {
|
||||
this.tabs = tabs
|
||||
},
|
||||
addTab(tab = {}) {
|
||||
const findIndex = this.tabs.findIndex((item) => item.path === tab.path)
|
||||
const findIndex = this.tabs.findIndex(item => item.path === tab.path)
|
||||
if (findIndex !== -1) {
|
||||
this.tabs.splice(findIndex, 1, tab)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
this.setTabs([...this.tabs, tab])
|
||||
}
|
||||
this.setActiveTab(tab.path)
|
||||
},
|
||||
async reloadTab(path, keepAlive) {
|
||||
const findItem = this.tabs.find((item) => item.path === path)
|
||||
if (!findItem) return
|
||||
const findItem = this.tabs.find(item => item.path === path)
|
||||
if (!findItem)
|
||||
return
|
||||
// 更新key可让keepAlive失效
|
||||
if (keepAlive) findItem.keepAlive = false
|
||||
if (keepAlive)
|
||||
findItem.keepAlive = false
|
||||
$loadingBar.start()
|
||||
this.reloading = true
|
||||
await nextTick()
|
||||
@@ -53,30 +56,30 @@ export const useTabStore = defineStore('tab', {
|
||||
}, 100)
|
||||
},
|
||||
async removeTab(path) {
|
||||
this.setTabs(this.tabs.filter((tab) => tab.path !== path))
|
||||
this.setTabs(this.tabs.filter(tab => tab.path !== path))
|
||||
if (path === this.activeTab) {
|
||||
useRouterStore().router?.push(this.tabs[this.tabs.length - 1].path)
|
||||
}
|
||||
},
|
||||
removeOther(curPath = this.activeTab) {
|
||||
this.setTabs(this.tabs.filter((tab) => tab.path === curPath))
|
||||
this.setTabs(this.tabs.filter(tab => tab.path === curPath))
|
||||
if (curPath !== this.activeTab) {
|
||||
useRouterStore().router?.push(this.tabs[this.tabs.length - 1].path)
|
||||
}
|
||||
},
|
||||
removeLeft(curPath) {
|
||||
const curIndex = this.tabs.findIndex((item) => item.path === curPath)
|
||||
const curIndex = this.tabs.findIndex(item => item.path === curPath)
|
||||
const filterTabs = this.tabs.filter((item, index) => index >= curIndex)
|
||||
this.setTabs(filterTabs)
|
||||
if (!filterTabs.find((item) => item.path === this.activeTab)) {
|
||||
if (!filterTabs.find(item => item.path === this.activeTab)) {
|
||||
useRouterStore().router?.push(filterTabs[filterTabs.length - 1].path)
|
||||
}
|
||||
},
|
||||
removeRight(curPath) {
|
||||
const curIndex = this.tabs.findIndex((item) => item.path === curPath)
|
||||
const curIndex = this.tabs.findIndex(item => item.path === curPath)
|
||||
const filterTabs = this.tabs.filter((item, index) => index <= curIndex)
|
||||
this.setTabs(filterTabs)
|
||||
if (!filterTabs.find((item) => item.path === this.activeTab.value)) {
|
||||
if (!filterTabs.find(item => item.path === this.activeTab.value)) {
|
||||
useRouterStore().router?.push(filterTabs[filterTabs.length - 1].path)
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user