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) => { ...@@ -15,3 +15,7 @@ export const setCookie = <T>(key: CookieKeys, value: T) => {
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 60), // 两个月的cookie,应该很充裕 expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 60), // 两个月的cookie,应该很充裕
}); });
}; };
export const removeCookie = (key: CookieKeys) => {
cookies.remove(key);
};
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
} from "react-router-dom"; } from "react-router-dom";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
import { CookieKeys, removeCookie } from "@/api";
import { useConfig } from "@/config"; import { useConfig } from "@/config";
import { accountStore } from "@/stores"; import { accountStore } from "@/stores";
...@@ -25,11 +26,11 @@ import { ...@@ -25,11 +26,11 @@ import {
const NeosConfig = useConfig(); const NeosConfig = useConfig();
export const loader: LoaderFunction = async () => { export const loader: LoaderFunction = async () => {
await getLoginStatus(); getLoginStatus();
await initDeck(); initDeck();
await initSqlite(); initSqlite();
await initWASM(); initWASM();
await initForbidden(); initForbidden();
return null; return null;
}; };
...@@ -112,6 +113,13 @@ export const Component = () => { ...@@ -112,6 +113,13 @@ export const Component = () => {
</a> </a>
), ),
}, },
{
label: "退出登录",
onClick: () => {
removeCookie(CookieKeys.USER);
accountStore.logout();
},
},
].map((x, key) => ({ ...x, key })), ].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