diff --git a/web/src/App.css b/web/src/App.css index 9443a7f..59ae085 100644 --- a/web/src/App.css +++ b/web/src/App.css @@ -33,7 +33,7 @@ } .layout-header { - height: 48px; + height: 60px; align-items: center; padding: 0 16px 0 0; background: #fff; @@ -45,23 +45,19 @@ padding: 0 12px; cursor: pointer; transition: all .3s; - line-height: 48px; - height: 48px; + line-height: 60px; + height: 60px; } .layout-header-right-item { margin: 0 6px; display: inline; - height: 48px; -} - -.layout-header-right-item:hover { - background-color: #eeeeee; + height: 60px; } .nickname { - line-height: 48px; - height: 48px; + line-height: 60px; + height: 60px; width: 125px; text-align: left; padding: 0 5px; diff --git a/web/src/App.js b/web/src/App.js index 0868860..8a7f90b 100644 --- a/web/src/App.js +++ b/web/src/App.js @@ -1,7 +1,7 @@ import React, {Component} from 'react'; import 'antd/dist/antd.css'; import './App.css'; -import {Divider, Layout, Menu} from "antd"; +import {Col, Divider, Dropdown, Layout, Menu, Popconfirm, Row, Tooltip} from "antd"; import {Link, Route, Switch} from "react-router-dom"; import Dashboard from "./components/dashboard/Dashboard"; import Asset from "./components/asset/Asset"; @@ -21,15 +21,21 @@ import { DashboardOutlined, DesktopOutlined, DisconnectOutlined, + DownOutlined, + GithubOutlined, IdcardOutlined, LinkOutlined, LoginOutlined, + LogoutOutlined, + QuestionCircleOutlined, SafetyCertificateOutlined, SettingOutlined, SolutionOutlined, TeamOutlined, UserOutlined, - UserSwitchOutlined + UserSwitchOutlined, + MenuUnfoldOutlined, + MenuFoldOutlined, } from '@ant-design/icons'; import Info from "./components/user/Info"; import request from "./common/request"; @@ -37,18 +43,18 @@ import {message} from "antd/es"; import Setting from "./components/setting/Setting"; import BatchCommand from "./components/command/BatchCommand"; import {isEmpty, NT_PACKAGE} from "./utils/utils"; -import {isAdmin} from "./service/permission"; +import {getCurrentUser, isAdmin} from "./service/permission"; import UserGroup from "./components/user/UserGroup"; import LoginLog from "./components/devops/LoginLog"; import Term from "./components/access/Term"; import Job from "./components/devops/Job"; import {Header} from "antd/es/layout/layout"; -import LayoutHeader from "./components/user/LayoutHeader"; import Security from "./components/devops/Security"; const {Footer, Sider} = Layout; const {SubMenu} = Menu; +const headerHeight = 60; class App extends Component { @@ -113,8 +119,54 @@ class App extends Component { sessionStorage.setItem('openKeys', JSON.stringify(openKeys)); } + confirm = async (e) => { + let result = await request.post('/logout'); + if (result['code'] !== 1) { + message.error(result['message']); + } else { + message.success('退出登录成功,即将跳转至登录页面。'); + window.location.reload(); + } + } + render() { + const menu = ( + + + + + + 个人中心 + + + + + + + 点个Star + + + + + + + + + + 退出登录 + + + + + ); return ( @@ -126,7 +178,7 @@ class App extends Component { - +
logo { @@ -251,8 +303,38 @@ class App extends Component {
- + style={{padding: 0, height: headerHeight, zIndex: 20}}> +
+ + + {React.createElement(this.state.collapsed ? MenuUnfoldOutlined : MenuFoldOutlined, { + className: 'trigger', + onClick: this.onCollapse, + })} + + + +
+ + + + + + +
+ + + +
+ {getCurrentUser()['nickname']}   +
+
+ +
+ +
diff --git a/web/src/components/Login.js b/web/src/components/Login.js index 49db17c..351b442 100644 --- a/web/src/components/Login.js +++ b/web/src/components/Login.js @@ -10,7 +10,8 @@ const {Title} = Typography; class LoginForm extends Component { - formRef = React.createRef() + formRef = React.createRef(); + totpInputRef = React.createRef(); state = { inLogin: false, @@ -44,6 +45,8 @@ class LoginForm extends Component { loginAccount: params, totpModalVisible: true }) + + this.totpInputRef.current.focus(); return; } if (result.code !== 1) { @@ -74,8 +77,9 @@ class LoginForm extends Component { try { let result = await request.post('/loginWithTotp', loginAccount); - if (result.code !== 1) { - throw new Error(result.message); + if (result['code'] !== 1) { + message.error(result['message']); + return; } // 跳转登录 @@ -129,12 +133,13 @@ class LoginForm extends Component { { this.formRef.current .validateFields() .then(values => { - this.formRef.current.resetFields(); this.handleOk(values); + // this.formRef.current.resetFields(); }) .catch(info => { @@ -142,10 +147,10 @@ class LoginForm extends Component { }} onCancel={this.handleCancel}> -
+ - } placeholder="请输入双因素认证APP中显示的授权码"/> + } placeholder="请输入双因素认证APP中显示的授权码"/>
diff --git a/web/src/components/asset/Asset.js b/web/src/components/asset/Asset.js index 8786549..fb1e328 100644 --- a/web/src/components/asset/Asset.js +++ b/web/src/components/asset/Asset.js @@ -51,19 +51,6 @@ const confirm = Modal.confirm; const {Search} = Input; const {Content} = Layout; const {Title, Text} = Typography; -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - breadcrumbName: '资源管理', - }, - { - path: 'assets', - breadcrumbName: '资产管理', - } -]; class Asset extends Component { @@ -660,18 +647,6 @@ class Asset extends Component { return ( <> - - -
diff --git a/web/src/components/command/DynamicCommand.js b/web/src/components/command/DynamicCommand.js index 8e7f1c1..5dcfe67 100644 --- a/web/src/components/command/DynamicCommand.js +++ b/web/src/components/command/DynamicCommand.js @@ -43,16 +43,6 @@ const {Content} = Layout; const {Title, Text} = Typography; const {Search} = Input; const CheckboxGroup = Checkbox.Group; -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - path: 'command', - breadcrumbName: '动态指令', - } -]; class DynamicCommand extends Component { @@ -534,18 +524,6 @@ class DynamicCommand extends Component { return ( <> - - -
diff --git a/web/src/components/credential/Credential.js b/web/src/components/credential/Credential.js index 12e837d..15de275 100644 --- a/web/src/components/credential/Credential.js +++ b/web/src/components/credential/Credential.js @@ -10,7 +10,6 @@ import { Layout, Menu, Modal, - PageHeader, Row, Select, Space, @@ -32,7 +31,6 @@ import { SyncOutlined, UndoOutlined } from '@ant-design/icons'; -import {itemRender} from "../../utils/utils"; import {hasPermission, isAdmin} from "../../service/permission"; import dayjs from "dayjs"; @@ -41,16 +39,6 @@ const confirm = Modal.confirm; const {Search} = Input; const {Title, Text} = Typography; const {Content} = Layout; -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - path: 'credentials', - breadcrumbName: '授权凭证', - } -]; class Credential extends Component { @@ -483,18 +471,6 @@ class Credential extends Component { return ( <> - - -
diff --git a/web/src/components/dashboard/Dashboard.js b/web/src/components/dashboard/Dashboard.js index 22f5b1d..7cf5090 100644 --- a/web/src/components/dashboard/Dashboard.js +++ b/web/src/components/dashboard/Dashboard.js @@ -9,18 +9,6 @@ import {Area} from '@ant-design/charts'; import {isAdmin} from "../../service/permission"; - -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - path: 'dashboard', - breadcrumbName: '仪表盘', - } -]; - class Dashboard extends Component { state = { @@ -79,17 +67,6 @@ class Dashboard extends Component { return ( <> - -
diff --git a/web/src/components/devops/Job.js b/web/src/components/devops/Job.js index 3242cb8..2ff7acd 100644 --- a/web/src/components/devops/Job.js +++ b/web/src/components/devops/Job.js @@ -40,16 +40,6 @@ const confirm = Modal.confirm; const {Content} = Layout; const {Title, Text} = Typography; const {Search} = Input; -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - path: 'job', - breadcrumbName: '计划任务', - } -]; class Job extends Component { @@ -441,18 +431,6 @@ class Job extends Component { return ( <> - - -
diff --git a/web/src/components/devops/LoginLog.js b/web/src/components/devops/LoginLog.js index 8c76605..6211647 100644 --- a/web/src/components/devops/LoginLog.js +++ b/web/src/components/devops/LoginLog.js @@ -27,16 +27,6 @@ const confirm = Modal.confirm; const {Content} = Layout; const {Search} = Input; const {Title, Text} = Typography; -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - path: 'loginLog', - breadcrumbName: '登录日志', - } -]; class LoginLog extends Component { @@ -280,18 +270,6 @@ class LoginLog extends Component { return ( <> - - -
diff --git a/web/src/components/devops/Security.js b/web/src/components/devops/Security.js index 9f6e13d..55f8597 100644 --- a/web/src/components/devops/Security.js +++ b/web/src/components/devops/Security.js @@ -27,16 +27,6 @@ const confirm = Modal.confirm; const {Content} = Layout; const {Title, Text} = Typography; const {Search} = Input; -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - path: 'security', - breadcrumbName: '访问安全', - } -]; class Security extends Component { @@ -296,18 +286,6 @@ class Security extends Component { return ( <> - - -
diff --git a/web/src/components/session/OfflineSession.js b/web/src/components/session/OfflineSession.js index a2253d4..5cc6f5e 100644 --- a/web/src/components/session/OfflineSession.js +++ b/web/src/components/session/OfflineSession.js @@ -30,16 +30,6 @@ const confirm = Modal.confirm; const {Content} = Layout; const {Search} = Input; const {Title, Text} = Typography; -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - path: 'offlineSession', - breadcrumbName: '离线会话', - } -]; class OfflineSession extends Component { @@ -365,18 +355,6 @@ class OfflineSession extends Component { return ( <> - - -
diff --git a/web/src/components/session/OnlineSession.js b/web/src/components/session/OnlineSession.js index 32a20f5..e7f04f8 100644 --- a/web/src/components/session/OnlineSession.js +++ b/web/src/components/session/OnlineSession.js @@ -31,16 +31,6 @@ const confirm = Modal.confirm; const {Content} = Layout; const {Search} = Input; const {Title, Text} = Typography; -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - path: 'onlineSession', - breadcrumbName: '在线会话', - } -]; class OnlineSession extends Component { @@ -335,18 +325,6 @@ class OnlineSession extends Component { return ( <> - - -
diff --git a/web/src/components/setting/Setting.js b/web/src/components/setting/Setting.js index ad55f8c..3b056b0 100644 --- a/web/src/components/setting/Setting.js +++ b/web/src/components/setting/Setting.js @@ -10,17 +10,6 @@ const {Option} = Select; const {TabPane} = Tabs; const {Title} = Typography; -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - path: 'setting', - breadcrumbName: '系统设置', - } -]; - const formItemLayout = { labelCol: {span: 12}, wrapperCol: {span: 12}, @@ -114,18 +103,6 @@ class Setting extends Component { render() { return ( <> - - - diff --git a/web/src/components/user/Info.js b/web/src/components/user/Info.js index 45bbb53..ec1246a 100644 --- a/web/src/components/user/Info.js +++ b/web/src/components/user/Info.js @@ -8,17 +8,6 @@ import {ExclamationCircleOutlined, ReloadOutlined} from "@ant-design/icons"; const {Content} = Layout; const {Meta} = Card; -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - path: 'info', - breadcrumbName: '个人中心', - } -]; - const formItemLayout = { labelCol: {span: 3}, wrapperCol: {span: 6}, @@ -121,17 +110,6 @@ class Info extends Component { render() { return ( <> - -

修改密码

diff --git a/web/src/components/user/LayoutHeader.js b/web/src/components/user/LayoutHeader.js deleted file mode 100644 index 80cd048..0000000 --- a/web/src/components/user/LayoutHeader.js +++ /dev/null @@ -1,87 +0,0 @@ -import React, {Component} from 'react'; -import {Col, Dropdown, Menu, message, Popconfirm, Row, Tooltip} from "antd"; -import request from "../../common/request"; -import {getCurrentUser} from "../../service/permission"; -import {GithubOutlined, LogoutOutlined, QuestionCircleOutlined, SolutionOutlined} from "@ant-design/icons"; -import {Link} from "react-router-dom"; - -class LayoutHeader extends Component { - - confirm = async (e) => { - let result = await request.post('/logout'); - if (result['code'] !== 1) { - message.error(result['message']); - } else { - message.success('退出登录成功,即将跳转至登录页面。'); - window.location.reload(); - } - } - - - render() { - - const menu = ( - - - - - - 个人中心 - - - - - - - 点个Star - - - - - - - - - - 退出登录 - - - - - ); - - return ( -
- - - - -
- - - - - - -
- - - -
{getCurrentUser()['nickname']}
-
- -
- -
- ); - } -} - -export default LayoutHeader; \ No newline at end of file diff --git a/web/src/components/user/User.js b/web/src/components/user/User.js index fe3c5c6..c9ad087 100644 --- a/web/src/components/user/User.js +++ b/web/src/components/user/User.js @@ -34,7 +34,6 @@ import { SyncOutlined, UndoOutlined } from '@ant-design/icons'; -import LayoutHeader from "./LayoutHeader"; import UserShareAsset from "./UserShareAsset"; import {hasPermission} from "../../service/permission"; import dayjs from "dayjs"; @@ -44,17 +43,6 @@ const {Search} = Input; const {Title, Text} = Typography; const {Content} = Layout; -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - path: 'user', - breadcrumbName: '用户', - } -]; - class User extends Component { inputRefOfNickname = React.createRef(); @@ -473,18 +461,6 @@ class User extends Component { return ( <> - - -
diff --git a/web/src/components/user/UserGroup.js b/web/src/components/user/UserGroup.js index d525f9b..9960d79 100644 --- a/web/src/components/user/UserGroup.js +++ b/web/src/components/user/UserGroup.js @@ -15,17 +15,6 @@ const {Search} = Input; const {Title, Text} = Typography; const {Content} = Layout; -const routes = [ - { - path: '', - breadcrumbName: '首页', - }, - { - path: 'user', - breadcrumbName: '用户组', - } -]; - class UserGroup extends Component { inputRefOfName = React.createRef(); @@ -334,18 +323,6 @@ class UserGroup extends Component { return ( <> - - -