first commit

This commit is contained in:
“dongming”
2025-12-28 22:43:26 +08:00
commit ed40350aeb
46 changed files with 14844 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
export const customQuerySerializer = (queryParams: any) => {
const search: string[] = [];
const serialize = (name: string, value: any) => {
if (value === undefined || value === null) return;
if (Array.isArray(value)) {
value.forEach((v, i) => {
serialize(`${name}[${i}]`, v);
});
} else if (typeof value === 'object' && value !== null && !(value instanceof Date)) {
Object.entries(value).forEach(([key, v]) => {
serialize(`${name}[${key}]`, v);
});
} else {
const val = value instanceof Date ? value.toISOString() : String(value);
search.push(`${encodeURIComponent(name)}=${encodeURIComponent(val)}`);
}
};
if (queryParams && typeof queryParams === 'object') {
for (const key in queryParams) {
serialize(key, queryParams[key]);
}
}
return search.join('&');
};