refactor(data): 收口关系表运行时数据源
Some checks failed
Deploy Production / Build, push, deploy, verify (push) Has been cancelled
Some checks failed
Deploy Production / Build, push, deploy, verify (push) Has been cancelled
- 移除已迁移业务 AppData 运行时 fallback,改走领域 API 和关系表快读 - 补齐需求产品负责人、版本计划任务 JSON 和成员 username 回填迁移 - 统一治理字典入口,并补充 AI provider、数据源契约和领域服务测试 Co-Authored-By: Codex GPT-5 <codex@openai.com>
This commit is contained in:
@@ -37,6 +37,17 @@ function getErrorMessage(body: unknown, status: number) {
|
||||
return `Request failed: ${status}`;
|
||||
}
|
||||
|
||||
function isAbortLikeError(error: unknown) {
|
||||
const value = error as { name?: unknown; message?: unknown };
|
||||
const text = `${typeof value?.name === 'string' ? value.name : ''} ${typeof value?.message === 'string' ? value.message : String(error ?? '')}`;
|
||||
return /abort|aborted|timeout|timed out/i.test(text);
|
||||
}
|
||||
|
||||
function formatTimeoutMs(timeoutMs: number) {
|
||||
if (timeoutMs >= 60000) return `约 ${Math.ceil(timeoutMs / 60000)} 分钟`;
|
||||
return `${Math.ceil(timeoutMs / 1000)} 秒`;
|
||||
}
|
||||
|
||||
export class ApiRequestError extends Error {
|
||||
constructor(
|
||||
public readonly status: number,
|
||||
@@ -110,6 +121,11 @@ export const api = {
|
||||
throw new ApiRequestError(res.status, err);
|
||||
}
|
||||
return res.json();
|
||||
} catch (e) {
|
||||
if (isAbortLikeError(e)) {
|
||||
throw new Error(`请求超时:服务在${formatTimeoutMs(timeoutMs)}内没有返回,请稍后重试。`);
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
clearTimeout(tid);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user