- 新建一级代理改为选择已有玩家;新建用户可选一级代理 - 操作日志/注单等扁平 key 翻译;清理 src 内误生成 .js,Vite 优先解析 .ts Co-authored-by: Cursor <cursoragent@cursor.com>
17 lines
496 B
TypeScript
17 lines
496 B
TypeScript
/** 表单校验错误(key 对应 vue-i18n 文案) */
|
||
export class FormValidationError extends Error {
|
||
readonly key: string;
|
||
|
||
constructor(key: string) {
|
||
super(key);
|
||
this.name = 'FormValidationError';
|
||
this.key = key;
|
||
}
|
||
}
|
||
|
||
export function resolveFormError(e: unknown, t: (key: string) => string): string {
|
||
if (e instanceof FormValidationError) return t(e.key);
|
||
if (e instanceof Error && e.message.startsWith('err.')) return t(e.message);
|
||
return t('msg.form_invalid');
|
||
}
|