feat(admin): align frontend with updated API contracts
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { NAlert, NButton, NCard, NForm, NFormItem, NInput, NResult } from 'naive-ui'
|
||||
import { ApiError } from '@/lib/api'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
|
||||
const authStore = useAuthStore()
|
||||
@@ -15,13 +16,12 @@ const error = ref('')
|
||||
const loading = ref(false)
|
||||
const registered = ref(false)
|
||||
const emailDelivered = ref(true)
|
||||
|
||||
const canResend = computed(() =>
|
||||
error.value.includes('重发验证') || error.value.includes('已被注册,请使用重发'),
|
||||
)
|
||||
const registerConflict = ref(false)
|
||||
const canResend = computed(() => registerConflict.value)
|
||||
|
||||
async function handleRegister() {
|
||||
error.value = ''
|
||||
registerConflict.value = false
|
||||
const trimmedName = name.value.trim()
|
||||
const trimmedEmail = email.value.trim()
|
||||
|
||||
@@ -53,7 +53,12 @@ async function handleRegister() {
|
||||
emailDelivered.value = response.email_sent
|
||||
registered.value = true
|
||||
} catch (e: unknown) {
|
||||
error.value = e instanceof Error ? e.message : '注册失败,请稍后重试'
|
||||
if (e instanceof ApiError && e.status === 409) {
|
||||
registerConflict.value = true
|
||||
error.value = '邮箱或用户名已被占用;若邮箱尚未验证,可以尝试重发验证邮件。'
|
||||
} else {
|
||||
error.value = e instanceof Error ? e.message : '注册失败,请稍后重试'
|
||||
}
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user