添加依赖管理

This commit is contained in:
whyour
2021-10-24 17:07:06 +08:00
parent bd8953ea81
commit 0c2a2af308
12 changed files with 270 additions and 159 deletions
+2 -1
View File
@@ -7,6 +7,7 @@ import {
FolderOutlined,
RadiusSettingOutlined,
ControlOutlined,
ContainerOutlined,
} from '@ant-design/icons';
export default {
@@ -51,7 +52,7 @@ export default {
{
path: '/dependence',
name: '依赖管理',
icon: <FormOutlined />,
icon: <ContainerOutlined />,
component: '@/pages/dependence/index',
},
{
+11 -6
View File
@@ -26,6 +26,7 @@ export default function (props: any) {
const [loading, setLoading] = useState<boolean>(true);
const [systemInfo, setSystemInfo] = useState<{ isInitialized: boolean }>();
const ws = useRef<any>(null);
const [socketMessage, setSocketMessage] = useState<any>();
const logout = () => {
request.post(`${config.apiPrefix}logout`).then(() => {
@@ -124,6 +125,7 @@ export default function (props: any) {
}, []);
useEffect(() => {
if (!user) return;
ws.current = new SockJS(
`${location.origin}/api/ws?token=${localStorage.getItem(config.authKey)}`,
);
@@ -131,11 +133,14 @@ export default function (props: any) {
ws.current.onmessage = (e: any) => {
try {
const data = JSON.parse(e.data);
if (data && data.message === 'hanhh') {
console.log('websocket连接成功', e);
} else {
console.log('websocket连接失败', e);
if (data.type === 'ping') {
if (data && data.message === 'hanhh') {
console.log('websocket连接成功', e);
} else {
console.log('websocket连接失败', e);
}
}
setSocketMessage(data);
} catch (error) {
console.log('websocket连接失败', e);
}
@@ -146,7 +151,7 @@ export default function (props: any) {
return () => {
wsCurrent.close();
};
}, []);
}, [user]);
if (['/login', '/initialization'].includes(props.location.pathname)) {
document.title = `${
@@ -246,7 +251,7 @@ export default function (props: any) {
user,
reloadUser,
reloadTheme: setTheme,
ws: ws.current,
socketMessage,
});
})}
</ProLayout>