优化菜单和登录按钮

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

View File

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

View File

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