@electerm/electerm-react 3.15.32 → 3.15.36
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/components/session/session.jsx +1 -1
- package/client/components/sftp/file-item.jsx +11 -48
- package/client/components/sftp/list-table-ui.jsx +73 -1
- package/client/components/terminal/terminal.jsx +3 -3
- package/client/components/vnc/vnc-session.jsx +4 -3
- package/package.json +1 -1
- package/client/entry/basic.js +0 -62
- package/client/entry/electerm.jsx +0 -9
- package/client/entry/worker.js +0 -146
|
@@ -537,7 +537,7 @@ export default class SessionWrapper extends Component {
|
|
|
537
537
|
}
|
|
538
538
|
|
|
539
539
|
renderKeepaliveIcon = () => {
|
|
540
|
-
if (this.isSshDisabled()
|
|
540
|
+
if (this.isSshDisabled()) {
|
|
541
541
|
return null
|
|
542
542
|
}
|
|
543
543
|
const { keepaliveEnabled } = this.state
|
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
paneMap,
|
|
28
28
|
isMac, maxEditFileSize, ctrlOrCmd
|
|
29
29
|
} from '../../common/constants'
|
|
30
|
-
import findParent from '../../common/find-parent'
|
|
31
30
|
import sorter from '../../common/index-sorter'
|
|
32
31
|
import { getFolderFromFilePath, getLocalFileInfo } from './file-read'
|
|
33
32
|
import { readClipboard, copy as copyToClipboard, hasFileInClipboardText } from '../../common/clipboard'
|
|
@@ -192,33 +191,6 @@ export default class FileSection extends React.Component {
|
|
|
192
191
|
this.props.addTransferList(res)
|
|
193
192
|
}
|
|
194
193
|
|
|
195
|
-
onDrag = () => {}
|
|
196
|
-
|
|
197
|
-
onDragEnter = e => {
|
|
198
|
-
let { target } = e
|
|
199
|
-
target = findParent(target, '.' + fileItemCls)
|
|
200
|
-
if (!target) {
|
|
201
|
-
return e.preventDefault()
|
|
202
|
-
}
|
|
203
|
-
this.dropTarget = target
|
|
204
|
-
target.classList.add(onDragOverCls)
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
onDragExit = () => {}
|
|
208
|
-
|
|
209
|
-
onDragLeave = e => {
|
|
210
|
-
let { target } = e
|
|
211
|
-
target = findParent(target, '.' + fileItemCls)
|
|
212
|
-
if (!target) {
|
|
213
|
-
return e.preventDefault()
|
|
214
|
-
}
|
|
215
|
-
target.classList.remove(onDragOverCls)
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
onDragOver = e => {
|
|
219
|
-
e.preventDefault()
|
|
220
|
-
}
|
|
221
|
-
|
|
222
194
|
onDragStart = e => {
|
|
223
195
|
this.props.modifier({
|
|
224
196
|
onDrag: true
|
|
@@ -248,6 +220,16 @@ export default class FileSection extends React.Component {
|
|
|
248
220
|
return getDropFileList(data)
|
|
249
221
|
}
|
|
250
222
|
|
|
223
|
+
onDragEnd = () => {
|
|
224
|
+
this.props.modifier({
|
|
225
|
+
onDrag: false
|
|
226
|
+
})
|
|
227
|
+
removeClass(this.domRef.current, onDragCls, onMultiDragCls)
|
|
228
|
+
document.querySelectorAll('.' + onDragOverCls).forEach((d) => {
|
|
229
|
+
removeClass(d, onDragOverCls)
|
|
230
|
+
})
|
|
231
|
+
}
|
|
232
|
+
|
|
251
233
|
onDrop = async e => {
|
|
252
234
|
e.preventDefault()
|
|
253
235
|
const fromFileManager = !!e?.dataTransfer?.files?.length
|
|
@@ -279,17 +261,6 @@ export default class FileSection extends React.Component {
|
|
|
279
261
|
this.onDropFile(fromFiles, toFile, fromFileManager)
|
|
280
262
|
}
|
|
281
263
|
|
|
282
|
-
onDragEnd = e => {
|
|
283
|
-
this.props.modifier({
|
|
284
|
-
onDrag: false
|
|
285
|
-
})
|
|
286
|
-
removeClass(this.domRef.current, onDragCls, onMultiDragCls)
|
|
287
|
-
document.querySelectorAll('.' + onDragOverCls).forEach((d) => {
|
|
288
|
-
removeClass(d, onDragOverCls)
|
|
289
|
-
})
|
|
290
|
-
e && e.dataTransfer && e.dataTransfer.clearData()
|
|
291
|
-
}
|
|
292
|
-
|
|
293
264
|
onDropFile = async (fromFiles, toFile, fromFileManager) => {
|
|
294
265
|
const { type: fromType } = fromFiles[0]
|
|
295
266
|
const {
|
|
@@ -1297,15 +1268,7 @@ export default class FileSection extends React.Component {
|
|
|
1297
1268
|
const props = {
|
|
1298
1269
|
className,
|
|
1299
1270
|
draggable: draggable && !isParent,
|
|
1300
|
-
|
|
1301
|
-
'onDrag',
|
|
1302
|
-
'onDragEnter',
|
|
1303
|
-
'onDragExit',
|
|
1304
|
-
'onDragLeave',
|
|
1305
|
-
'onDragOver',
|
|
1306
|
-
'onDrop',
|
|
1307
|
-
'onDragEnd'
|
|
1308
|
-
]),
|
|
1271
|
+
onDrop: this.onDrop,
|
|
1309
1272
|
onDragStart: onDragStart || this.onDragStart,
|
|
1310
1273
|
'data-id': id,
|
|
1311
1274
|
id: this.id,
|
|
@@ -13,8 +13,14 @@ import {
|
|
|
13
13
|
} from '@ant-design/icons'
|
|
14
14
|
import IconHolder from '../sys-menu/icon-holder'
|
|
15
15
|
import { filesRef } from '../common/ref'
|
|
16
|
+
import findParent from '../../common/find-parent'
|
|
17
|
+
import { removeClass } from '../../common/class'
|
|
16
18
|
|
|
17
19
|
const e = window.translate
|
|
20
|
+
const fileItemCls = 'sftp-item'
|
|
21
|
+
const onDragCls = 'sftp-ondrag'
|
|
22
|
+
const onDragOverCls = 'sftp-dragover'
|
|
23
|
+
const onMultiDragCls = 'sftp-dragover-multi'
|
|
18
24
|
|
|
19
25
|
export default class FileListTable extends Component {
|
|
20
26
|
constructor (props) {
|
|
@@ -27,6 +33,67 @@ export default class FileListTable extends Component {
|
|
|
27
33
|
|
|
28
34
|
containerRef = createRef()
|
|
29
35
|
|
|
36
|
+
onDragOver = e => {
|
|
37
|
+
e.preventDefault()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
onDragEnter = e => {
|
|
41
|
+
let { target } = e
|
|
42
|
+
target = findParent(target, '.' + fileItemCls)
|
|
43
|
+
if (!target) {
|
|
44
|
+
return e.preventDefault()
|
|
45
|
+
}
|
|
46
|
+
if (this.dropTarget && this.dropTarget !== target) {
|
|
47
|
+
this.dropTarget.classList.remove(onDragOverCls)
|
|
48
|
+
}
|
|
49
|
+
this.dropTarget = target
|
|
50
|
+
target.classList.add(onDragOverCls)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
onDragLeave = e => {
|
|
54
|
+
let { target } = e
|
|
55
|
+
target = findParent(target, '.' + fileItemCls)
|
|
56
|
+
if (!target) {
|
|
57
|
+
return e.preventDefault()
|
|
58
|
+
}
|
|
59
|
+
if (
|
|
60
|
+
this.containerRef.current &&
|
|
61
|
+
!this.containerRef.current.contains(e.relatedTarget)
|
|
62
|
+
) {
|
|
63
|
+
target.classList.remove(onDragOverCls)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
onDrop = e => {
|
|
68
|
+
e.preventDefault()
|
|
69
|
+
let { target } = e
|
|
70
|
+
if (!target) {
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
target = findParent(target, '.' + fileItemCls)
|
|
74
|
+
if (!target) {
|
|
75
|
+
return
|
|
76
|
+
}
|
|
77
|
+
const id = target.getAttribute('data-id')
|
|
78
|
+
const ref = filesRef.get('file-' + id)
|
|
79
|
+
if (ref) {
|
|
80
|
+
ref.onDrop(e)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
onDragEnd = e => {
|
|
85
|
+
this.props.modifier({
|
|
86
|
+
onDrag: false
|
|
87
|
+
})
|
|
88
|
+
document.querySelectorAll('.' + onDragCls).forEach((d) => {
|
|
89
|
+
removeClass(d, onDragCls, onMultiDragCls)
|
|
90
|
+
})
|
|
91
|
+
document.querySelectorAll('.' + onDragOverCls).forEach((d) => {
|
|
92
|
+
removeClass(d, onDragOverCls)
|
|
93
|
+
})
|
|
94
|
+
e && e.dataTransfer && e.dataTransfer.clearData()
|
|
95
|
+
}
|
|
96
|
+
|
|
30
97
|
componentDidUpdate (prevProps) {
|
|
31
98
|
const prevList = prevProps.fileList
|
|
32
99
|
const nextList = this.props.fileList
|
|
@@ -289,7 +356,12 @@ export default class FileListTable extends Component {
|
|
|
289
356
|
draggable: false,
|
|
290
357
|
onScroll: this.onScroll,
|
|
291
358
|
onClick: this.handleClick,
|
|
292
|
-
onDoubleClick: this.handleDoubleClick
|
|
359
|
+
onDoubleClick: this.handleDoubleClick,
|
|
360
|
+
onDragOver: this.onDragOver,
|
|
361
|
+
onDragEnter: this.onDragEnter,
|
|
362
|
+
onDragLeave: this.onDragLeave,
|
|
363
|
+
onDrop: this.onDrop,
|
|
364
|
+
onDragEnd: this.onDragEnd
|
|
293
365
|
}
|
|
294
366
|
const cls = classnames('sftp-table relative')
|
|
295
367
|
const ddProps = {
|
|
@@ -1356,7 +1356,7 @@ class Term extends Component {
|
|
|
1356
1356
|
id
|
|
1357
1357
|
)
|
|
1358
1358
|
}
|
|
1359
|
-
return `ws://${host}:${port}/terminals/${id}
|
|
1359
|
+
return `ws://${host}:${port}/terminals/${id}`
|
|
1360
1360
|
}
|
|
1361
1361
|
|
|
1362
1362
|
remoteInit = async (term = this.term) => {
|
|
@@ -1448,7 +1448,7 @@ class Term extends Component {
|
|
|
1448
1448
|
if (this.onClose) {
|
|
1449
1449
|
if (r && r.port) {
|
|
1450
1450
|
try {
|
|
1451
|
-
const tmpSock = new WebSocket(this.buildWsUrl(r.port))
|
|
1451
|
+
const tmpSock = new WebSocket(this.buildWsUrl(r.port), [this.props.config.tokenElecterm])
|
|
1452
1452
|
tmpSock.onopen = () => tmpSock.close()
|
|
1453
1453
|
} catch (_e) {}
|
|
1454
1454
|
}
|
|
@@ -1477,7 +1477,7 @@ class Term extends Component {
|
|
|
1477
1477
|
term.pid = id
|
|
1478
1478
|
this.pid = id
|
|
1479
1479
|
const wsUrl = this.buildWsUrl(r.port)
|
|
1480
|
-
const socket = new WebSocket(wsUrl)
|
|
1480
|
+
const socket = new WebSocket(wsUrl, [this.props.config.tokenElecterm])
|
|
1481
1481
|
socket.onclose = this.oncloseSocket
|
|
1482
1482
|
socket.onerror = this.onerrorSocket
|
|
1483
1483
|
this.socket = socket
|
|
@@ -96,7 +96,7 @@ export default class VncSession extends PureComponent {
|
|
|
96
96
|
extra
|
|
97
97
|
)
|
|
98
98
|
}
|
|
99
|
-
return `ws://${host}:${port}/${type}/${id}
|
|
99
|
+
return `ws://${host}:${port}/${type}/${id}${extra}`
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
getControlProps = (options = {}) => {
|
|
@@ -226,7 +226,7 @@ export default class VncSession extends PureComponent {
|
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
const { width, height } = this.calcCanvasSize()
|
|
229
|
-
const wsUrl = this.buildWsUrl(port, 'vnc',
|
|
229
|
+
const wsUrl = this.buildWsUrl(port, 'vnc', `?width=${width}&height=${height}`)
|
|
230
230
|
// When scaleViewport is false, we don't set fixed dimensions on the canvas
|
|
231
231
|
// so it can render at the actual remote screen size
|
|
232
232
|
const vncOpts = {
|
|
@@ -243,7 +243,8 @@ export default class VncSession extends PureComponent {
|
|
|
243
243
|
overflow: 'hidden'
|
|
244
244
|
}
|
|
245
245
|
: {},
|
|
246
|
-
credentials: {}
|
|
246
|
+
credentials: {},
|
|
247
|
+
wsProtocols: [this.props.config.tokenElecterm]
|
|
247
248
|
}
|
|
248
249
|
if (username) {
|
|
249
250
|
vncOpts.credentials.username = username
|
package/package.json
CHANGED
package/client/entry/basic.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* init app data then write main script to html body
|
|
3
|
-
*/
|
|
4
|
-
import '../css/basic.styl'
|
|
5
|
-
import '../css/mobile.styl'
|
|
6
|
-
import { get as _get } from 'lodash-es'
|
|
7
|
-
import '../common/pre'
|
|
8
|
-
|
|
9
|
-
const { isDev } = window.et
|
|
10
|
-
const { version } = window.pre.packInfo
|
|
11
|
-
|
|
12
|
-
async function loadWorker () {
|
|
13
|
-
return new Promise((resolve) => {
|
|
14
|
-
const url = !isDev ? `js/worker-${version}.js` : 'js/worker.js'
|
|
15
|
-
window.worker = new window.Worker(url)
|
|
16
|
-
function onInit (e) {
|
|
17
|
-
if (!e || !e.data) {
|
|
18
|
-
return false
|
|
19
|
-
}
|
|
20
|
-
const {
|
|
21
|
-
action
|
|
22
|
-
} = e.data
|
|
23
|
-
if (action === 'worker-init') {
|
|
24
|
-
window.worker.removeEventListener('message', onInit)
|
|
25
|
-
resolve(1)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
window.worker.addEventListener('message', onInit)
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async function load () {
|
|
33
|
-
window.capitalizeFirstLetter = (string) => {
|
|
34
|
-
return string.charAt(0).toUpperCase() + string.slice(1)
|
|
35
|
-
}
|
|
36
|
-
function loadScript () {
|
|
37
|
-
const rcs = document.createElement('script')
|
|
38
|
-
const url = !isDev ? `js/electerm-${version}.js` : 'js/electerm.js'
|
|
39
|
-
rcs.src = url
|
|
40
|
-
rcs.type = 'module'
|
|
41
|
-
rcs.onload = () => {
|
|
42
|
-
const loadingEl = document.getElementById('content-loading')
|
|
43
|
-
if (loadingEl) {
|
|
44
|
-
document.body.removeChild(loadingEl)
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
document.body.appendChild(rcs)
|
|
48
|
-
}
|
|
49
|
-
window.getLang = (lang = window.store?.config.language || 'en_us') => {
|
|
50
|
-
return _get(window.langMap, `[${lang}].lang`)
|
|
51
|
-
}
|
|
52
|
-
window.translate = txt => {
|
|
53
|
-
const lang = window.getLang()
|
|
54
|
-
const str = _get(lang, `[${txt}]`) || txt
|
|
55
|
-
return window.capitalizeFirstLetter(str)
|
|
56
|
-
}
|
|
57
|
-
await loadWorker()
|
|
58
|
-
loadScript()
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// window.addEventListener('load', load)
|
|
62
|
-
load()
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createRoot } from 'react-dom/client'
|
|
2
|
-
import 'antd/dist/reset.css'
|
|
3
|
-
import '@fontsource/maple-mono/index.css'
|
|
4
|
-
import Main from '../components/main/index.jsx'
|
|
5
|
-
|
|
6
|
-
const rootElement = createRoot(document.getElementById('container'))
|
|
7
|
-
rootElement.render(
|
|
8
|
-
<Main />
|
|
9
|
-
)
|
package/client/entry/worker.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* web worker
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
self.insts = {}
|
|
6
|
-
|
|
7
|
-
function createWs (
|
|
8
|
-
type,
|
|
9
|
-
id,
|
|
10
|
-
sftpId = '',
|
|
11
|
-
config
|
|
12
|
-
) {
|
|
13
|
-
// init gloabl ws
|
|
14
|
-
const { host, port, tokenElecterm } = config
|
|
15
|
-
const wsUrl = `ws://${host}:${port}/${type}/${id}?&sftpId=${sftpId}&token=${tokenElecterm}`
|
|
16
|
-
const ws = new WebSocket(wsUrl)
|
|
17
|
-
ws.s = msg => {
|
|
18
|
-
try {
|
|
19
|
-
ws.send(JSON.stringify(msg))
|
|
20
|
-
} catch (e) {
|
|
21
|
-
console.error('ws send error', e)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
ws.id = id
|
|
25
|
-
ws.once = (callack, id) => {
|
|
26
|
-
const func = (evt) => {
|
|
27
|
-
const arg = JSON.parse(evt.data)
|
|
28
|
-
if (id === arg.id) {
|
|
29
|
-
callack(arg)
|
|
30
|
-
ws.removeEventListener('message', func)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
ws.addEventListener('message', func)
|
|
34
|
-
}
|
|
35
|
-
ws.onclose = () => {
|
|
36
|
-
if (ws.dup) {
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
send({
|
|
40
|
-
id: ws.id,
|
|
41
|
-
action: 'close'
|
|
42
|
-
})
|
|
43
|
-
delete self.insts[ws.id]
|
|
44
|
-
}
|
|
45
|
-
return new Promise((resolve) => {
|
|
46
|
-
ws.onopen = () => {
|
|
47
|
-
if (self.insts[ws.id]) {
|
|
48
|
-
ws.dup = true
|
|
49
|
-
ws.close()
|
|
50
|
-
resolve(null)
|
|
51
|
-
} else {
|
|
52
|
-
resolve(ws)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function send (data) {
|
|
59
|
-
self.postMessage(data)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function onMsg (e) {
|
|
63
|
-
const {
|
|
64
|
-
id,
|
|
65
|
-
wsId,
|
|
66
|
-
args,
|
|
67
|
-
action,
|
|
68
|
-
type,
|
|
69
|
-
persist
|
|
70
|
-
} = e.data
|
|
71
|
-
if (action === 'create') {
|
|
72
|
-
const inst = self.insts[id]
|
|
73
|
-
if (inst instanceof WebSocket) {
|
|
74
|
-
return send({
|
|
75
|
-
action,
|
|
76
|
-
id,
|
|
77
|
-
persist
|
|
78
|
-
}, '*')
|
|
79
|
-
} else if (inst) {
|
|
80
|
-
return false
|
|
81
|
-
} else {
|
|
82
|
-
const ws = await createWs(...args)
|
|
83
|
-
if (ws) {
|
|
84
|
-
self.insts[id] = ws
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
send({
|
|
88
|
-
action,
|
|
89
|
-
persist,
|
|
90
|
-
id
|
|
91
|
-
}, '*')
|
|
92
|
-
} else if (action === 'once') {
|
|
93
|
-
const ws = self.insts[wsId]
|
|
94
|
-
if (ws) {
|
|
95
|
-
const cb = (data) => {
|
|
96
|
-
send({
|
|
97
|
-
id,
|
|
98
|
-
wsId,
|
|
99
|
-
data
|
|
100
|
-
})
|
|
101
|
-
}
|
|
102
|
-
ws.once(cb, id)
|
|
103
|
-
}
|
|
104
|
-
} else if (action === 'close') {
|
|
105
|
-
const ws = self.insts[wsId]
|
|
106
|
-
if (ws) {
|
|
107
|
-
ws.close()
|
|
108
|
-
}
|
|
109
|
-
} else if (action === 's') {
|
|
110
|
-
const ws = self.insts[wsId]
|
|
111
|
-
if (ws) {
|
|
112
|
-
ws.s(...args)
|
|
113
|
-
}
|
|
114
|
-
} else if (action === 'addEventListener') {
|
|
115
|
-
const ws = self.insts[wsId]
|
|
116
|
-
if (ws) {
|
|
117
|
-
if (!ws.cbs) {
|
|
118
|
-
ws.cbs = {}
|
|
119
|
-
}
|
|
120
|
-
const cb = (e) => {
|
|
121
|
-
send({
|
|
122
|
-
wsId,
|
|
123
|
-
id,
|
|
124
|
-
data: {
|
|
125
|
-
data: e.data
|
|
126
|
-
}
|
|
127
|
-
})
|
|
128
|
-
}
|
|
129
|
-
ws.cbs[id] = cb
|
|
130
|
-
ws.addEventListener(type, cb)
|
|
131
|
-
}
|
|
132
|
-
} else if (action === 'removeEventListener') {
|
|
133
|
-
const ws = self.insts[wsId]
|
|
134
|
-
if (ws && ws.cbs && ws.cbs[id]) {
|
|
135
|
-
ws.removeEventListener(type, ws.cbs[id])
|
|
136
|
-
delete ws.cbs[id]
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
self.addEventListener('message', onMsg)
|
|
142
|
-
setTimeout(() => {
|
|
143
|
-
send({
|
|
144
|
-
action: 'worker-init'
|
|
145
|
-
})
|
|
146
|
-
}, 10)
|