This commit is contained in:
Ah jung
2021-07-17 17:09:28 +08:00
parent ab4063e75e
commit c1e741dad6
+9 -8
View File
@@ -211,7 +211,7 @@ export default defineComponent({
if (whiteList.includes(route.name as string) || ['ErrorPage'].includes(route.name as string)) return if (whiteList.includes(route.name as string) || ['ErrorPage'].includes(route.name as string)) return
state.activeKey = to state.activeKey = to
tabsViewStore.addTabs(getSimpleRoute(route)) tabsViewStore.addTabs(getSimpleRoute(route))
onElementResize() updateNavScroll()
}, },
{ immediate: true } { immediate: true }
) )
@@ -234,7 +234,7 @@ export default defineComponent({
state.activeKey = currentRoute.fullPath state.activeKey = currentRoute.fullPath
router.push(currentRoute) router.push(currentRoute)
} }
onElementResize() updateNavScroll()
} }
// 刷新页面 // 刷新页面
@@ -253,7 +253,7 @@ export default defineComponent({
tabsViewStore.closeLeftTabs(route) tabsViewStore.closeLeftTabs(route)
state.activeKey = route.fullPath state.activeKey = route.fullPath
router.replace(route.fullPath) router.replace(route.fullPath)
onElementResize() updateNavScroll()
} }
// 关闭右侧 // 关闭右侧
@@ -261,7 +261,7 @@ export default defineComponent({
tabsViewStore.closeRightTabs(route) tabsViewStore.closeRightTabs(route)
state.activeKey = route.fullPath state.activeKey = route.fullPath
router.replace(route.fullPath) router.replace(route.fullPath)
onElementResize() updateNavScroll()
} }
// 关闭其他 // 关闭其他
@@ -269,7 +269,7 @@ export default defineComponent({
tabsViewStore.closeOtherTabs(route) tabsViewStore.closeOtherTabs(route)
state.activeKey = route.fullPath state.activeKey = route.fullPath
router.replace(route.fullPath) router.replace(route.fullPath)
onElementResize() updateNavScroll()
} }
// 关闭全部 // 关闭全部
@@ -277,7 +277,7 @@ export default defineComponent({
localStorage.removeItem('routes') localStorage.removeItem('routes')
tabsViewStore.closeAllTabs() tabsViewStore.closeAllTabs()
router.replace('/') router.replace('/')
onElementResize() updateNavScroll()
} }
//tab 操作 //tab 操作
@@ -300,7 +300,7 @@ export default defineComponent({
closeAll() closeAll()
break break
} }
onElementResize() updateNavScroll()
} }
function getCurrentScrollOffset() { function getCurrentScrollOffset() {
@@ -336,7 +336,8 @@ export default defineComponent({
} }
function updateNavScroll() { function updateNavScroll() {
const navWidth = navRef.value.offsetWidth if(!navRef.value)return
const navWidth = (navRef.value.offsetWidth + 32)
const containerWidth = navScroll.value.offsetWidth const containerWidth = navScroll.value.offsetWidth
const currentOffset = getCurrentScrollOffset() const currentOffset = getCurrentScrollOffset()
if (containerWidth < navWidth) { if (containerWidth < navWidth) {