18586361686
2025-05-19 9c9c0629a4849e996bf39dc3bb0a6c0ac7c950ba
fix: 修复apiKey 新增成功后列表没有自动刷新
close: #IC8C9I
2个文件已修改
27 ■■■■■ 已修改文件
aiflowy-ui-react/src/components/CrudPage/index.tsx 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aiflowy-ui-react/src/pages/system/SysApiKey.tsx 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
aiflowy-ui-react/src/components/CrudPage/index.tsx
@@ -1,4 +1,4 @@
import React from 'react';
import React, {useEffect} from 'react';
import {useList, usePage, useRemove, useRemoveBatch, useSave, useUpdate} from "../../hooks/useApis.ts";
import AntdCrud, {ActionConfig, Actions, ColumnsConfig} from "../AntdCrud";
import {Page} from "../../types/Page.ts";
@@ -19,7 +19,9 @@
    rowSelectEnable?: boolean,
    params?: any,
    paramsToUrl?: boolean,
    editLayout?: EditLayout
    editLayout?: EditLayout,
    onRefresh?: () => void;
    externalRefreshTrigger?: number; // 当这个值变化时触发刷新
}
const CrudPage: React.FC<CurdPageProps> = ({
@@ -35,6 +37,7 @@
                                               params,
                                               paramsToUrl = false,
                                               editLayout,
                                               externalRefreshTrigger
                                           }) => {
    const isPage = showType === "page";
@@ -110,6 +113,9 @@
    //
    // console.log("index", urlParams, {pageNumber, pageSize})
    useEffect(() => {
        actions.onFetchList?.(pageNumber, pageSize, urlParams);
    }, [externalRefreshTrigger]);
    return (
        <AntdCrud columns={columnsConfig}
aiflowy-ui-react/src/pages/system/SysApiKey.tsx
@@ -4,7 +4,7 @@
import {EditLayout} from "../../components/AntdCrud/EditForm.tsx";
import {dateFormat} from "../../libs/utils.ts";
import {Button, message, Modal} from "antd";
import {useGetManual, usePostManual} from "../../hooks/useApis.ts";
import {usePostManual} from "../../hooks/useApis.ts";
//字段配置
@@ -90,13 +90,9 @@
export const SysApiKey: React.FC = () => {
    const {doPost: useApiKeyPost} = usePostManual('/api/v1/sysApiKey/key/save');
    const {doGet: doPage} = useGetManual('/api/v1/sysApiKey/page');
    const [queryParam] = useState({
        pageNum: 1,
        pageSize: 10
    });
    const [refreshTrigger, setRefreshTrigger] = useState(0);
    return (
        <CrudPage columnsConfig={columnsConfig} tableAlias="sysApiKey" addButtonEnable={false}
        <CrudPage columnsConfig={columnsConfig} tableAlias="sysApiKey" addButtonEnable={false} externalRefreshTrigger={refreshTrigger}
                  customButton={() => {
                      return <><Button type="primary" onClick={() => {
                              Modal.confirm({
@@ -111,12 +107,7 @@
                                          console.log(res);
                                          if (res.data.errorCode === 0) {
                                              message.success("apiKey生成成功");
                                              doPage({params: {
                                                  ...queryParam,
                                                  }}).then((res) => {
                                                  console.log('res');
                                                  console.log(res);
                                              })
                                              setRefreshTrigger(prev => prev + 1);
                                          }
                                      })
                                  },