|
@@ -2,6 +2,7 @@
|
|
|
import ButtonOwn from "@/components/ButtonOwn";
|
|
|
import { Link, useRouter } from "@/i18n";
|
|
|
import { useGlobalStore } from "@/stores";
|
|
|
+import { setCookies } from "@/utils/Cookies";
|
|
|
import { Toast } from "antd-mobile";
|
|
|
import clsx from "clsx";
|
|
|
import { useTranslations } from "next-intl";
|
|
@@ -40,7 +41,7 @@ const FromCom: FC<PropsWithChildren<FromComProps>> = ({ type = "login", msgError
|
|
|
let [pwdVisible, setPwdVisible] = useState(false);
|
|
|
const searchParams = useSearchParams();
|
|
|
const router = useRouter();
|
|
|
- const { setUserInfo, setToken } = useGlobalStore();
|
|
|
+ const { setUserInfo } = useGlobalStore();
|
|
|
const [loginFormStatus, setLoginFormStatus] = useState<{ success?: boolean; message?: string }>(
|
|
|
{}
|
|
|
);
|
|
@@ -48,10 +49,8 @@ const FromCom: FC<PropsWithChildren<FromComProps>> = ({ type = "login", msgError
|
|
|
const formAction = async (formData: FormData) => {
|
|
|
Toast.show({ icon: "loading", duration: 3000, maskClickable: false });
|
|
|
const result = await loginAction(formData);
|
|
|
- // todo token存放位置在本地, 优化目标: 要做服务端渲染应该获取cookie里面的token
|
|
|
setUserInfo(result.user);
|
|
|
- setToken(result.token!);
|
|
|
- console.log(`🚀🚀🚀🚀🚀-> in index.tsx on 54`, result);
|
|
|
+ setCookies("Token", result.token!);
|
|
|
setLoginFormStatus(result);
|
|
|
Toast.clear();
|
|
|
if (result.success) {
|