mirror of
https://git.mirrors.martin98.com/https://github.com/infiniflow/ragflow.git
synced 2025-06-04 11:24:00 +08:00

### What problem does this PR solve? fix: cannot save the system model setting #468 feat: rename file in FileManager feat: add FileManager feat: override useSelector type ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
30 lines
845 B
TypeScript
30 lines
845 B
TypeScript
import isObject from 'lodash/isObject';
|
|
import snakeCase from 'lodash/snakeCase';
|
|
|
|
export const isFormData = (data: unknown): data is FormData => {
|
|
return data instanceof FormData;
|
|
};
|
|
|
|
const excludedFields = ['img2txt_id'];
|
|
|
|
const isExcludedField = (key: string) => {
|
|
return excludedFields.includes(key);
|
|
};
|
|
|
|
export const convertTheKeysOfTheObjectToSnake = (data: unknown) => {
|
|
if (isObject(data) && !isFormData(data)) {
|
|
return Object.keys(data).reduce<Record<string, any>>((pre, cur) => {
|
|
const value = (data as Record<string, any>)[cur];
|
|
pre[isFormData(value) || isExcludedField(cur) ? cur : snakeCase(cur)] =
|
|
value;
|
|
return pre;
|
|
}, {});
|
|
}
|
|
return data;
|
|
};
|
|
|
|
export const getSearchValue = (key: string) => {
|
|
const params = new URL(document.location as any).searchParams;
|
|
return params.get(key);
|
|
};
|