mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-31 09:05:30 +08:00
### What problem does this PR solve? Feat: Add note node #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
35
web/src/pages/agent/hooks/use-move-note.ts
Normal file
35
web/src/pages/agent/hooks/use-move-note.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { useMouse } from 'ahooks';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
export function useMoveNote() {
|
||||
const ref = useRef<SVGSVGElement>(null);
|
||||
const mouse = useMouse();
|
||||
const [imgVisible, setImgVisible] = useState(false);
|
||||
|
||||
const toggleVisible = useCallback((visible: boolean) => {
|
||||
setImgVisible(visible);
|
||||
}, []);
|
||||
|
||||
const showImage = useCallback(() => {
|
||||
toggleVisible(true);
|
||||
}, [toggleVisible]);
|
||||
|
||||
const hideImage = useCallback(() => {
|
||||
toggleVisible(false);
|
||||
}, [toggleVisible]);
|
||||
|
||||
useEffect(() => {
|
||||
if (ref.current) {
|
||||
ref.current.style.top = `${mouse.clientY - 70}px`;
|
||||
ref.current.style.left = `${mouse.clientX + 10}px`;
|
||||
}
|
||||
}, [mouse.clientX, mouse.clientY]);
|
||||
|
||||
return {
|
||||
ref,
|
||||
showImage,
|
||||
hideImage,
|
||||
mouse,
|
||||
imgVisible,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user