|
|
@@ -1,4 +1,4 @@
|
|
|
-import React, { useState } from 'react'
|
|
|
+import React, { useState, useEffect } from 'react'
|
|
|
import { View, Text, Input, Button } from '@tarojs/components'
|
|
|
import { useAuth } from '../../hooks'
|
|
|
import { Navbar } from '@d8d/mini-shared-ui-components/components/navbar'
|
|
|
@@ -13,7 +13,14 @@ export const LoginPage: React.FC = () => {
|
|
|
const [identifier, setIdentifier] = useState('')
|
|
|
const [password, setPassword] = useState('')
|
|
|
const [loading, setLoading] = useState(false)
|
|
|
- const { login } = useAuth()
|
|
|
+ const { login, isLoggedIn } = useAuth()
|
|
|
+
|
|
|
+ // 如果已登录,直接跳转到首页
|
|
|
+ useEffect(() => {
|
|
|
+ if (isLoggedIn) {
|
|
|
+ Taro.switchTab({ url: '/pages/index/index' })
|
|
|
+ }
|
|
|
+ }, [isLoggedIn])
|
|
|
|
|
|
const handleLogin = async () => {
|
|
|
// 表单验证
|