mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### 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:
@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user