💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
>[info] Object对象格式化为Query语法 ~~~ /** * @description对象格式化为Query语法 * @param { Object } params * @return {string} Query语法 */ export function objectToQuery(params: Record<string, any>): string { let query = '' for (const props of Object.keys(params)) { const value = params[props] const part = encodeURIComponent(props) + '=' if (!isEmpty(value)) { if (isObject(value)) { for (const key of Object.keys(value)) { if (!isEmpty(value[key])) { const params = props + '[' + key + ']' const subPart = encodeURIComponent(params) + '=' query += subPart + encodeURIComponent(value[key]) + '&' } } } else { query += part + encodeURIComponent(value) + '&' } } } return query.slice(0, -1) } ~~~