fix: 🐛 修复玩家和管理员登录后刷新自动退出的bug优

This commit is contained in:
Stev_Wang
2025-12-27 21:12:05 +08:00
parent 598cd3026b
commit cb5088115a
11 changed files with 195 additions and 86 deletions

View File

@@ -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');