fix: 🐛 修复玩家和管理员登录后刷新自动退出的bug优
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react';
|
||||
import { Layout, Menu, Button, theme } from 'antd';
|
||||
import { Layout, Menu, Button, theme, App } from 'antd';
|
||||
import {
|
||||
MenuFoldOutlined,
|
||||
MenuUnfoldOutlined,
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
import { Outlet, useNavigate, useLocation } from 'react-router-dom';
|
||||
import { useAuthStore } from '../stores/authStore';
|
||||
import { adminAuthService } from '../services/adminAuthService';
|
||||
import { message } from 'antd';
|
||||
|
||||
const { Header, Sider, Content, Footer } = Layout;
|
||||
|
||||
@@ -23,11 +22,11 @@ const AdminLayout = () => {
|
||||
const location = useLocation();
|
||||
const adminUser = useAuthStore((state) => state.adminUser);
|
||||
const logout = useAuthStore((state) => state.logout);
|
||||
const { message } = App.useApp();
|
||||
|
||||
const handleLogout = async () => {
|
||||
try {
|
||||
await adminAuthService.logout();
|
||||
localStorage.removeItem('adminToken');
|
||||
logout();
|
||||
message.success('登出成功');
|
||||
navigate('/admin/login');
|
||||
|
||||
Reference in New Issue
Block a user