Skip to content

Commit

Permalink
fix: Fixed the issue of jumping to the dashboard before judging (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
GaoNeng-wWw authored Nov 24, 2023
1 parent 3103643 commit 648828d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/authenticate/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const Login = (
}
const CheckCode = (props: {type: 'email' | 'phone' | 'unknown', userInput: string}) => {
const {type} = props;
const [loading, setLoading] = useState(true);
const [loading, setLoading] = useState(false );
const [cd, setCD] = useState(1000)
const [time, setTime] = useCountDown(cd)
const getCode = () => {
Expand Down
8 changes: 6 additions & 2 deletions app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Uploader from "@/components/uploader";
import {Card, CardBody, CardFooter, Divider} from "@nextui-org/react";
import {Progress} from "@nextui-org/progress";
import {Button} from "@nextui-org/button";
import {useRouter} from "next/navigation";
import {redirect, useRouter} from "next/navigation";
import {Chip} from "@nextui-org/chip";
import {FiChevronsUp, FiUploadCloud} from "react-icons/fi";
import Picture from "@/components/picture";
Expand All @@ -15,10 +15,14 @@ import {getGroupPrice} from "@/config/prices";
import {PictureList} from "@/interface/model/picture";
import {SERVER_URL} from "@/interface/api";
import cookie from "react-cookies";
import {userInfo} from "os";
import {PriceInfo} from "@/components/price";
import { IsLoggedIn } from "@/interface/hooks";
import { RedirectType } from "next/dist/client/components/redirect";

export default function Page() {
if (!IsLoggedIn){
redirect('/authenticate', RedirectType.replace);
}
let [used, setUsed] = useState(0);
let [total, setTotal] = useState(1);

Expand Down
4 changes: 3 additions & 1 deletion app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export default function Home() {
<div className="flex gap-3">
<Link
as={NextLink}
href={IsLoggedIn ? "/pricing" : "/dashboard"}
href={IsLoggedIn ? "/dashboard" : "/authenticate"}
className={buttonStyles({color: "primary", variant: "shadow"})}
prefetch
>
<FaLocationArrow size={20}/>
开始使用
Expand All @@ -40,6 +41,7 @@ export default function Home() {
as={NextLink}
className={buttonStyles({variant: "bordered"})}
href={siteConfig.navItems[2].href}
prefetch
>
<HiOutlineNewspaper size={20}/>
日志
Expand Down
2 changes: 1 addition & 1 deletion app/providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function AuthProvider({children, whiteList}: AuthProvider) {
}
}, [pathName, whiteList])
if (!IsLoggedIn && !whiteList.includes(pathName)){
return null;
return <></>;
}
return (
<>
Expand Down
6 changes: 3 additions & 3 deletions components/password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import { useState } from "react";
export interface PasswordProps {
label: string;
placeholder: string;
key: string
value?: string;
onValueChange?: (val:string)=>void;
}

export default function Password(
props: PasswordProps
props: PasswordProps,
key: string
){
const {key, label, placeholder, value, onValueChange} = props
const {label, placeholder, value, onValueChange} = props
const [visible, setVisible] = useState(false);
const toggleVisible = () => setVisible(!visible);
const endContent = () => {
Expand Down

0 comments on commit 648828d

Please sign in to comment.