修复导览位置预览与楼层状态
Some checks failed
CI / verify (push) Has been cancelled

This commit is contained in:
lyf
2026-07-19 21:04:57 +08:00
parent 3cba97b786
commit 47dd4c7c87
9 changed files with 128 additions and 28 deletions

View File

@@ -371,10 +371,17 @@ const parseJsonPayload = <T>(payload: unknown, requestUrl: string, contentType:
return payload as T
}
const inFlightRequests = new Map<string, Promise<unknown>>()
const requestJson = <T>(
path: string,
options: { method?: 'GET' | 'POST'; data?: unknown } = {}
): Promise<T> => new Promise((resolve, reject) => {
): Promise<T> => {
const requestKey = `${options.method || 'GET'}:${path}:${JSON.stringify(options.data || {})}`
const existing = inFlightRequests.get(requestKey)
if (existing) return existing as Promise<T>
const request = new Promise<T>((resolve, reject) => {
const baseUrl = resolveAppApiBaseUrl()
const requestUrl = `${baseUrl}${path}`
@@ -412,7 +419,11 @@ const requestJson = <T>(
reject(new Error(`SGS 数据接口网络失败: ${path} ${JSON.stringify(error)}`))
}
})
})
})
inFlightRequests.set(requestKey, request)
void request.finally(() => inFlightRequests.delete(requestKey)).catch(() => undefined)
return request
}
const buildQueryString = (params: object) => {
const query = new URLSearchParams()