feat(auth): 注册真实化 + 注册/忘记密码默认隐藏
- register.vue 接入 POST /auth/register - defaultLoginConfig showRegister/showForgetPassword 默认 false Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
84edbc67c0
commit
23da579b26
@ -10,3 +10,14 @@ export function fetchMenus(): Promise<ResourceNode[]> {
|
||||
export function fetchPermissions(): Promise<{ super: boolean; permissions: string[] }> {
|
||||
return http.get<{ super: boolean; permissions: string[] }>('/auth/permissions')
|
||||
}
|
||||
|
||||
/** 注册账号。 */
|
||||
export function register(data: {
|
||||
tenantCode: string
|
||||
username: string
|
||||
password: string
|
||||
email?: string
|
||||
phone?: string
|
||||
}): Promise<{ id: string; username: string }> {
|
||||
return http.post<{ id: string; username: string }>('/auth/register', data)
|
||||
}
|
||||
|
||||
@ -56,8 +56,8 @@ export const defaultLoginConfig: LoginConfig = {
|
||||
required: ['username', 'password'],
|
||||
},
|
||||
showRemember: true,
|
||||
showForgetPassword: true,
|
||||
showRegister: true,
|
||||
showForgetPassword: false,
|
||||
showRegister: false,
|
||||
showCaptcha: true,
|
||||
homePath: '/',
|
||||
}
|
||||
|
||||
@ -60,6 +60,7 @@ import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
|
||||
import { useAppStore } from '@/stores/modules/app'
|
||||
import { defaultLoginConfig } from '@/config/login'
|
||||
import { applyTheme } from '@/utils/theme'
|
||||
import { register } from '@/api/auth'
|
||||
|
||||
const router = useRouter()
|
||||
const app = useAppStore()
|
||||
@ -102,11 +103,21 @@ async function onSubmit(): Promise<void> {
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
// mock:后端暂无注册接口,模拟耗时
|
||||
await new Promise((resolve) => setTimeout(resolve, 300))
|
||||
loading.value = false
|
||||
ElMessage.success('注册成功,请登录')
|
||||
router.push({ path: '/login', query: { username: model.username } })
|
||||
try {
|
||||
await register({
|
||||
tenantCode: config.tenantCode,
|
||||
username: model.username,
|
||||
password: model.password,
|
||||
email: model.email,
|
||||
phone: model.phone || undefined,
|
||||
})
|
||||
ElMessage.success('注册成功,请登录')
|
||||
router.push({ path: '/login', query: { username: model.username } })
|
||||
} catch (e) {
|
||||
ElMessage.error(e instanceof Error ? e.message : '注册失败')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user