Skip to content

Commit

Permalink
feat:退出登录提示弹窗
Browse files Browse the repository at this point in the history
  • Loading branch information
QwQ-wuwuwu committed Jul 2, 2024
1 parent 60806ad commit af13470
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/frontend/src/layout/MainLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { userContext } from "../contexts/userContext";
import { logoutApi } from "../controllers/API/user";
import { captureAndAlertRequestErrorHoc } from "../controllers/request";
import { User } from "../types/api/user";
import { bsConfirm } from "@/components/bs-ui/alertDialog/useConfirm";

export default function MainLayout() {
const { dark, setDark } = useContext(darkContext);
Expand All @@ -38,9 +39,17 @@ export default function MainLayout() {
const { language, options, changLanguage, t } = useLanguage(user)

const handleLogout = () => {
captureAndAlertRequestErrorHoc(logoutApi()).then(_ => {
setUser(null)
localStorage.removeItem('isLogin')
bsConfirm({
title: `${t('prompt')}!`,
desc: `${t('menu.logoutDescription')}?`,
okTxt: t('system.confirm'),
onOk(next) {
captureAndAlertRequestErrorHoc(logoutApi()).then(_ => {
setUser(null)
localStorage.removeItem('isLogin')
})
next()
}
})
}

Expand Down

0 comments on commit af13470

Please sign in to comment.