@electerm/electerm-react 3.15.39 → 3.15.42
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.
- package/client/common/choose-save-folder.js +3 -2
- package/client/common/download.jsx +4 -16
- package/client/components/bookmark-form/common/ssh-auth-selector.jsx +3 -2
- package/client/components/common/upload.jsx +9 -1
- package/client/components/quick-commands/quick-command-transport-mod.jsx +3 -2
- package/client/components/rdp/file-transfer.js +2 -1
- package/client/components/rdp/rdp-session.jsx +2 -1
- package/client/components/setting-panel/keywords-transport.jsx +3 -2
- package/client/components/setting-panel/setting-terminal.jsx +3 -0
- package/client/components/setting-panel/terminal-bg-config.jsx +3 -0
- package/client/components/sftp/address-bar.jsx +1 -0
- package/client/components/sftp/file-item.jsx +4 -6
- package/client/components/sftp/sftp-entry.jsx +3 -6
- package/client/components/terminal/transfer-client-base.js +4 -3
- package/client/components/theme/theme-form.jsx +3 -2
- package/client/components/tree-list/bookmark-upload.js +3 -2
- package/client/store/sync.js +3 -3
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ const {
|
|
|
2
2
|
openDialog
|
|
3
3
|
} = window.api
|
|
4
4
|
|
|
5
|
-
export async function chooseSaveDirectory () {
|
|
5
|
+
export async function chooseSaveDirectory (opts) {
|
|
6
6
|
const savePaths = await openDialog({
|
|
7
7
|
title: 'Choose a folder to save file(s)',
|
|
8
8
|
message: 'Choose a folder to save file(s)',
|
|
@@ -13,7 +13,8 @@ export async function chooseSaveDirectory () {
|
|
|
13
13
|
'noResolveAliases',
|
|
14
14
|
'treatPackageAsDirectory',
|
|
15
15
|
'dontAddToRecent'
|
|
16
|
-
]
|
|
16
|
+
],
|
|
17
|
+
...opts
|
|
17
18
|
})
|
|
18
19
|
if (!savePaths || !savePaths.length) {
|
|
19
20
|
return undefined
|
|
@@ -6,23 +6,11 @@ import ShowItem from '../components/common/show-item'
|
|
|
6
6
|
import { chooseSaveDirectory } from './choose-save-folder'
|
|
7
7
|
import { DownloadOutlined } from '@ant-design/icons'
|
|
8
8
|
|
|
9
|
-
// function downloadForBrowser (filename, text) {
|
|
10
|
-
// const blob = new Blob([text], { type: 'text/plain;charset=utf-8' })
|
|
11
|
-
// const url = URL.createObjectURL(blob)
|
|
12
|
-
// const a = document.createElement('a')
|
|
13
|
-
// a.href = url
|
|
14
|
-
// a.download = filename
|
|
15
|
-
// document.body.appendChild(a)
|
|
16
|
-
// a.click()
|
|
17
|
-
// document.body.removeChild(a)
|
|
18
|
-
// URL.revokeObjectURL(url)
|
|
19
|
-
// }
|
|
20
|
-
|
|
21
9
|
export default async function download (filename, text) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const savePath = await chooseSaveDirectory()
|
|
10
|
+
const opts = window.et.isWebApp
|
|
11
|
+
? { filename, content: text }
|
|
12
|
+
: undefined
|
|
13
|
+
const savePath = await chooseSaveDirectory(opts)
|
|
26
14
|
if (!savePath) {
|
|
27
15
|
return
|
|
28
16
|
}
|
|
@@ -26,8 +26,9 @@ export default function renderAuth (props) {
|
|
|
26
26
|
profileFilter = (d) => d
|
|
27
27
|
} = props
|
|
28
28
|
const commonBeforeUpload = (fieldName) => async (file) => {
|
|
29
|
-
const
|
|
30
|
-
|
|
29
|
+
const content = file.fileContent !== undefined
|
|
30
|
+
? file.fileContent
|
|
31
|
+
: await window.fs.readFile(file.filePath)
|
|
31
32
|
form.setFieldsValue({
|
|
32
33
|
[fieldName]: content
|
|
33
34
|
})
|
|
@@ -8,6 +8,7 @@ import { getLocalFileInfo } from '../sftp/file-read'
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Open a single file select dialog
|
|
11
|
+
* Supports browser upload in web app mode
|
|
11
12
|
* @returns {Promise<Object|null>} - File object with path info or null if cancelled
|
|
12
13
|
*/
|
|
13
14
|
const openFileSelect = async () => {
|
|
@@ -23,7 +24,14 @@ const openFileSelect = async () => {
|
|
|
23
24
|
message: 'Choose a file',
|
|
24
25
|
properties
|
|
25
26
|
}).catch(() => false)
|
|
26
|
-
if (!files
|
|
27
|
+
if (!files) {
|
|
28
|
+
return null
|
|
29
|
+
}
|
|
30
|
+
// Browser upload returns { fileContent, fileName }
|
|
31
|
+
if (files.fileContent !== undefined) {
|
|
32
|
+
return files
|
|
33
|
+
}
|
|
34
|
+
if (!files.length) {
|
|
27
35
|
return null
|
|
28
36
|
}
|
|
29
37
|
const filePath = files[0]
|
|
@@ -7,8 +7,9 @@ export default class QmTransport extends BookmarkTransport {
|
|
|
7
7
|
name = 'quickCommands'
|
|
8
8
|
beforeUpload = async (file) => {
|
|
9
9
|
const { store } = this.props
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const txt = file.fileContent !== undefined
|
|
11
|
+
? file.fileContent
|
|
12
|
+
: await window.fs.readFile(file.filePath)
|
|
12
13
|
try {
|
|
13
14
|
const arr = JSON.parse(txt)
|
|
14
15
|
const state = store[this.name]
|
|
@@ -233,7 +233,8 @@ export class FileTransferManager {
|
|
|
233
233
|
const savePath = await window.api.openDialog({
|
|
234
234
|
title: `Save ${fileInfo.name}`,
|
|
235
235
|
message: `Choose where to save ${fileInfo.name}`,
|
|
236
|
-
properties: ['openDirectory', 'createDirectory']
|
|
236
|
+
properties: ['openDirectory', 'createDirectory'],
|
|
237
|
+
noBrowserTransfer: true
|
|
237
238
|
}).catch((err) => {
|
|
238
239
|
this.log(`Save dialog error: ${err.message}`, 'error')
|
|
239
240
|
return false
|
|
@@ -562,7 +562,8 @@ export default class RdpSession extends PureComponent {
|
|
|
562
562
|
const files = await window.api.openDialog({
|
|
563
563
|
title: 'Choose files to upload to remote desktop',
|
|
564
564
|
message: 'Choose files to upload',
|
|
565
|
-
properties
|
|
565
|
+
properties,
|
|
566
|
+
noBrowserTransfer: true
|
|
566
567
|
}).catch((err) => {
|
|
567
568
|
this.log(`File dialog error: ${err.message}`, 'error')
|
|
568
569
|
return false
|
|
@@ -6,8 +6,9 @@ export default class KeywordsTransport extends BookmarkTransport {
|
|
|
6
6
|
name = 'keywords-highlight'
|
|
7
7
|
beforeUpload = async (file) => {
|
|
8
8
|
const { store } = this.props
|
|
9
|
-
const
|
|
10
|
-
|
|
9
|
+
const txt = file.fileContent !== undefined
|
|
10
|
+
? file.fileContent
|
|
11
|
+
: await window.fs.readFile(file.filePath)
|
|
11
12
|
try {
|
|
12
13
|
store.setConfig({
|
|
13
14
|
keywords: JSON.parse(txt)
|
|
@@ -264,6 +264,9 @@ export default class SettingTerminal extends Component {
|
|
|
264
264
|
const after = (
|
|
265
265
|
<Upload
|
|
266
266
|
beforeUpload={(file) => {
|
|
267
|
+
if (file.fileContent !== undefined) {
|
|
268
|
+
return
|
|
269
|
+
}
|
|
267
270
|
const filePath = file.filePath
|
|
268
271
|
this.onChangeValue(filePath, name)
|
|
269
272
|
}}
|
|
@@ -871,11 +871,9 @@ export default class FileSection extends React.Component {
|
|
|
871
871
|
const { path, name, isDirectory } = this.state.file
|
|
872
872
|
const p = resolve(path, name)
|
|
873
873
|
const url = '/api/download?path=' + encodeURIComponent(p)
|
|
874
|
-
const res = await window.fetch(url
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
}
|
|
878
|
-
})
|
|
874
|
+
const res = await window.api.fetch(url)
|
|
875
|
+
.catch(window.store.onError)
|
|
876
|
+
if (!res) return
|
|
879
877
|
const blob = await res.blob()
|
|
880
878
|
const a = document.createElement('a')
|
|
881
879
|
a.href = URL.createObjectURL(blob)
|
|
@@ -1068,7 +1066,7 @@ export default class FileSection extends React.Component {
|
|
|
1068
1066
|
res.push({
|
|
1069
1067
|
func: 'downloadFromBrowser',
|
|
1070
1068
|
icon: 'DownloadOutlined',
|
|
1071
|
-
text: '
|
|
1069
|
+
text: e('downloadFromBrowser')
|
|
1072
1070
|
})
|
|
1073
1071
|
}
|
|
1074
1072
|
if (showEdit) {
|
|
@@ -983,13 +983,10 @@ export default class Sftp extends Component {
|
|
|
983
983
|
const formData = new FormData()
|
|
984
984
|
formData.append('file', file)
|
|
985
985
|
formData.append('path', localPath)
|
|
986
|
-
await window.fetch('/api/upload', {
|
|
986
|
+
await window.api.fetch('/api/upload', {
|
|
987
987
|
method: 'POST',
|
|
988
|
-
body: formData
|
|
989
|
-
|
|
990
|
-
token: window.store?.config.tokenElecterm
|
|
991
|
-
}
|
|
992
|
-
})
|
|
988
|
+
body: formData
|
|
989
|
+
}).catch(handleErr)
|
|
993
990
|
}
|
|
994
991
|
this.localList()
|
|
995
992
|
}
|
|
@@ -203,11 +203,11 @@ export class TransferClientBase {
|
|
|
203
203
|
'treatPackageAsDirectory',
|
|
204
204
|
'dontAddToRecent'
|
|
205
205
|
]
|
|
206
|
-
|
|
207
206
|
files = await window.api.openDialog({
|
|
208
207
|
title,
|
|
209
208
|
message,
|
|
210
|
-
properties
|
|
209
|
+
properties,
|
|
210
|
+
noBrowserTransfer: true
|
|
211
211
|
}).catch(() => false)
|
|
212
212
|
}
|
|
213
213
|
|
|
@@ -253,7 +253,8 @@ export class TransferClientBase {
|
|
|
253
253
|
'noResolveAliases',
|
|
254
254
|
'treatPackageAsDirectory',
|
|
255
255
|
'dontAddToRecent'
|
|
256
|
-
]
|
|
256
|
+
],
|
|
257
|
+
noBrowserTransfer: true
|
|
257
258
|
}).catch(() => false)
|
|
258
259
|
|
|
259
260
|
if (!savePaths || !savePaths.length) {
|
|
@@ -154,8 +154,9 @@ export default function ThemeForm (props) {
|
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
async function beforeUpload (file) {
|
|
157
|
-
const
|
|
158
|
-
|
|
157
|
+
const txt = file.fileContent !== undefined
|
|
158
|
+
? file.fileContent
|
|
159
|
+
: await window.fs.readFile(file.filePath)
|
|
159
160
|
const { name, themeConfig, uiThemeConfig } = convertTheme(txt)
|
|
160
161
|
const tt = convertThemeToText({
|
|
161
162
|
themeConfig, uiThemeConfig
|
|
@@ -25,8 +25,9 @@ export const bookmarkUpload = action(async (file) => {
|
|
|
25
25
|
const { store } = window
|
|
26
26
|
const { bookmarks, bookmarkGroups } = store
|
|
27
27
|
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const txt = file.fileContent !== undefined
|
|
29
|
+
? file.fileContent
|
|
30
|
+
: await window.fs.readFile(file.filePath)
|
|
30
31
|
|
|
31
32
|
const content = JSON.parse(txt)
|
|
32
33
|
let bookmarkGroups1 = []
|
package/client/store/sync.js
CHANGED
|
@@ -565,9 +565,9 @@ export default (Store) => {
|
|
|
565
565
|
}
|
|
566
566
|
|
|
567
567
|
Store.prototype.importAll = async function (file) {
|
|
568
|
-
const
|
|
569
|
-
|
|
570
|
-
.readFile(filePath)
|
|
568
|
+
const txt = file.fileContent !== undefined
|
|
569
|
+
? file.fileContent
|
|
570
|
+
: await window.fs.readFile(file.filePath)
|
|
571
571
|
const { store } = window
|
|
572
572
|
const objs = JSON.parse(txt)
|
|
573
573
|
const { names } = store.getDataSyncNames(true)
|