fix: friendly Chinese error messages on login/register pages

Map backend English error details to user-facing Chinese text on all
3 frontends (uni-app, user-frontend, admin-frontend). Previously raw
English like 'Invalid credentials' was shown directly to users.
This commit is contained in:
TradeMate Dev
2026-05-30 09:06:01 +08:00
parent 3e39cf0170
commit 4122571f86
4 changed files with 15 additions and 7 deletions
+4 -2
View File
@@ -172,7 +172,8 @@ async function submit() {
const redirect = route.query.redirect || '/workspace'
router.push(redirect)
} catch (e) {
error.value = e?.detail || '登录失败'
const map = { 'Invalid credentials': '手机号或密码错误', 'Invalid refresh token': '登录已过期,请重新登录', 'phone required': '请输入手机号' }
error.value = map[e?.detail] || e?.detail || '登录失败'
} finally {
loading.value = false
}
@@ -191,7 +192,8 @@ async function register() {
regForm.phone = ''
regForm.password = ''
} catch (e) {
regError.value = e?.detail || '注册失败'
const map = { 'Phone already registered': '该手机号已被注册', 'Invalid credentials': '手机号或密码错误' }
regError.value = map[e?.detail] || e?.detail || '注册失败'
} finally {
regLoading.value = false
}