优化菜单和登录按钮

This commit is contained in:
dushixiang 2021-01-21 22:15:23 +08:00
parent cdbb7b567a
commit ba982dacd0
3 changed files with 49 additions and 33 deletions

View File

@ -36,7 +36,7 @@ import request from "./common/request";
import {message} from "antd/es";
import Setting from "./components/setting/Setting";
import BatchCommand from "./components/command/BatchCommand";
import {NT_PACKAGE} from "./utils/utils";
import {isEmpty, NT_PACKAGE} from "./utils/utils";
import {isAdmin} from "./service/permission";
import UserGroup from "./components/user/UserGroup";
import LoginLog from "./components/session/LoginLog";
@ -64,16 +64,17 @@ class App extends Component {
};
componentDidMount() {
this.getInfo().then(r => {
});
let hash = window.location.hash;
let current = hash.replace('#/', '');
if(isEmpty(current)){
current = 'dashboard';
}
this.setCurrent(current);
this.getInfo();
}
async getInfo() {
if ('/login' === window.location.pathname) {
return;
}
let result = await request.get('/info');
if (result['code'] === 1) {
this.setState({
@ -151,7 +152,7 @@ class App extends Component {
资产列表
</Link>
</Menu.Item>
<Menu.Item key="idcard" icon={<IdcardOutlined/>}>
<Menu.Item key="credential" icon={<IdcardOutlined/>}>
<Link to={'/credential'}>
授权凭证
</Link>

View File

@ -1,19 +1,19 @@
// prod
// let wsPrefix;
// if (window.location.protocol === 'https:') {
// wsPrefix = 'wss:'
// } else {
// wsPrefix = 'ws:'
// }
//
// export const server = '';
// export const wsServer = wsPrefix + window.location.host;
// export const prefix = window.location.protocol + '//' + window.location.host;
let wsPrefix;
if (window.location.protocol === 'https:') {
wsPrefix = 'wss:'
} else {
wsPrefix = 'ws:'
}
export const server = '';
export const wsServer = wsPrefix + window.location.host;
export const prefix = window.location.protocol + '//' + window.location.host;
// dev
export const server = '//127.0.0.1:8088';
export const wsServer = 'ws://127.0.0.1:8088';
export const prefix = '';
// export const server = '//127.0.0.1:8088';
// export const wsServer = 'ws://127.0.0.1:8088';
// export const prefix = '';
export const PROTOCOL_COLORS = {
'rdp': 'red',

View File

@ -1,6 +1,7 @@
import React, {Component} from 'react';
import {Button, message, Popconfirm} from "antd";
import {Button, Dropdown, Menu, message, Popconfirm} from "antd";
import request from "../../common/request";
import {getCurrentUser} from "../../service/permission";
class Logout extends Component {
@ -14,9 +15,14 @@ class Logout extends Component {
}
}
render() {
return (
<div>
const menu = (
<Menu>
<Menu.Item>
<Popconfirm
key='login-btn-pop'
title="您确定要退出登录吗?"
@ -25,11 +31,20 @@ class Logout extends Component {
cancelText="取消"
placement="left"
>
<Button key="login-btn" type="dashed">
退出登录
</Button>
</Popconfirm>
</Menu.Item>
</Menu>
);
return (
<div>
<Dropdown overlay={menu}>
<Button key="login-btn" type="dashed">
{getCurrentUser()['nickname']}
</Button>
</Dropdown>
</div>
);
}