Commit 21903bc1 authored by Chunchi Che's avatar Chunchi Che

handle logout

parent ffb387c3
Pipeline #23217 passed with stages
in 11 minutes and 54 seconds
......@@ -15,3 +15,7 @@ export const setCookie = <T>(key: CookieKeys, value: T) => {
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 60), // 两个月的cookie,应该很充裕
});
};
export const removeCookie = (key: CookieKeys) => {
cookies.remove(key);
};
......@@ -9,6 +9,7 @@ import {
} from "react-router-dom";
import { useSnapshot } from "valtio";
import { CookieKeys, removeCookie } from "@/api";
import { useConfig } from "@/config";
import { accountStore } from "@/stores";
......@@ -25,11 +26,11 @@ import {
const NeosConfig = useConfig();
export const loader: LoaderFunction = async () => {
await getLoginStatus();
await initDeck();
await initSqlite();
await initWASM();
await initForbidden();
getLoginStatus();
initDeck();
initSqlite();
initWASM();
initForbidden();
return null;
};
......@@ -112,6 +113,13 @@ export const Component = () => {
</a>
),
},
{
label: "退出登录",
onClick: () => {
removeCookie(CookieKeys.USER);
accountStore.logout();
},
},
].map((x, key) => ({ ...x, key })),
}}
>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment