This commit is contained in:
@@ -15,10 +15,9 @@ const Layout = ({ children }) => {
|
||||
const location = useLocation();
|
||||
const [searchParams] = useSearchParams();
|
||||
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
||||
const [loginVisible, setLoginVisible] = useState(false);
|
||||
const [profileVisible, setProfileVisible] = useState(false);
|
||||
|
||||
const { user, login, logout } = useAuth();
|
||||
const { user, login, logout, loginModalVisible, showLoginModal, hideLoginModal } = useAuth();
|
||||
|
||||
// 全局监听并持久化 ref 参数
|
||||
useEffect(() => {
|
||||
@@ -178,7 +177,7 @@ const Layout = ({ children }) => {
|
||||
</Dropdown>
|
||||
</div>
|
||||
) : (
|
||||
<Button type="primary" onClick={() => setLoginVisible(true)}>登录</Button>
|
||||
<Button type="primary" onClick={showLoginModal}>登录</Button>
|
||||
)}
|
||||
</div>
|
||||
<style>{`
|
||||
@@ -222,7 +221,7 @@ const Layout = ({ children }) => {
|
||||
<Button type="link" danger onClick={handleLogout} style={{ marginTop: 10 }}>退出登录</Button>
|
||||
</div>
|
||||
) : (
|
||||
<Button type="primary" block onClick={() => { setLoginVisible(true); setMobileMenuOpen(false); }}>登录 / 注册</Button>
|
||||
<Button type="primary" block onClick={() => { showLoginModal(); setMobileMenuOpen(false); }}>登录 / 注册</Button>
|
||||
)}
|
||||
</div>
|
||||
<Menu
|
||||
@@ -236,8 +235,8 @@ const Layout = ({ children }) => {
|
||||
</Drawer>
|
||||
|
||||
<LoginModal
|
||||
visible={loginVisible}
|
||||
onClose={() => setLoginVisible(false)}
|
||||
visible={loginModalVisible}
|
||||
onClose={hideLoginModal}
|
||||
onLoginSuccess={(userData) => login(userData)}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user