mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? fix: Set the default value of Self RAG to false #1220 fix: Change all tool file names to kebab format ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
39
web/src/utils/register-server.ts
Normal file
39
web/src/utils/register-server.ts
Normal file
@ -0,0 +1,39 @@
|
||||
import omit from 'lodash/omit';
|
||||
import { RequestMethod } from 'umi-request';
|
||||
|
||||
type Service<T extends string> = Record<
|
||||
T,
|
||||
(params?: any, urlAppendix?: string) => any
|
||||
>;
|
||||
|
||||
const registerServer = <T extends string>(
|
||||
opt: Record<T, { url: string; method: string }>,
|
||||
request: RequestMethod,
|
||||
) => {
|
||||
const server: Service<T> = {} as Service<T>;
|
||||
for (let key in opt) {
|
||||
server[key] = (params?: any, urlAppendix?: string) => {
|
||||
let url = opt[key].url;
|
||||
const requestOptions = opt[key];
|
||||
if (urlAppendix) {
|
||||
url = url + '/' + urlAppendix;
|
||||
}
|
||||
if (opt[key].method === 'post' || opt[key].method === 'POST') {
|
||||
return request(url, {
|
||||
method: opt[key].method,
|
||||
data: params,
|
||||
});
|
||||
}
|
||||
|
||||
if (opt[key].method === 'get' || opt[key].method === 'GET') {
|
||||
return request.get(url, {
|
||||
...omit(requestOptions, ['method', 'url']),
|
||||
params,
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
return server;
|
||||
};
|
||||
|
||||
export default registerServer;
|
||||
Reference in New Issue
Block a user