feat(questions): make brand questions the primary monitoring & template axis
- add /questions/combination-fill endpoint with AI-driven, IP-region-aware matrix fill - extract ip2region resolver from ops/app into shared/ipregion for cross-service use - thread question_id filter through dashboard composite, citation summary, and collect-now - switch template wizard from keyword inputs to brand-question selection (primary + supplemental) - pass brand_question and supplemental_questions through assist/title/outline prompts - add AiWaitingModal + 45s client timeout and request_timeout error mapping for long AI flows Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -97,6 +97,7 @@ const errorMessageMap: Record<string, string> = {
|
||||
publisher_plugin_unknown_error: '浏览器插件调用失败,请稍后重试',
|
||||
installation_offline: '桌面客户端未在线,请打开桌面客户端后重试',
|
||||
network_error: '网络连接失败,请稍后重试',
|
||||
request_timeout: '请求超时,AI 生成耗时较长,请稍后重试或稍候再查看结果',
|
||||
unknown_error: '发生未知错误',
|
||||
}
|
||||
|
||||
@@ -136,13 +137,27 @@ export function isHandledAuthError(error: unknown): boolean {
|
||||
)
|
||||
}
|
||||
|
||||
const TIMEOUT_MESSAGE_PATTERN = /^timeout of \d+ms exceeded$/i
|
||||
|
||||
function translateRawErrorMessage(raw: string): string | null {
|
||||
const mapped = errorMessageMap[raw]
|
||||
if (mapped) {
|
||||
return mapped
|
||||
}
|
||||
if (TIMEOUT_MESSAGE_PATTERN.test(raw)) {
|
||||
return errorMessageMap.request_timeout
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
export function formatError(error: unknown): string {
|
||||
if (isHandledAuthError(error)) {
|
||||
return '登录已过期,请重新登录'
|
||||
}
|
||||
|
||||
if (error instanceof ApiClientError) {
|
||||
const message = errorMessageMap[error.message] ?? error.message.replaceAll('_', ' ')
|
||||
const translated = translateRawErrorMessage(error.message)
|
||||
const message = translated ?? error.message.replaceAll('_', ' ')
|
||||
if (isAiPointsInsufficient(error)) {
|
||||
return message
|
||||
}
|
||||
@@ -150,7 +165,7 @@ export function formatError(error: unknown): string {
|
||||
}
|
||||
|
||||
if (error instanceof Error) {
|
||||
return errorMessageMap[error.message] ?? error.message
|
||||
return translateRawErrorMessage(error.message) ?? error.message
|
||||
}
|
||||
|
||||
return '发生未知错误'
|
||||
|
||||
Reference in New Issue
Block a user