tabs支持拖动排序功能

This commit is contained in:
gary.fu
2025-07-01 14:41:56 +08:00
parent e8d3419250
commit 102b639802
2 changed files with 30 additions and 2 deletions

View File

@@ -193,6 +193,12 @@ export const useTabsViewStore = defineStore('tabsView', () => {
}
}
const reIndexHistoryTab = (fromIndex, toIndex) => {
const tabs = historyTabs.value
tabs.splice(toIndex, 0, tabs.splice(fromIndex, 1)[0]) // 插入到 toIndex 位置
console.log('新的tabs顺序', fromIndex, toIndex, tabs.map(t => t.name))
}
watch(currentTab, path => {
currentTabItem.value = historyTabs.value.find(v => path && v.path === path)
})
@@ -234,6 +240,7 @@ export const useTabsViewStore = defineStore('tabsView', () => {
addHistoryTab,
addCachedTab,
removeCachedTab,
reIndexHistoryTab,
hasCloseDropdown
}
}, {