Initial commit: GovAI 政务AI平台
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback, useEffect, useRef } from "react";
|
||||
|
||||
/**
|
||||
* 自动滚动到容器底部。
|
||||
* 当 deps 变化时触发滚动(通常传入 messages 数组)。
|
||||
*/
|
||||
export function useScrollToBottom(deps: unknown[]) {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
|
||||
const scrollToBottom = useCallback(() => {
|
||||
ref.current?.scrollIntoView({ behavior: "smooth" });
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
scrollToBottom();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, deps);
|
||||
|
||||
return ref;
|
||||
}
|
||||
Reference in New Issue
Block a user