@electerm/electerm-react 3.15.41 → 3.15.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -870,12 +870,13 @@ export default class FileSection extends React.Component {
|
|
|
870
870
|
downloadFromBrowser = async () => {
|
|
871
871
|
const { path, name, isDirectory } = this.state.file
|
|
872
872
|
const p = resolve(path, name)
|
|
873
|
+
if (window.et.downloadFromBrowser) {
|
|
874
|
+
return window.et.downloadFromBrowser(p)
|
|
875
|
+
}
|
|
873
876
|
const url = '/api/download?path=' + encodeURIComponent(p)
|
|
874
|
-
const res = await window.fetch(url
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
}
|
|
878
|
-
})
|
|
877
|
+
const res = await window.api.fetch(url)
|
|
878
|
+
.catch(window.store.onError)
|
|
879
|
+
if (!res) return
|
|
879
880
|
const blob = await res.blob()
|
|
880
881
|
const a = document.createElement('a')
|
|
881
882
|
a.href = URL.createObjectURL(blob)
|
|
@@ -972,6 +972,12 @@ export default class Sftp extends Component {
|
|
|
972
972
|
}
|
|
973
973
|
|
|
974
974
|
handleUploadFromBrowser = () => {
|
|
975
|
+
if (window.et.handleUploadFromBrowser) {
|
|
976
|
+
return window.et.handleUploadFromBrowser(
|
|
977
|
+
this.state.localPath,
|
|
978
|
+
this.localList
|
|
979
|
+
)
|
|
980
|
+
}
|
|
975
981
|
const input = document.createElement('input')
|
|
976
982
|
input.type = 'file'
|
|
977
983
|
input.multiple = true
|
|
@@ -983,13 +989,10 @@ export default class Sftp extends Component {
|
|
|
983
989
|
const formData = new FormData()
|
|
984
990
|
formData.append('file', file)
|
|
985
991
|
formData.append('path', localPath)
|
|
986
|
-
await window.fetch('/api/upload', {
|
|
992
|
+
await window.api.fetch('/api/upload', {
|
|
987
993
|
method: 'POST',
|
|
988
|
-
body: formData
|
|
989
|
-
|
|
990
|
-
token: window.store?.config.tokenElecterm
|
|
991
|
-
}
|
|
992
|
-
})
|
|
994
|
+
body: formData
|
|
995
|
+
}).catch(handleErr)
|
|
993
996
|
}
|
|
994
997
|
this.localList()
|
|
995
998
|
}
|