Fix: Fixed the issue where the error prompt box on the Agent page would be covered #3221 (#8992)

### What problem does this PR solve?

Fix: Fixed the issue where the error prompt box on the Agent page would
be covered #3221

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
balibabu
2025-07-23 15:09:24 +08:00
committed by GitHub
parent b4b6d296ea
commit 03165a1efa
7 changed files with 319 additions and 44 deletions

View File

@ -1,5 +1,8 @@
import { AxiosRequestConfig, AxiosResponse } from 'axios';
import { isObject } from 'lodash';
import omit from 'lodash/omit';
import { RequestMethod } from 'umi-request';
import request from './next-request';
type Service<T extends string> = Record<
T,
@ -39,3 +42,39 @@ const registerServer = <T extends string>(
};
export default registerServer;
export function registerNextServer<T extends string>(
requestRecord: Record<
T,
{ url: string | ((...args: Array<any>) => string); method: string }
>,
) {
type Server = Record<
T,
(
config?:
| AxiosRequestConfig<any>
| Record<string, any>
| string
| number
| boolean
| undefined,
useAxiosNativeConfig?: boolean,
) => Promise<AxiosResponse<any, any>>
>;
const server: Server = {} as Server;
for (const name in requestRecord) {
if (Object.prototype.hasOwnProperty.call(requestRecord, name)) {
const { url, method } = requestRecord[name];
server[name] = (config, useAxiosNativeConfig = false) => {
const nextConfig = useAxiosNativeConfig ? config : { data: config };
const finalConfig = isObject(nextConfig) ? nextConfig : {};
const nextUrl = typeof url === 'function' ? url(config) : url;
return request({ url: nextUrl, method, ...finalConfig });
};
}
}
return server;
}