fix: 修复apiKey 新增成功后列表没有自动刷新
close: #IC8C9I
| | |
| | | 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"; |
| | |
| | | rowSelectEnable?: boolean, |
| | | params?: any, |
| | | paramsToUrl?: boolean, |
| | | editLayout?: EditLayout |
| | | editLayout?: EditLayout, |
| | | onRefresh?: () => void; |
| | | externalRefreshTrigger?: number; // 当这个值变化时触发刷新 |
| | | } |
| | | |
| | | const CrudPage: React.FC<CurdPageProps> = ({ |
| | |
| | | params, |
| | | paramsToUrl = false, |
| | | editLayout, |
| | | externalRefreshTrigger |
| | | }) => { |
| | | |
| | | const isPage = showType === "page"; |
| | |
| | | // |
| | | // console.log("index", urlParams, {pageNumber, pageSize}) |
| | | |
| | | useEffect(() => { |
| | | actions.onFetchList?.(pageNumber, pageSize, urlParams); |
| | | }, [externalRefreshTrigger]); |
| | | |
| | | return ( |
| | | <AntdCrud columns={columnsConfig} |
| | |
| | | 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"; |
| | | |
| | | |
| | | //字段配置 |
| | |
| | | |
| | | 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({ |
| | |
| | | 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); |
| | | } |
| | | }) |
| | | }, |