This commit is contained in:
2026-08-13 11:50:50 +08:00
parent 2aa737edaa
commit b4b629a497
3 changed files with 122 additions and 137 deletions
@@ -1,5 +1,5 @@
import React, { useEffect, useState, useCallback, useRef } from 'react';
import { Layout, Avatar, Dropdown, Space, Modal, Form, Input, message, notification, Tag, Button, Typography, Radio, Drawer, Tabs, Progress, Collapse, ConfigProvider } from 'antd';
import { Layout, Avatar, Dropdown, Space, Modal, Form, Input, message, Tag, Button, Typography, Radio, Drawer, Tabs, Progress, Collapse, ConfigProvider } from 'antd';
import { QRCodeSVG } from 'qrcode.react';
import {
PlayCircleOutlined,
@@ -515,27 +515,12 @@ const AppLayout: React.FC = () => {
const [isMobile, setIsMobile] = useState(false);
const [operationManualUrl, setOperationManualUrl] = useState('');
// 监听"被踢出"事件 — 单设备登录互斥,显示顶部通知
// 监听"被踢出"事件 — 单设备登录互斥,显示顶部消息并跳转登录
useEffect(() => {
const handleKickedOut = () => {
notification.warning({
message: '登录提示',
description: '您的账号已在其他设备登录,请重新登录',
placement: 'top',
duration: 0, // 不自动关闭
btn: (
<Button
type="primary"
size="small"
onClick={() => {
localStorage.removeItem('token');
navigate('/login');
}}
>
</Button>
),
});
message.warning('您的账号已在其他设备登录,请重新登录');
localStorage.removeItem('token');
navigate('/login');
};
window.addEventListener('kicked-out', handleKickedOut);
return () => window.removeEventListener('kicked-out', handleKickedOut);