mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
feat: add translation for ChooseUsernamePage
This commit is contained in:
1 parent
54f73504ec
commit
85dda9486e
1 file changed
+7
-4
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user