|
@@ -10,7 +10,7 @@
|
|
|
<script lang="ts" setup>
|
|
|
import { t } from '@/locale'
|
|
|
import { useUserStore } from '@/store/user'
|
|
|
-import { goBack, toPage } from '@/utils/page'
|
|
|
+import { getPageParams, goBack, toPage } from '@/utils/page'
|
|
|
import { toast } from '@/utils/toast'
|
|
|
|
|
|
defineOptions({
|
|
@@ -24,6 +24,8 @@ const safeAreaInsets = systemInfo.safeAreaInsets
|
|
|
// 用户状态管理
|
|
|
const userStore = useUserStore()
|
|
|
|
|
|
+const redirectUrl = ref<string | null>(null)
|
|
|
+
|
|
|
// 表单数据
|
|
|
const formData = ref({
|
|
|
username: '',
|
|
@@ -72,19 +74,18 @@ async function handleLogin() {
|
|
|
pwd: formData.value.password,
|
|
|
}
|
|
|
|
|
|
- // 获取页面参数中的跳转地址(如果有的话)
|
|
|
- const pages = getCurrentPages()
|
|
|
- const currentPage = pages[pages.length - 1] as any
|
|
|
- const redirectUrl = currentPage?.options?.redirect
|
|
|
-
|
|
|
// 调用 userStore 中的登录方法,传入跳转地址
|
|
|
- await userStore.login(loginData, redirectUrl)
|
|
|
+ await userStore.login(loginData, redirectUrl.value)
|
|
|
}
|
|
|
catch (error) {
|
|
|
// 错误处理已在 userStore.login 中处理
|
|
|
console.error('Login error:', error)
|
|
|
}
|
|
|
}
|
|
|
+onLoad((options) => {
|
|
|
+ const params = getPageParams(options)
|
|
|
+ redirectUrl.value = params.redirect || null
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<template>
|