-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(electron): multi tabs support (#7440)
use https://www.electronjs.org/docs/latest/api/web-contents-view to serve different tab views added tabs view manager in electron to handle multi-view actions and events. fix AF-1111 fix AF-999 fix PD-1459 fix AF-964 PD-1458
- Loading branch information
Showing
88 changed files
with
3,157 additions
and
942 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 22 additions & 26 deletions
48
packages/frontend/component/src/ui/scrollbar/use-has-scroll-top.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,27 @@ | ||
import type { RefObject } from 'react'; | ||
import { useEffect, useState } from 'react'; | ||
import { debounce } from 'lodash-es'; | ||
import { useMemo, useState } from 'react'; | ||
|
||
export function useHasScrollTop(ref: RefObject<HTMLElement> | null) { | ||
export function useHasScrollTop() { | ||
const [hasScrollTop, setHasScrollTop] = useState(false); | ||
|
||
useEffect(() => { | ||
if (!ref?.current) { | ||
return; | ||
} | ||
|
||
const container = ref.current; | ||
|
||
function updateScrollTop() { | ||
if (container) { | ||
setTimeout(() => { | ||
const hasScrollTop = container.scrollTop > 0; | ||
setHasScrollTop(hasScrollTop); | ||
}); | ||
} | ||
} | ||
|
||
container.addEventListener('scroll', updateScrollTop); | ||
updateScrollTop(); | ||
return () => { | ||
container.removeEventListener('scroll', updateScrollTop); | ||
const containerRefFn = useMemo(() => { | ||
let unsub: (() => void) | null = null; | ||
return (container: HTMLElement | null) => { | ||
unsub?.(); | ||
const updateScrollTop = debounce(() => { | ||
if (container) { | ||
setTimeout(() => { | ||
const hasScrollTop = container.scrollTop > 0; | ||
setHasScrollTop(hasScrollTop); | ||
}); | ||
} | ||
}, 50); | ||
container?.addEventListener('scroll', updateScrollTop); | ||
updateScrollTop(); | ||
unsub = () => { | ||
container?.removeEventListener('scroll', updateScrollTop); | ||
}; | ||
}; | ||
}, [ref]); | ||
}, []); | ||
|
||
return hasScrollTop; | ||
return [containerRefFn, hasScrollTop] as const; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.