@@ -13,7 +13,7 @@ import fileIcon from '/src/assets/icons/file.svg'
1313import addIcon from '/src/assets/icons/add.svg'
1414import deleteIcon from '/src/assets/icons/delete.svg'
1515import renameIcon from '/src/assets/icons/rename.svg'
16- import { useEffect , useMemo , useRef , useState } from 'react'
16+ import { CSSProperties , useEffect , useMemo , useRef , useState } from 'react'
1717import { useEvents } from '@renderer/hooks/use-events'
1818import { PushDataTypes } from '@renderer/constant/feed'
1919import { get } from 'lodash'
@@ -175,7 +175,7 @@ const Node = ({ node, dragHandle }: NodeRendererProps<VaultTreeNode>) => {
175175 )
176176}
177177
178- const Sidebar = ( { className } : { className ?: string } ) => {
178+ const Sidebar = ( { className } : { className ?: string } ) => {
179179 const {
180180 vaults : treeData ,
181181 updateVaultPosition,
@@ -251,29 +251,29 @@ const Sidebar = ({ className } : { className?: string }) => {
251251 const treeContainerRef = useRef < HTMLDivElement > ( null )
252252 const [ treeDimensions , setTreeDimensions ] = useState ( { width : 200 , height : 600 } )
253253 useEffect ( ( ) => {
254- if ( ! treeContainerRef . current ) return
254+ if ( ! treeContainerRef . current ) return
255255
256- const updateSize = ( ) => {
257- const el = treeContainerRef . current
258- if ( ! el ) return
259- setTreeDimensions ( {
260- height : el . clientHeight ,
261- width : el . clientWidth
262- } )
263- }
264-
265- // 初始化时先更新一次
266- updateSize ( )
256+ const updateSize = ( ) => {
257+ const el = treeContainerRef . current
258+ if ( ! el ) return
259+ setTreeDimensions ( {
260+ height : el . clientHeight ,
261+ width : el . clientWidth
262+ } )
263+ }
267264
268- const observer = new ResizeObserver ( ( ) => {
265+ // 初始化时先更新一次
269266 updateSize ( )
270- } )
271267
272- observer . observe ( treeContainerRef . current )
268+ const observer = new ResizeObserver ( ( ) => {
269+ updateSize ( )
270+ } )
271+
272+ observer . observe ( treeContainerRef . current )
273273
274- // 清理 observer
275- return ( ) => observer . disconnect ( )
276- } , [ treeContainerRef ] )
274+ // 清理 observer
275+ return ( ) => observer . disconnect ( )
276+ } , [ treeContainerRef ] )
277277
278278 const onRename = ( { id, name } : { id : string ; name : string } ) => {
279279 onRenameVault ( Number ( id ) , name )
@@ -315,7 +315,9 @@ const Sidebar = ({ className } : { className?: string }) => {
315315 )
316316
317317 return (
318- < div className = { clsx ( 'flex flex-col min-h-[0]' , className ) } style = { { marginTop : 12 } } >
318+ < div
319+ className = { clsx ( 'flex flex-col min-h-[0]' , className ) }
320+ style = { { marginTop : 12 , appRegion : 'no-drag' } as CSSProperties } >
319321 < div className = "flex flex-col flex-1 min-h-[0]" >
320322 { /* Vault notes section */ }
321323 < div className = "px-[12px] shrink-0" >
@@ -334,23 +336,25 @@ const Sidebar = ({ className } : { className?: string }) => {
334336 </ div >
335337
336338 { /* Modern tree structure */ }
337- < div className = "text-black flex-1 min-h-[0] [&_.arco-typography]: !font-[13px] overflow-auto" ref = { treeContainerRef } >
339+ < div
340+ className = "text-black flex-1 min-h-[0] [&_.arco-typography]: !font-[13px] overflow-auto"
341+ ref = { treeContainerRef } >
338342 < Tree
339- idAccessor = { ( data ) => data . id . toString ( ) }
340- data = { treeData ?. children || [ ] }
341- onRename = { onRename }
342- onMove = { onMove }
343- width = { treeDimensions . width }
344- height = { treeDimensions . height }
345- rowHeight = { 32 }
346- indent = { 0 }
347- onActivate = { ( node ) => {
348- if ( node . data . is_folder !== 1 ) {
349- navigateToVault ( node . data . id )
350- }
351- } } >
352- { Node }
353- </ Tree >
343+ idAccessor = { ( data ) => data . id . toString ( ) }
344+ data = { treeData ?. children || [ ] }
345+ onRename = { onRename }
346+ onMove = { onMove }
347+ width = { treeDimensions . width }
348+ height = { treeDimensions . height }
349+ rowHeight = { 32 }
350+ indent = { 0 }
351+ onActivate = { ( node ) => {
352+ if ( node . data . is_folder !== 1 ) {
353+ navigateToVault ( node . data . id )
354+ }
355+ } } >
356+ { Node }
357+ </ Tree >
354358 </ div >
355359 </ div >
356360 </ div >
0 commit comments