11<script setup lang="ts">
22import type { RouteLocationNormalized } from ' vue-router'
33import { useAppStore , useTabStore } from ' @/store'
4+ import { useTabScroll } from ' @/hooks/useTabScroll'
45import { useDraggable } from ' vue-draggable-plus'
56import IconClose from ' ~icons/icon-park-outline/close'
67import IconDelete from ' ~icons/icon-park-outline/delete-four'
@@ -17,6 +18,8 @@ const tabStore = useTabStore()
1718const { tabs } = storeToRefs (useTabStore ())
1819const appStore = useAppStore ()
1920
21+ const {scrollbar, onWheel } = useTabScroll (computed (() => tabStore .currentTabPath ))
22+
2023const router = useRouter ()
2124function handleTab(route : RouteLocationNormalized ) {
2225 router .push (route .fullPath )
@@ -111,32 +114,38 @@ useDraggable(el, tabs, {
111114 </script >
112115
113116<template >
114- <div class =" p-l-2 flex w-full relative" >
115- <div class =" flex items-end" >
116- <TabBarItem
117- v-for =" item in tabStore.pinTabs" :key =" item.fullPath" :value =" tabStore.currentTabPath" :route =" item"
118- @click =" handleTab(item)"
119- />
120- </div >
121- <div ref =" el" class =" flex items-end flex-1" >
122- <TabBarItem
123- v-for =" item in tabStore.tabs" :key =" item.fullPath" :value =" tabStore.currentTabPath" :route =" item" closable
124- @close =" tabStore.closeTab"
125- @click =" handleTab(item)"
126- @contextmenu =" handleContextMenu($event, item)"
127- />
128- <n-dropdown
129- placement =" bottom-start" trigger =" manual" :x =" x" :y =" y" :options =" options" :show =" showDropdown"
130- :on-clickoutside =" onClickoutside" @select =" handleSelect"
131- />
117+ <n-scrollbar ref =" scrollbar" class =" relative flex tab-bar-scroller-wrapper" content-class =" pr-34 tab-bar-scroller-content" :x-scrollable =" true" @wheel =" onWheel" >
118+ <div class =" p-l-2 flex w-full relative" >
119+ <div class =" flex items-end" >
120+ <TabBarItem
121+ v-for =" item in tabStore.pinTabs" :key =" item.fullPath" :value =" tabStore.currentTabPath" :route =" item"
122+ @click =" handleTab(item)"
123+ />
124+ </div >
125+ <div ref =" el" class =" flex items-end flex-1" >
126+ <TabBarItem
127+ v-for =" item in tabStore.tabs"
128+ :key =" item.fullPath"
129+ :value =" tabStore.currentTabPath"
130+ :route =" item"
131+ closable
132+ :data-tab-path =" item.fullPath"
133+ @close =" tabStore.closeTab"
134+ @click =" handleTab(item)"
135+ @contextmenu =" handleContextMenu($event, item)"
136+ />
137+ <n-dropdown
138+ placement =" bottom-start" trigger =" manual" :x =" x" :y =" y" :options =" options" :show =" showDropdown"
139+ :on-clickoutside =" onClickoutside" @select =" handleSelect"
140+ />
141+ </div >
132142 </div >
133- <!-- <span class="m-l-auto" /> -->
134- <n-el class =" absolute right-0 flex items-center gap-1 bg-[var(--base-color)] h-full" >
143+ <n-el class =" absolute right-0 top-0 flex items-center gap-1 bg-[var(--base-color)] h-full" >
135144 <Reload />
136145 <ContentFullScreen />
137146 <DropTabs />
138147 </n-el >
139- </div >
148+ </n-scrollbar >
140149</template >
141150
142151<style scoped>
0 commit comments