/** * 后台提示语把关(2026-10-09):只把中文给用户看。 * * Java 侧仍有出口把底层异常原文写进 message/errorMessage,后台同学看到 * `Invalid export date range` 这类句子既看不懂也没法转述给用户。这里统一换成中文兜底句, * 原文进 console 供对着日志核对。 */ const CJK = /[\u3400-\u4dbf\u4e00-\u9fff]/ export const NOTICE_FALLBACK = '操作未能完成,请稍后重试' export function userNotice(text?: string | null, fallback: string = NOTICE_FALLBACK): string { const raw = typeof text === 'string' ? text.trim() : '' if (!raw) { return fallback } if (!CJK.test(raw)) { console.warn('[user-notice] 提示语原文不是中文,已换成中文兜底句,原文:', raw) return fallback } // 中文主干 + 英文尾巴(后端把底层异常原文拼在冒号后):留主干,尾巴只进 console const at = Math.max(raw.lastIndexOf(':'), raw.lastIndexOf(':')) if (at > 0 && !CJK.test(raw.slice(at + 1))) { const head = raw.slice(0, at).trim() if (CJK.test(head)) { console.warn('[user-notice] 提示语尾巴是英文,已隐去,原文:', raw) return head } } return raw }