dev #3

Merged
jingrow merged 96 commits from dev into main 2026-01-13 22:47:33 +08:00
2 changed files with 44 additions and 23 deletions
Showing only changes of commit 51a8654248 - Show all commits

View File

@ -82,7 +82,7 @@ const authStore = useAuthStore()
const formRef = ref()
const loading = ref(false)
const showSignupLink = ref(false)
const showSignupLink = ref(true)
const formData = reactive({
username: '',

View File

@ -212,35 +212,56 @@ const rules = computed(() => {
return rules
})
const getReferrerIfAny = () => {
try {
return document.referrer || ''
} catch {
return ''
}
}
const handleSignup = async () => {
try {
await formRef.value?.validate()
loading.value = true
message.error(t('注册功能已移除'))
return
const response = await fetch('/api/action/jcloud.api.account.signup_with_username', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
credentials: 'include',
body: JSON.stringify({
username: formData.username,
password: formData.password,
email: formData.email || null,
phone_number: isEnglish.value ? (formData.phoneNumber || null) : formData.phoneNumber || null,
referrer: getReferrerIfAny(),
product: router.currentRoute.value.query.product || null
})
})
if (!response.ok) {
const errorData = await response.json().catch(() => ({}))
const errorMessage = errorData?.messages?.length
? errorData.messages.join('\n')
: (errorData?.message || errorData?.exc || '注册失败,请检查您的信息')
throw new Error(errorMessage)
}
const data = await response.json()
if (result.success) {
message.success(t('Sign up successful'))
if (result.user) {
authStore.user = result.user
// cookie
localStorage.setItem('jingrow_user', JSON.stringify(result.user))
localStorage.setItem('jingrow_authenticated', 'true')
router.push('/')
} else {
const loginResult = await authStore.login(formData.username, formData.password)
if (loginResult.success) {
router.push('/')
} else {
message.warning(loginResult.error || t('注册成功,但自动登录失败,请手动登录'))
router.push('/login')
}
}
if (data && data.success === false) {
throw new Error(data.message || '注册失败,请检查您的信息')
}
localStorage.setItem('login_email', formData.username || formData.email)
if (data && data.dashboard_route) {
window.location.href = data.dashboard_route
} else {
const errorMsg = result.error || t('Sign up failed')
console.error('注册失败:', errorMsg, result)
message.error(errorMsg)
window.location.href = '/'
}
} catch (error: any) {
console.error('注册异常:', error)