feat: add translation for ChooseUsernamePage

This commit is contained in:
neilchen0812 committed 2026-10-10 00:30:02 +10:30
1 parent 54f73504ec
commit 85dda9486e
1 file changed
+7 -4
+7 -4
View File
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import { isValidUsername } from '../../../packages/utils'
import AuthForm from '../components/AuthForm.vue'
import DynamicBackground from '../components/DynamicBackground.vue'
@@ -6,6 +7,8 @@ import HeaderPart from '../components/header/HeaderPart.vue'
import { TooManyRequestsError, ValidationError } from '../utils/errors'
import { checkUsername, chooseUsername } from '../utils/auth'
const { t } = useI18n()
async function check({
username,
error,
@@ -16,21 +19,21 @@ async function check({
}) {
if (username) {
if (!isValidUsername(username)) {
error('無效的帳號名稱')
error(t('authform_error.invalid_username'))
return
}
try {
await checkUsername(username)
} catch (err) {
if (err instanceof TooManyRequestsError) {
error('太多請求,兩分鐘後再試一次。')
error(t('authform_error.too_many_requests'))
return
}
if (err instanceof ValidationError) {
error(err.message)
return
}
error('出了點問題,請再試一次。')
error(t('authform_error.auth_failed'))
}
}
}
@@ -50,7 +53,7 @@ async function handleSubmit({
success()
} catch (err: any) {
if (err instanceof TooManyRequestsError) {
error('太多請求,兩分鐘後再試一次。')
error(t('authform_error.too_many_requests'))
return
}
if (err instanceof ValidationError) {