web: 界面优化

addon-dailer
lqqyt2423 3 years ago
parent 1509a04b7d
commit 914ff470fb

@ -18,7 +18,6 @@
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-json-pretty": "^2.2.0", "react-json-pretty": "^2.2.0",
"react-scripts": "4.0.3", "react-scripts": "4.0.3",
"scrollmonitor": "1.2.4",
"typescript": "^4.5.2", "typescript": "^4.5.2",
"web-vitals": "^2.1.2" "web-vitals": "^2.1.2"
}, },

@ -33,7 +33,6 @@
<noscript>You need to enable JavaScript to run this app.</noscript> <noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div> <div id="root"></div>
<div id="hidden-bottom" style="height: 0px; visibility: hidden;">bottom</div>
<!-- <!--
This HTML file is a template. This HTML file is a template.
If you open it directly in the browser, you will see an empty page. If you open it directly in the browser, you will see an empty page.

@ -1,26 +1,43 @@
.main-table-wrap { .main-table-wrap {
font-family: Menlo,Monaco; font-family: Menlo,Monaco;
font-size: 0.8rem; font-size: 0.8rem;
display: flex;
flex-flow: column;
height: 100vh;
} }
.main-table-wrap table td { .table-wrap-div {
overflow: hidden; flex: 1;
white-space: nowrap; overflow: auto;
border-top: 1px solid rgb(222, 226, 230);
}
.table-wrap-div .table>:not(:first-child) {
border-top: 0 solid rgb(222, 226, 230);
}
.table-wrap-div .table {
margin-bottom: 0;
} }
/* https://css-tricks.com/position-sticky-and-table-headers/ */ /* https://codepen.io/Ray-H/pen/bMedLL */
.main-table-wrap table th { .table-wrap-div thead tr {
border-width: 0;
background-color: white; background-color: white;
position: sticky; position: sticky;
top: 50px; top: 0;
background: linear-gradient(to top,rgb(33, 37, 41), rgb(33, 37, 41) 2px, white 1px, white 100%);
}
.main-table-wrap table td {
overflow: hidden;
white-space: nowrap;
} }
.top-control { .top-control {
position: sticky;
display: flex; display: flex;
align-items: center; align-items: center;
background-color: #fff; background-color: #fff;
top: 0;
padding: 10px; padding: 10px;
} }

@ -2,7 +2,6 @@ import React from 'react'
import Table from 'react-bootstrap/Table' import Table from 'react-bootstrap/Table'
import Form from 'react-bootstrap/Form' import Form from 'react-bootstrap/Form'
import Button from 'react-bootstrap/Button' import Button from 'react-bootstrap/Button'
import scrollMonitor from 'scrollmonitor'
import './App.css' import './App.css'
import BreakPoint from './components/BreakPoint' import BreakPoint from './components/BreakPoint'
@ -21,17 +20,14 @@ interface IState {
const wsReconnIntervals = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32] const wsReconnIntervals = [1, 1, 2, 2, 4, 4, 8, 8, 16, 16, 32, 32]
interface IProps { // eslint-disable-next-line @typescript-eslint/no-empty-interface
pageBottom: HTMLElement interface IProps {}
}
class App extends React.Component<IProps, IState> { class App extends React.Component<IProps, IState> {
private flowMgr: FlowManager private flowMgr: FlowManager
private ws: WebSocket | null private ws: WebSocket | null
private wsUnmountClose: boolean private wsUnmountClose: boolean
private autoScore = false
private wsReconnCount = -1 private wsReconnCount = -1
constructor(props: IProps) { constructor(props: IProps) {
@ -48,8 +44,6 @@ class App extends React.Component<IProps, IState> {
this.ws = null this.ws = null
this.wsUnmountClose = false this.wsUnmountClose = false
this.initScrollMonitor()
} }
componentDidMount() { componentDidMount() {
@ -112,11 +106,7 @@ class App extends React.Component<IProps, IState> {
if (msg.type === MessageType.REQUEST) { if (msg.type === MessageType.REQUEST) {
const flow = new Flow(msg) const flow = new Flow(msg)
this.flowMgr.add(flow) this.flowMgr.add(flow)
this.setState({ flows: this.flowMgr.showList() }, () => { this.setState({ flows: this.flowMgr.showList() })
if (this.autoScore) {
this.props.pageBottom.scrollIntoView({ behavior: 'auto' })
}
})
} }
else if (msg.type === MessageType.REQUEST_BODY) { else if (msg.type === MessageType.REQUEST_BODY) {
const flow = this.flowMgr.get(msg.id) const flow = this.flowMgr.get(msg.id)
@ -139,16 +129,6 @@ class App extends React.Component<IProps, IState> {
} }
} }
initScrollMonitor() {
const watcher = scrollMonitor.create(this.props.pageBottom)
watcher.enterViewport(() => {
this.autoScore = true
})
watcher.exitViewport(() => {
this.autoScore = false
})
}
render() { render() {
const { flows } = this.state const { flows } = this.state
return ( return (
@ -179,38 +159,41 @@ class App extends React.Component<IProps, IState> {
<span>status: {this.state.wsStatus}</span> <span>status: {this.state.wsStatus}</span>
</div> </div>
<Table striped bordered size="sm" style={{ tableLayout: 'fixed' }}> <div className="table-wrap-div">
<thead> <Table striped bordered size="sm" style={{ tableLayout: 'fixed' }}>
<tr> <thead>
<th style={{ width: '50px' }}>No</th> <tr>
<th style={{ width: '80px' }}>Method</th> <th style={{ width: '50px' }}>No</th>
<th style={{ width: '200px' }}>Host</th> <th style={{ width: '80px' }}>Method</th>
<th style={{ width: 'auto' }}>Path</th> <th style={{ width: '200px' }}>Host</th>
<th style={{ width: '150px' }}>Type</th> <th style={{ width: 'auto' }}>Path</th>
<th style={{ width: '80px' }}>Status</th> <th style={{ width: '150px' }}>Type</th>
<th style={{ width: '90px' }}>Size</th> <th style={{ width: '80px' }}>Status</th>
<th style={{ width: '90px' }}>Time</th> <th style={{ width: '90px' }}>Size</th>
</tr> <th style={{ width: '90px' }}>Time</th>
</thead> </tr>
<tbody> </thead>
{ <tbody>
flows.map(f => { {
const fp = f.preview() flows.map(f => {
const fp = f.preview()
return (
<FlowPreview return (
key={fp.id} <FlowPreview
flow={fp} key={fp.id}
isSelected={(this.state.flow && this.state.flow.id === fp.id) ? true : false} flow={fp}
onShowDetail={() => { isSelected={(this.state.flow && this.state.flow.id === fp.id) ? true : false}
this.setState({ flow: f }) onShowDetail={() => {
}} this.setState({ flow: f })
/> }}
) />
}) )
} })
</tbody> }
</Table> </tbody>
</Table>
<div id="hidden-bottom" style={{ height: '0px', visibility: 'hidden' }}></div>
</div>
<ViewFlow <ViewFlow
flow={this.state.flow} flow={this.state.flow}

@ -4,11 +4,9 @@ import 'bootstrap/dist/css/bootstrap.min.css'
import App from './App' import App from './App'
import reportWebVitals from './reportWebVitals' import reportWebVitals from './reportWebVitals'
const pageBottom = document.getElementById('hidden-bottom')
ReactDOM.render( ReactDOM.render(
<React.StrictMode> <React.StrictMode>
<App pageBottom={pageBottom as HTMLElement} /> <App />
</React.StrictMode>, </React.StrictMode>,
document.getElementById('root') document.getElementById('root')
) )

@ -1,3 +0,0 @@
declare module 'scrollmonitor' {
export function create(el: HTMLElement): any
}

@ -10311,11 +10311,6 @@ schema-utils@^3.0.0:
ajv "^6.12.5" ajv "^6.12.5"
ajv-keywords "^3.5.2" ajv-keywords "^3.5.2"
scrollmonitor@1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/scrollmonitor/-/scrollmonitor-1.2.4.tgz#823d04cc1574aa3b71de7cc70ef91ebe633344a0"
integrity sha512-HBQpeZVAYETbNk0DAmi+X4hdTQMk5WRa/Udez9o8yC8GcRiPDgBxyEdV9g9Su/TWOuUeVfVGfNcyboEyzkte4Q==
select-hose@^2.0.0: select-hose@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz" resolved "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz"
@ -12254,4 +12249,4 @@ yargs@^15.4.1:
yocto-queue@^0.1.0: yocto-queue@^0.1.0:
version "0.1.0" version "0.1.0"
resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz" resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q== integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==

Loading…
Cancel
Save