|
@@ -2,7 +2,10 @@
|
|
|
import { getLogoutApi } from "@/api/user";
|
|
|
import { useRouter } from "@/i18n";
|
|
|
import { useGlobalStore } from "@/stores";
|
|
|
+import { useSearchStore } from "@/stores/useSearchStore";
|
|
|
+import { useWalletStore } from "@/stores/useWalletStore";
|
|
|
import { CenterPopup } from "antd-mobile";
|
|
|
+import Cookies from "js-cookie";
|
|
|
import { useTranslations } from "next-intl";
|
|
|
import { FC, PropsWithChildren, useState } from "react";
|
|
|
import "./style.scss";
|
|
@@ -17,14 +20,21 @@ export interface ItemComProps {
|
|
|
|
|
|
const ModalCom: FC<PropsWithChildren<ItemComProps>> = () => {
|
|
|
const t = useTranslations("ProfilePage");
|
|
|
- const { token, setToken, setUserInfo } = useGlobalStore();
|
|
|
+ const restGlobal = useGlobalStore((state) => state.reset);
|
|
|
+ const resetSearch = useSearchStore((state) => state.reset);
|
|
|
+ const restWalletStore = useWalletStore((state) => state.reset);
|
|
|
+
|
|
|
// const { isOpen, onOpen, onClose, onOpenChange } = useDisclosure();
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
const logoutRequest = async () => {
|
|
|
let res = await getLogoutApi();
|
|
|
if (res.code == 200) {
|
|
|
- setUserInfo("");
|
|
|
- setToken("");
|
|
|
+ restGlobal();
|
|
|
+ resetSearch();
|
|
|
+ restWalletStore();
|
|
|
+ localStorage.clear();
|
|
|
+ sessionStorage.clear();
|
|
|
+ Cookies.remove("Token");
|
|
|
router.replace("/login");
|
|
|
}
|
|
|
};
|