hookehuyr

refactor(auth): 临时修改登录逻辑以支持任意输入

为了在开发阶段方便测试,暂时将登录逻辑修改为支持任意输入并模拟用户数据。此更改不影响生产环境,仅为临时解决方案。
......@@ -127,6 +127,40 @@ const password = ref('password123')
const error = ref('')
const loading = ref(false)
// 原登录逻辑
// const handleSubmit = async () => {
// if (!email.value || !password.value) {
// error.value = '请填写所有字段'
// return
// }
// try {
// error.value = ''
// loading.value = true
// // 调用登录接口
// const response = await loginAPI({
// email: email.value,
// password: password.value
// })
// if (response.code !== 1) {
// error.value = response.msg || '登录失败,请检查您的凭据'
// return
// }
// // 登录成功,更新auth状态
// const success = login(response.data)
// if (success) {
// // 如果有重定向参数,登录成功后跳转到对应页面
// const redirect = $route.query.redirect
// router.push(redirect || '/')
// } else {
// error.value = '登录失败,请检查您的凭据'
// }
// 临时登录逻辑 - 支持任意输入
const handleSubmit = async () => {
if (!email.value || !password.value) {
error.value = '请填写所有字段'
......@@ -137,22 +171,20 @@ const handleSubmit = async () => {
error.value = ''
loading.value = true
// 调用登录接口
const response = await loginAPI({
// 构造默认用户数据
const mockUserData = {
id: 1,
name: '测试用户',
email: email.value,
password: password.value
})
if (response.code !== 1) {
error.value = response.msg || '登录失败,请检查您的凭据'
return
avatar: 'https://cdn.ipadbiz.cn/mlaj/images/user-avatar-2.jpg',
checkInDays: 3,
completedCourses: 12
}
// 登录成功,更新auth状态
const success = login(response.data)
// 模拟登录成功
const success = login(mockUserData)
if (success) {
// 如果有重定向参数,登录成功后跳转到对应页面
const redirect = $route.query.redirect
router.push(redirect || '/')
} else {
......