mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-14 20:41:15 +08:00
Merge branch 'feature/1.5-cx' into 'main'
feat: feature/1.5-Data Integration See merge request apipark/APIPark!218
This commit is contained in:
@@ -98,7 +98,7 @@ const trimStringValuesInObject = (obj: unknown): unknown => {
|
||||
return obj
|
||||
}
|
||||
|
||||
const processQueryParams = (url: string, options: EoRequest, shouldTransformKeys: boolean, transformParams = true) => {
|
||||
const processQueryParams = (url: string, options: EoRequest, shouldTransformKeys: boolean) => {
|
||||
if (options.eoParams) {
|
||||
const cleanParams = Object.fromEntries(
|
||||
Object.entries(options.eoParams)
|
||||
@@ -106,10 +106,7 @@ const processQueryParams = (url: string, options: EoRequest, shouldTransformKeys
|
||||
.map(([key, value]) => [key, typeof value === 'string' ? value.trim() : value])
|
||||
)
|
||||
const queryParams = convertQueryParamsToSnake(cleanParams, shouldTransformKeys, options.eoTransformKeys as string[])
|
||||
let queryString = queryParams.toString()
|
||||
if (!transformParams) {
|
||||
queryString = decodeURIComponent(queryString)
|
||||
}
|
||||
const queryString = queryParams.toString()
|
||||
url += (url.includes('?') ? '&' : '?') + queryString // 添加查询字符串到URL
|
||||
}
|
||||
return url
|
||||
@@ -140,7 +137,6 @@ type EoRequest = RequestInit & {
|
||||
isStream?: boolean
|
||||
handleStream?: (line: any) => void
|
||||
callback?: (cancel: () => void) => void
|
||||
transformParams?: boolean
|
||||
}
|
||||
|
||||
type EoHeaders = Headers | { [k: string]: string }
|
||||
@@ -166,7 +162,7 @@ export function useFetch() {
|
||||
!shouldNotTransform(url) && options?.eoTransformKeys && options?.eoTransformKeys?.length > 0
|
||||
|
||||
// 处理URL查询参数
|
||||
url = processQueryParams(url, options, !!shouldTransformKeys, options?.transformParams)
|
||||
url = processQueryParams(url, options, !!shouldTransformKeys)
|
||||
|
||||
// 处理请求体, 当请求头为json时,fetch的body应当是json字符串
|
||||
options.body = processRequestBody(options, headers as EoHeaders, !!shouldTransformKeys)
|
||||
|
||||
@@ -31,8 +31,7 @@ const ConfigureOllamaService = forwardRef<ConfigureOllamaServiceHandle, any>((pr
|
||||
.then((value) => {
|
||||
fetchData<BasicResponse<null>>('model/local/source/ollama', {
|
||||
method: 'PUT',
|
||||
eoParams: { address: value.address },
|
||||
transformParams: false
|
||||
eoBody: { address: value.address }
|
||||
})
|
||||
.then((response) => {
|
||||
const { code, msg } = response
|
||||
|
||||
Reference in New Issue
Block a user