mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-05-03 18:50:43 +08:00
feat: enhance auto-play
This commit is contained in:
@@ -54,12 +54,14 @@ export function MultiAgentVisualization({ className }: { className?: string }) {
|
|||||||
} = useMAVStore((state) => state);
|
} = useMAVStore((state) => state);
|
||||||
const flowRef = useRef<ReactFlowInstance<GraphNode, Edge>>(null);
|
const flowRef = useRef<ReactFlowInstance<GraphNode, Edge>>(null);
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [hasPlayed, setHasPlayed] = useState(false);
|
||||||
const [fullscreen, setFullscreen] = useState(false);
|
const [fullscreen, setFullscreen] = useState(false);
|
||||||
const { ref: anchorRef } = useIntersectionObserver({
|
const { ref: anchorRef } = useIntersectionObserver({
|
||||||
rootMargin: "0%",
|
rootMargin: "0%",
|
||||||
threshold: 0,
|
threshold: 0,
|
||||||
onChange: (isIntersecting) => {
|
onChange: (isIntersecting) => {
|
||||||
if (isIntersecting && !playing) {
|
if (isIntersecting && !playing && !hasPlayed) {
|
||||||
|
setHasPlayed(true);
|
||||||
void play();
|
void play();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -132,7 +134,13 @@ export function MultiAgentVisualization({ className }: { className?: string }) {
|
|||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip title="Move to the next step">
|
<Tooltip title="Move to the next step">
|
||||||
<Button variant="ghost" onClick={nextStep}>
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
onClick={() => {
|
||||||
|
setHasPlayed(true);
|
||||||
|
nextStep();
|
||||||
|
}}
|
||||||
|
>
|
||||||
<ChevronRight className="size-5" />
|
<ChevronRight className="size-5" />
|
||||||
</Button>
|
</Button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@@ -144,13 +152,20 @@ export function MultiAgentVisualization({ className }: { className?: string }) {
|
|||||||
step={1}
|
step={1}
|
||||||
value={[activeStepIndex >= 0 ? activeStepIndex : 0]}
|
value={[activeStepIndex >= 0 ? activeStepIndex : 0]}
|
||||||
onValueChange={([value]) => {
|
onValueChange={([value]) => {
|
||||||
console.info("jump", value);
|
setHasPlayed(true);
|
||||||
activateStep(value!);
|
activateStep(value!);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Tooltip title="Toggle fullscreen">
|
<Tooltip title="Toggle fullscreen">
|
||||||
<Button variant="ghost" size="icon" onClick={toggleFullscreen}>
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
size="icon"
|
||||||
|
onClick={() => {
|
||||||
|
setHasPlayed(true);
|
||||||
|
void toggleFullscreen();
|
||||||
|
}}
|
||||||
|
>
|
||||||
{fullscreen ? (
|
{fullscreen ? (
|
||||||
<Minimize className="size-5" />
|
<Minimize className="size-5" />
|
||||||
) : (
|
) : (
|
||||||
|
|||||||
Reference in New Issue
Block a user