From 93a5beb43df4dcae225fb8139f593386a7de8a00 Mon Sep 17 00:00:00 2001 From: vapao Date: Sat, 9 Jul 2022 23:55:01 +0800 Subject: [PATCH] =?UTF-8?q?U=20=E4=BC=98=E5=8C=96=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=88=86=E5=8F=91=E4=B8=8A=E4=BC=A0=E8=BF=9B=E5=BA=A6=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spug_web/src/pages/exec/transfer/index.js | 20 +++++++++++++++----- spug_web/src/pages/ssh/FileManager.js | 6 ------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/spug_web/src/pages/exec/transfer/index.js b/spug_web/src/pages/exec/transfer/index.js index 06c1b43..b89b9da 100644 --- a/spug_web/src/pages/exec/transfer/index.js +++ b/spug_web/src/pages/exec/transfer/index.js @@ -28,10 +28,10 @@ function TransferIndex() { const [dir, setDir] = useState('') const [hosts, setHosts] = useState([]) const [sProps, setSProps] = useState({visible: false}) + const [percent, setPercent] = useState() const [token, setToken] = useState() const [histories, setHistories] = useState([]) - useEffect(() => { if (!loading) { http.get('/api/exec/transfer/') @@ -39,6 +39,12 @@ function TransferIndex() { } }, [loading]) + function _handleProgress(e) { + const data = e.loaded / e.total * 100 + if (!percent && data === 100) return + setPercent(String(data).replace(/(\d+\.\d).*/, '$1')) + } + function handleSubmit() { const formData = new FormData(); if (files.length === 0) return message.error('请添加数据源') @@ -55,7 +61,7 @@ function TransferIndex() { } formData.append('data', JSON.stringify(data)) setLoading(true) - http.post('/api/exec/transfer/', formData) + http.post('/api/exec/transfer/', formData, {timeout: 600000, onUploadProgress: _handleProgress}) .then(res => { const tmp = {} for (let host of hosts) { @@ -68,7 +74,10 @@ function TransferIndex() { store.outputs = tmp setToken(res) }) - .finally(() => setLoading(false)) + .finally(() => { + setLoading(false) + setPercent() + }) } function handleAddHostFile() { @@ -145,8 +154,9 @@ function TransferIndex() { - +
diff --git a/spug_web/src/pages/ssh/FileManager.js b/spug_web/src/pages/ssh/FileManager.js index 7d18355..9df0cd9 100644 --- a/spug_web/src/pages/ssh/FileManager.js +++ b/spug_web/src/pages/ssh/FileManager.js @@ -123,12 +123,6 @@ class FileManager extends React.Component { this.fetchFiles(pwd) }; - handlePathInput = (e) => { - const value = e.target.value; - const pwd = value.substring(1).split('/') - this.setState({pwd}) - }; - handleInputEnter = () => { if (this.state.inputPath === null) { if (this.state.pwd.length > 0) {