|
|
@@ -10,11 +10,27 @@ definePageMeta({
|
|
|
})
|
|
|
|
|
|
const router = useRouter()
|
|
|
+const route = useRoute()
|
|
|
const { login, loginWithEmail, isAuthenticated } = useAuth()
|
|
|
const config = useRuntimeConfig()
|
|
|
|
|
|
const isTestEnv = computed(() => config.public.env === 'development')
|
|
|
|
|
|
+const redirectPath = computed(() => {
|
|
|
+ const redirect = route.query.redirect
|
|
|
+
|
|
|
+ if (!redirect || Array.isArray(redirect)) {
|
|
|
+ return '/'
|
|
|
+ }
|
|
|
+
|
|
|
+ // 避免跳转回登录页本身
|
|
|
+ if (typeof redirect === 'string' && redirect.startsWith('/login')) {
|
|
|
+ return '/'
|
|
|
+ }
|
|
|
+
|
|
|
+ return redirect as string
|
|
|
+})
|
|
|
+
|
|
|
const showTestLogin = ref(false)
|
|
|
const testEmail = ref('')
|
|
|
const testLoginLoading = ref(false)
|
|
|
@@ -23,7 +39,7 @@ const testLoginError = ref('')
|
|
|
onMounted(() => {
|
|
|
watch(isAuthenticated, (newIsAuthenticated) => {
|
|
|
if (newIsAuthenticated) {
|
|
|
- router.push('/')
|
|
|
+ router.replace(redirectPath.value)
|
|
|
}
|
|
|
})
|
|
|
})
|