import {useEffect, useState} from "react";
import {ROUTE_PATH} from "@constants/routes";
import {useLocation} from "react-router-dom";

const useAuthLockRoute=()=>{
    const location = useLocation();
    const [lockPath, setLockPath] = useState("");
    //如果不是登录和注册则清除
    const unLockRoute=(path,force=false)=>{
        if (!force&&(path==ROUTE_PATH.SIGN_IN||path==ROUTE_PATH.SIGN_UP)){
            return;
        }
        setLockPath("");
    }
    const lockRoute=(path)=>{
        setLockPath(path);
    }
    useEffect(() => {
        return () => {

        }
    }, [location]);
    return {
        lockPath,
        // setLockPath,
        lockRoute,
        unLockRoute
    }
}
export default useAuthLockRoute;
