mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-04-24 15:37:19 +08:00
30 lines
694 B
TypeScript
30 lines
694 B
TypeScript
import { EnclosureHttpRequestConfig } from "./types.d";
|
|
|
|
export function excludeProps<T extends { [key: string]: any }>(
|
|
origin: T,
|
|
prop: string
|
|
): { [key: string]: T } {
|
|
return Object.keys(origin)
|
|
.filter(key => !prop.includes(key))
|
|
.reduce((res, key) => {
|
|
res[key] = origin[key];
|
|
return res;
|
|
}, {} as { [key: string]: T });
|
|
}
|
|
|
|
export function transformConfigByMethod(
|
|
params: any,
|
|
config: EnclosureHttpRequestConfig
|
|
): EnclosureHttpRequestConfig {
|
|
const { method } = config;
|
|
const props = ["delete", "get", "head", "options"].includes(
|
|
method!.toLocaleLowerCase()
|
|
)
|
|
? "params"
|
|
: "data";
|
|
return {
|
|
...config,
|
|
[props]: params
|
|
};
|
|
}
|