@@ -17,7 +17,7 @@ const expand = ref(true)
1717 * get file type icon
1818 *
1919 */
20- const fileTypeMap: any = useFileTypeMap () // 🚨 maybe should fix this any type
20+ const fileTypeMap: any = useFileTypeMap () // 🚨 maybe should fix this " any" type
2121
2222const getFileTypeIcon = (type : string ) => {
2323 const fileType = fileTypeMap .value [type ]
@@ -37,35 +37,40 @@ const getFileTypeIcon = (type:string) => {
3737const folderNavArr = ref ([
3838 {
3939 title: props .rootName ,
40- path: []
40+ path: [] as number []
4141 }
4242])
4343
44- let folderNavPath = []
44+ let folderNavPath: number [] = []
4545
4646const currentTree = ref <NavItem []>([])
4747
4848currentTree .value = props .rootTree
4949
50- const setFolderNavPath = (path ) => {
51- folderNavPath = path
50+ const setFolderNavPath = (path : number []) => {
51+ // path is a number array, which folder at nav been clicked
52+ folderNavPath = path // need to change the folder nav to this path
53+ // rebuild the folderNavArr
54+ // set the root folder (NavItem) as start
5255 let treeTemp = props .rootTree
5356
57+ // the start folderNavArr just contain the root folder
5458 const folderNavArrTemp = [{
5559 title: props .rootName ,
56- path: []
60+ path: [] as number []
5761 }]
5862
59- let folderNavPathTemp = []
63+ let folderNavPathTemp: number [] = []
6064
65+ // loop the path to rebuild the folderNavArr
6166 if (path .length > 0 ) {
6267 path .forEach ((index ) => {
6368 folderNavPathTemp = folderNavPathTemp .concat (index )
6469 folderNavArrTemp .unshift ({
6570 title: treeTemp [index ].title ,
6671 path: folderNavPathTemp
6772 })
68- treeTemp = treeTemp [index ].children
73+ treeTemp = treeTemp [index ].children as NavItem []
6974 })
7075 }
7176
@@ -77,15 +82,15 @@ const setFolderNavPath = (path) => {
7782 })
7883}
7984
80- const addFolderNav = (title , index ) => {
85+ const addFolderNav = (title : string , index : number ) => {
8186 folderNavPath = folderNavPath .concat (index )
8287
8388 folderNavArr .value .unshift ({
8489 title ,
8590 path: folderNavPath
8691 })
8792
88- currentTree .value = currentTree .value [index ].children
93+ currentTree .value = currentTree .value [index ].children as NavItem []
8994
9095 nextTick (() => {
9196 rejudgeShowScrollBtn ()
@@ -106,7 +111,7 @@ const showScrollBtn = ref(true)
106111
107112const scrollPos = ref <' start' | ' middle' | ' end' >(' start' )
108113
109- const folderNavContainer = ref (null )
114+ const folderNavContainer = ref < HTMLElement | null > (null ) // get the folderNav container DOM
110115
111116const rejudgeShowScrollBtn = () => {
112117 // show of hide the scroll button
@@ -136,7 +141,7 @@ onMounted(() => {
136141 })
137142})
138143
139- const scrollFolderNavHandler = (direction ) => {
144+ const scrollFolderNavHandler = (direction : ( ' left ' | ' right ' ) ) => {
140145 if (! folderNavContainer .value ) { return }
141146 const containerWidth = folderNavContainer .value .clientWidth
142147
@@ -166,11 +171,14 @@ const folderNavScrollingHandler = () => {
166171 >
167172 <button
168173 v-show =" !expand"
169- class =" group w-full px-4 py-2 flex items-center gap-1 hover:text-yellow-500 hover:bg-yellow-50 rounded-lg transition-colors duration-300"
174+ :title =" props.rootName"
175+ class =" group w-full px-4 py-2 flex items-start gap-1 hover:text-yellow-500 hover:bg-yellow-50 rounded-lg transition-colors duration-300"
170176 @click =" expand = true"
171177 >
172- <IconCustom name =" ph:folder-fill" class =" w-6 h-6 text-yellow-400" />
173- {{ props.rootName }}
178+ <IconCustom name =" ph:folder-fill" class =" shrink-0 w-6 h-6 text-yellow-400" />
179+ <span class =" line-camp-2 break-all" >
180+ {{ props.rootName }}
181+ </span >
174182 </button >
175183 <div v-show =" expand" class =" w-full flex flex-col" >
176184 <div class =" w-full flex justify-between items-center" >
@@ -234,19 +242,23 @@ const folderNavScrollingHandler = () => {
234242 :key =" item._path"
235243 :to =" item._path"
236244 target =" _blank"
237- class =" p-2 flex items-center gap-1 text-sm rounded hover:text-blue-500 active:text-white hover:bg-blue-100 active:bg-blue-500 transition-colors duration-300"
245+ class =" p-2 flex items-start gap-1 rounded hover:text-blue-500 active:text-white hover:bg-blue-100 active:bg-blue-500 transition-colors duration-300"
238246 >
239- <IconCustom :name =" getFileTypeIcon(item._type)" class =" w-5 h-5" />
240- {{ item.title }}
247+ <IconCustom :name =" getFileTypeIcon(item._type)" class =" shrink-0 w-5 h-5" />
248+ <span class =" text-sm break-all" >
249+ {{ item.title }}
250+ </span >
241251 </NuxtLink >
242252 <button
243253 v-if =" item.children"
244254 :key =" item._path"
245- class =" group p-2 flex items-center gap-1 text-sm rounded hover:text-yellow-500 active:text-white hover:bg-yellow-50 active:bg-yellow-500 transition-colors duration-300"
255+ class =" group p-2 flex items-start gap-1 rounded hover:text-yellow-500 active:text-white hover:bg-yellow-50 active:bg-yellow-500 transition-colors duration-300"
246256 @click =" addFolderNav(item.title, index)"
247257 >
248- <IconCustom name =" ph:folder-fill" class =" w-5 h-5 text-yellow-400 group-active:text-white" />
249- {{ item.title }}
258+ <IconCustom name =" ph:folder-fill" class =" shrink-0 w-5 h-5 text-yellow-400 group-active:text-white" />
259+ <span class =" text-sm break-all" >
260+ {{ item.title }}
261+ </span >
250262 </button >
251263 </template >
252264 </div >
@@ -275,4 +287,11 @@ const folderNavScrollingHandler = () => {
275287 background-color : #94a3b8 ;
276288 }
277289}
290+
291+ .line-camp-2 {
292+ overflow : hidden ;
293+ display : -webkit-box ;
294+ -webkit-box-orient : vertical ;
295+ -webkit-line-clamp : 2 ;
296+ }
278297 </style >
0 commit comments