mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00
perf: logs, auth root as super admin, etc (#2615)
* chore: usePagination hook type * feat: chat log show outlinkuid or tmb avatar and name * fix: ts error for pagination * feat: auth root
This commit is contained in:
@@ -16,7 +16,7 @@ type PagingData<T> = {
|
||||
total?: number;
|
||||
};
|
||||
|
||||
export function usePagination<T = any>({
|
||||
export function usePagination<ResT = any>({
|
||||
api,
|
||||
pageSize = 10,
|
||||
params = {},
|
||||
@@ -25,7 +25,7 @@ export function usePagination<T = any>({
|
||||
onChange,
|
||||
elementRef
|
||||
}: {
|
||||
api: (data: any) => any;
|
||||
api: (data: any) => Promise<PagingData<ResT>>;
|
||||
pageSize?: number;
|
||||
params?: Record<string, any>;
|
||||
defaultRequest?: boolean;
|
||||
@@ -41,7 +41,7 @@ export function usePagination<T = any>({
|
||||
const [total, setTotal] = useState(0);
|
||||
const totalRef = useRef(total);
|
||||
totalRef.current = total;
|
||||
const [data, setData] = useState<T[]>([]);
|
||||
const [data, setData] = useState<ResT[]>([]);
|
||||
const dataLengthRef = useRef(data.length);
|
||||
dataLengthRef.current = data.length;
|
||||
const maxPage = useMemo(() => Math.ceil(total / pageSize) || 1, [pageSize, total]);
|
||||
@@ -49,7 +49,7 @@ export function usePagination<T = any>({
|
||||
const { mutate, isLoading } = useMutation({
|
||||
mutationFn: async (num: number = pageNum) => {
|
||||
try {
|
||||
const res: PagingData<T> = await api({
|
||||
const res: PagingData<ResT> = await api({
|
||||
pageNum: num,
|
||||
pageSize,
|
||||
...params
|
||||
@@ -107,7 +107,7 @@ export function usePagination<T = any>({
|
||||
onKeyDown={(e) => {
|
||||
// @ts-ignore
|
||||
const val = +e.target.value;
|
||||
if (val && e.keyCode === 13) {
|
||||
if (val && e.key === 'Enter') {
|
||||
if (val === pageNum) return;
|
||||
if (val >= maxPage) {
|
||||
mutate(maxPage);
|
||||
|
@@ -72,6 +72,7 @@
|
||||
"logs_empty": "还没有日志噢~",
|
||||
"logs_message_total": "消息总数",
|
||||
"logs_title": "标题",
|
||||
"logs_chat_user": "使用者",
|
||||
"mark_count": "标注答案数量",
|
||||
"module": {
|
||||
"Confirm Sync": "将会更新至最新的模板配置,不存在模板中的字段将会被删除(包括所有自定义字段),建议您先复制一份节点,再更新原来节点的版本。",
|
||||
|
Reference in New Issue
Block a user