video curcse
All checks were successful
Deploy to Server / deploy (push) Successful in 37s

This commit is contained in:
jeremygan2021
2026-02-27 14:30:56 +08:00
parent 9123b929fd
commit a58fc40e10
4 changed files with 22 additions and 19 deletions

View File

@@ -7,6 +7,7 @@ const AuthContext = createContext(null);
export const AuthProvider = ({ children }) => {
const [user, setUser] = useState(null);
const [loading, setLoading] = useState(true);
const [loginModalVisible, setLoginModalVisible] = useState(false);
useEffect(() => {
const initAuth = async () => {
@@ -71,8 +72,11 @@ export const AuthProvider = ({ children }) => {
localStorage.setItem('user', JSON.stringify(newUser));
};
const showLoginModal = () => setLoginModalVisible(true);
const hideLoginModal = () => setLoginModalVisible(false);
return (
<AuthContext.Provider value={{ user, login, logout, updateUser, loading }}>
<AuthContext.Provider value={{ user, login, logout, updateUser, loading, loginModalVisible, showLoginModal, hideLoginModal }}>
{children}
</AuthContext.Provider>
);