From 5aeac11c6e23ecce03ec4110a72a3f5f0dce6770 Mon Sep 17 00:00:00 2001 From: vapao Date: Fri, 9 Apr 2021 09:17:15 +0800 Subject: [PATCH] fix issue --- spug_web/src/App.js | 2 +- spug_web/src/components/Breadcrumb.js | 5 +- spug_web/src/components/index.module.less | 2 + spug_web/src/pages/host/Detail.js | 2 +- spug_web/src/pages/host/Table.js | 110 ++++++++++------------ spug_web/src/pages/host/index.js | 9 +- 6 files changed, 66 insertions(+), 64 deletions(-) diff --git a/spug_web/src/App.js b/spug_web/src/App.js index 729ed28..867f379 100644 --- a/spug_web/src/App.js +++ b/spug_web/src/App.js @@ -14,7 +14,7 @@ class App extends Component { return ( - + ); diff --git a/spug_web/src/components/Breadcrumb.js b/spug_web/src/components/Breadcrumb.js index 6f14328..710da5a 100644 --- a/spug_web/src/components/Breadcrumb.js +++ b/spug_web/src/components/Breadcrumb.js @@ -27,7 +27,10 @@ export default class extends React.Component { {this.props.children} -
{title}
+
+ {title} + {this.props.extra} +
) } diff --git a/spug_web/src/components/index.module.less b/spug_web/src/components/index.module.less index 61a6b37..d6d72bf 100644 --- a/spug_web/src/components/index.module.less +++ b/spug_web/src/components/index.module.less @@ -141,6 +141,8 @@ border-bottom: 1px solid #e8e8e8; .title { + display: flex; + justify-content: space-between; margin-bottom: 9px; font-size: 20px; line-height: 50px; diff --git a/spug_web/src/pages/host/Detail.js b/spug_web/src/pages/host/Detail.js index 3540bea..86bc3e0 100644 --- a/spug_web/src/pages/host/Detail.js +++ b/spug_web/src/pages/host/Detail.js @@ -22,7 +22,7 @@ export default observer(function () { {group_ids.map(g_id => ( - {store.groups[g_id]} + {store.groups[g_id]} ))} diff --git a/spug_web/src/pages/host/Table.js b/spug_web/src/pages/host/Table.js index df1180c..3fae7f7 100644 --- a/spug_web/src/pages/host/Table.js +++ b/spug_web/src/pages/host/Table.js @@ -3,7 +3,7 @@ * Copyright (c) * Released under the AGPL-3.0 License. */ -import React from 'react'; +import React, { useEffect } from 'react'; import { observer } from 'mobx-react'; import { Table, Modal, message } from 'antd'; import { PlusOutlined, ImportOutlined } from '@ant-design/icons'; @@ -11,17 +11,12 @@ import { Action, TableCard, AuthButton } from 'components'; import { http, hasPermission } from 'libs'; import store from './store'; -@observer -class ComTable extends React.Component { - componentDidMount() { +function ComTable() { + useEffect(() => { store.fetchRecords() - } + }, []) - handleConsole = (info) => { - window.open(`/ssh/${info.id}`) - }; - - handleDelete = (text) => { + function handleDelete(text) { Modal.confirm({ title: '删除确认', content: `确定要删除【${text['name']}】?`, @@ -33,55 +28,52 @@ class ComTable extends React.Component { }) } }) - }; - - render() { - return ( - store[k] = v}/>} - loading={store.isFetching} - dataSource={store.dataSource} - onReload={store.fetchRecords} - actions={[ - } - onClick={() => store.showForm()}>新建, - } - onClick={() => store.importVisible = true}>批量导入 - ]} - pagination={{ - showSizeChanger: true, - showLessItems: true, - hideOnSinglePage: true, - showTotal: total => `共 ${total} 条`, - pageSizeOptions: ['10', '20', '50', '100'] - }}> - store.showDetail(info)}>{info.name}} - sorter={(a, b) => a.name.localeCompare(b.name)}/> - a.name.localeCompare(b.name)}/> - - - {hasPermission('host.host.edit|host.host.del|host.host.console') && ( - ( - - store.showForm(info)}>编辑 - this.handleDelete(info)}>删除 - this.handleConsole(info)}>Console - - )}/> - )} - - ) } + + return ( + store[k] = v}/>} + loading={store.isFetching} + dataSource={store.dataSource} + onReload={store.fetchRecords} + actions={[ + } + onClick={() => store.showForm()}>新建, + } + onClick={() => store.importVisible = true}>批量导入 + ]} + pagination={{ + showSizeChanger: true, + showLessItems: true, + hideOnSinglePage: true, + showTotal: total => `共 ${total} 条`, + pageSizeOptions: ['10', '20', '50', '100'] + }}> + store.showDetail(info)}>{info.name}} + sorter={(a, b) => a.name.localeCompare(b.name)}/> + a.name.localeCompare(b.name)}/> + + + {hasPermission('host.host.edit|host.host.del|host.host.console') && ( + ( + + store.showForm(info)}>编辑 + handleDelete(info)}>删除 + + )}/> + )} + + ) } -export default ComTable +export default observer(ComTable) diff --git a/spug_web/src/pages/host/index.js b/spug_web/src/pages/host/index.js index 1d52b35..65beb94 100644 --- a/spug_web/src/pages/host/index.js +++ b/spug_web/src/pages/host/index.js @@ -5,7 +5,8 @@ */ import React from 'react'; import { observer } from 'mobx-react'; -import { Row, Col } from 'antd'; +import { Row, Col, Button } from 'antd'; +import { RobotOutlined } from '@ant-design/icons'; import { AuthDiv, Breadcrumb } from 'components'; import Group from './Group'; import ComTable from './Table'; @@ -16,9 +17,13 @@ import Selector from './Selector'; import store from './store'; export default observer(function () { + function openTerminal() { + window.open('/ssh') + } + return ( - + } onClick={openTerminal}>Web 终端}> 首页 主机管理