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"> <script setup lang="ts">
import { useI18n } from 'vue-i18n'
import { isValidUsername } from '../../../packages/utils' import { isValidUsername } from '../../../packages/utils'
import AuthForm from '../components/AuthForm.vue' import AuthForm from '../components/AuthForm.vue'
import DynamicBackground from '../components/DynamicBackground.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 { TooManyRequestsError, ValidationError } from '../utils/errors'
import { checkUsername, chooseUsername } from '../utils/auth' import { checkUsername, chooseUsername } from '../utils/auth'
const { t } = useI18n()
async function check({ async function check({
username, username,
error, error,
@@ -16,21 +19,21 @@ async function check({
}) { }) {
if (username) { if (username) {
if (!isValidUsername(username)) { if (!isValidUsername(username)) {
error('無效的帳號名稱') error(t('authform_error.invalid_username'))
return return
} }
try { try {
await checkUsername(username) await checkUsername(username)
} catch (err) { } catch (err) {
if (err instanceof TooManyRequestsError) { if (err instanceof TooManyRequestsError) {
error('太多請求,兩分鐘後再試一次。') error(t('authform_error.too_many_requests'))
return return
} }
if (err instanceof ValidationError) { if (err instanceof ValidationError) {
error(err.message) error(err.message)
return return
} }
error('出了點問題,請再試一次。') error(t('authform_error.auth_failed'))
} }
} }
} }
@@ -50,7 +53,7 @@ async function handleSubmit({
success() success()
} catch (err: any) { } catch (err: any) {
if (err instanceof TooManyRequestsError) { if (err instanceof TooManyRequestsError) {
error('太多請求,兩分鐘後再試一次。') error(t('authform_error.too_many_requests'))
return return
} }
if (err instanceof ValidationError) { if (err instanceof ValidationError) {