@electerm/electerm-react 1.91.16 → 1.100.8

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.
@@ -67,5 +67,6 @@ export default {
67
67
  sessionLogPath: '',
68
68
  sshSftpSplitView: false,
69
69
  showCmdSuggestions: false,
70
- startDirectoryLocal: ''
70
+ startDirectoryLocal: '',
71
+ allowMultiInstance: false
71
72
  }
@@ -10,12 +10,13 @@ import initWs from './ws'
10
10
  const transferKeys = Object.keys(transferTypeMap)
11
11
 
12
12
  class Sftp {
13
- async init (terminalId) {
13
+ async init (terminalId, port) {
14
14
  const id = generate()
15
- const ws = await initWs('sftp', id, terminalId)
15
+ const ws = await initWs('sftp', id, terminalId, undefined, port)
16
16
  this.ws = ws
17
17
  this.id = id
18
18
  this.terminalId = terminalId
19
+ this.port = port
19
20
  ws.s({
20
21
  action: 'sftp-new',
21
22
  id,
@@ -32,7 +33,8 @@ class Sftp {
32
33
  isFtp: this.type === 'ftp',
33
34
  ...args[0],
34
35
  terminalId,
35
- type: func
36
+ type: func,
37
+ port
36
38
  })
37
39
  }
38
40
  const fid = generate()
@@ -71,9 +73,9 @@ class Sftp {
71
73
  }
72
74
  }
73
75
 
74
- export default async (terminalId, type = 'sftp') => {
76
+ export default async (terminalId, type = 'sftp', port) => {
75
77
  const sftp = new Sftp()
76
78
  sftp.type = type
77
- await sftp.init(terminalId)
79
+ await sftp.init(terminalId, port)
78
80
  return sftp
79
81
  }
@@ -19,9 +19,10 @@ class Transfer {
19
19
  const th = this
20
20
  const {
21
21
  sftpId,
22
- isFtp
22
+ isFtp,
23
+ port
23
24
  } = rest
24
- const ws = await initWs('transfer', id, sftpId)
25
+ const ws = await initWs('transfer', id, sftpId, undefined, port)
25
26
  ws.s({
26
27
  action: 'transfer-new',
27
28
  ...rest,
@@ -140,7 +140,17 @@ function onEvent (e) {
140
140
 
141
141
  window.worker.addEventListener('message', onEvent)
142
142
 
143
- export default (type, id, sftpId = '', persist) => {
143
+ export default (type, id, sftpId = '', persist, port) => {
144
+ const opts = pick(window.store.config, [
145
+ 'host',
146
+ 'port',
147
+ 'tokenElecterm',
148
+ 'server',
149
+ 'urlPath'
150
+ ])
151
+ if (port) {
152
+ opts.port = port
153
+ }
144
154
  return new Promise((resolve) => {
145
155
  send({
146
156
  id,
@@ -151,13 +161,7 @@ export default (type, id, sftpId = '', persist) => {
151
161
  type,
152
162
  id,
153
163
  sftpId,
154
- pick(window.store.config, [
155
- 'host',
156
- 'port',
157
- 'tokenElecterm',
158
- 'server',
159
- 'urlPath'
160
- ])
164
+ opts
161
165
  ]
162
166
  })
163
167
  onces[id] = {
@@ -27,8 +27,8 @@ const defaultRoles = [
27
27
  ]
28
28
 
29
29
  const proxyOptions = [
30
- { value: 'socks5://127.0.0.1:1080' },
31
- { value: 'http://127.0.0.1:8080' },
30
+ { value: 'socks5://localhost:1080' },
31
+ { value: 'http://localhost:8080' },
32
32
  { value: 'https://proxy.example.com:3128' }
33
33
  ]
34
34
 
@@ -180,7 +180,7 @@ export default function AIConfigForm ({ initialValues, onSubmit, showAIConfig })
180
180
  <Form.Item
181
181
  label={e('proxy')}
182
182
  name='proxyAI'
183
- tooltip='Proxy for AI API requests (e.g., socks5://127.0.0.1:1080)'
183
+ tooltip='Proxy for AI API requests (e.g., socks5://localhost:1080)'
184
184
  >
185
185
  <AutoComplete
186
186
  options={proxyOptions}
@@ -25,7 +25,7 @@ export default function renderProxy (props) {
25
25
  value: d
26
26
  }
27
27
  }),
28
- placeholder: 'socks5://127.0.0.1:1080',
28
+ placeholder: 'socks5://localhost:1080',
29
29
  allowClear: true
30
30
  }
31
31
  return (
@@ -29,9 +29,9 @@ export default function renderSshTunnels (props) {
29
29
  const [initialValues] = useState({
30
30
  sshTunnel: 'forwardRemoteToLocal',
31
31
  sshTunnelLocalPort: 12200,
32
- sshTunnelLocalHost: '127.0.0.1',
32
+ sshTunnelLocalHost: 'localhost',
33
33
  sshTunnelRemotePort: 12300,
34
- sshTunnelRemoteHost: '127.0.0.1'
34
+ sshTunnelRemoteHost: 'localhost'
35
35
  })
36
36
  const [isDynamic, setter] = useState(formData.sshTunnel === 'dynamicForward')
37
37
  const [list, setList] = useState(formData.sshTunnels || [])
@@ -85,9 +85,9 @@ export default function renderSshTunnels (props) {
85
85
  // sshTunnel is forwardRemoteToLocal or forwardLocalToRemote or dynamicForward
86
86
  const {
87
87
  sshTunnel,
88
- sshTunnelRemoteHost = '127.0.0.1',
88
+ sshTunnelRemoteHost = 'localhost',
89
89
  sshTunnelRemotePort = '',
90
- sshTunnelLocalHost = '127.0.0.1',
90
+ sshTunnelLocalHost = 'localhost',
91
91
  sshTunnelLocalPort = '',
92
92
  name
93
93
  } = item
@@ -63,7 +63,6 @@ export default class RdpSession extends PureComponent {
63
63
  const { config } = this.props
64
64
  const {
65
65
  host,
66
- port,
67
66
  tokenElecterm,
68
67
  server = ''
69
68
  } = config
@@ -76,24 +75,27 @@ export default class RdpSession extends PureComponent {
76
75
  const opts = clone({
77
76
  term: terminalType || config.terminalType,
78
77
  tabId: id,
78
+ uid: tab.id,
79
79
  srcTabId: tab.id,
80
80
  termType: type,
81
81
  ...tab
82
82
  })
83
- let pid = await createTerm(opts)
83
+ const r = await createTerm(opts)
84
84
  .catch(err => {
85
85
  const text = err.message
86
86
  handleErr({ message: text })
87
87
  })
88
- pid = pid || ''
89
88
  this.setState({
90
89
  loading: false
91
90
  })
92
- if (!pid) {
91
+ if (!r) {
93
92
  this.setStatus(statusMap.error)
94
93
  return
95
94
  }
96
95
  this.setStatus(statusMap.success)
96
+ const {
97
+ pid, port
98
+ } = r
97
99
  this.pid = pid
98
100
  const hs = server
99
101
  ? server.replace(/https?:\/\//, '')
@@ -434,7 +434,7 @@ export default class SettingCommon extends Component {
434
434
  />
435
435
  </div>
436
436
  {
437
- this.renderText('proxy', 'socks5://127.0.0.1:1080')
437
+ this.renderText('proxy', 'socks5://localhost:1080')
438
438
  }
439
439
  </div>
440
440
  )
@@ -669,6 +669,7 @@ export default class SettingCommon extends Component {
669
669
  'useSystemTitleBar',
670
670
  'confirmBeforeExit',
671
671
  'hideIP',
672
+ 'allowMultiInstance',
672
673
  'debug'
673
674
  ].map(this.renderToggle)
674
675
  }
@@ -51,7 +51,7 @@ export default function TerminalBackgroundConfig ({
51
51
  },
52
52
  {
53
53
  value: 'randomShape',
54
- desc: e('randomCats')
54
+ desc: e('randomShape')
55
55
  }
56
56
  )
57
57
  }
@@ -3,6 +3,7 @@ import { refs } from '../common/ref'
3
3
  import generate from '../../common/uid'
4
4
  import runIdle from '../../common/run-idle'
5
5
  import { Spin, Modal, notification } from 'antd'
6
+ import clone from '../../common/to-simple-obj'
6
7
  import { isEqual, last, isNumber, some, isArray, pick, uniq, debounce } from 'lodash-es'
7
8
  import FileSection from './file-item'
8
9
  import resolve from '../../common/resolve'
@@ -10,6 +11,7 @@ import wait from '../../common/wait'
10
11
  import isAbsPath from '../../common/is-absolute-path'
11
12
  import classnames from 'classnames'
12
13
  import sorterIndex from '../../common/index-sorter'
14
+ import { handleErr } from '../../common/fetch'
13
15
  import { getLocalFileInfo, getRemoteFileInfo, getFolderFromFilePath } from './file-read'
14
16
  import {
15
17
  typeMap, maxSftpHistory, paneMap,
@@ -29,6 +31,7 @@ import memoizeOne from 'memoize-one'
29
31
  import * as owner from './owner-list'
30
32
  import AddressBar from './address-bar'
31
33
  import getProxy from '../../common/get-proxy'
34
+ import { createTerm } from '../terminal/terminal-apis'
32
35
  import './sftp.styl'
33
36
 
34
37
  const e = window.translate
@@ -52,8 +55,7 @@ export default class Sftp extends Component {
52
55
  this.id = 'sftp-' + this.props.tab.id
53
56
  refs.add(this.id, this)
54
57
  if (this.props.isFtp) {
55
- this.type = 'ftp'
56
- this.initData()
58
+ this.initFtpData()
57
59
  }
58
60
  }
59
61
 
@@ -100,6 +102,31 @@ export default class Sftp extends Component {
100
102
  this.timer5 = null
101
103
  }
102
104
 
105
+ initFtpData = async () => {
106
+ this.type = 'ftp'
107
+ const { tab } = this.props
108
+ const { id } = tab
109
+ const opts = clone({
110
+ tabId: id,
111
+ uid: tab.id,
112
+ srcTabId: tab.id,
113
+ termType: 'ftp',
114
+ ...tab
115
+ })
116
+ const r = await createTerm(opts)
117
+ .catch(err => {
118
+ const text = err.message
119
+ handleErr({ message: text })
120
+ })
121
+ if (!r) {
122
+ return
123
+ }
124
+ const {
125
+ port
126
+ } = r
127
+ this.initData(undefined, port)
128
+ }
129
+
103
130
  directions = [
104
131
  'desc',
105
132
  'asc'
@@ -427,8 +454,9 @@ export default class Sftp extends Component {
427
454
  this[type + 'Dom'].onPaste()
428
455
  }
429
456
 
430
- initData = (terminalId) => {
457
+ initData = (terminalId, port) => {
431
458
  this.terminalId = terminalId
459
+ this.port = port
432
460
  if (this.shouldRenderRemote()) {
433
461
  this.initRemoteAll()
434
462
  }
@@ -592,7 +620,7 @@ export default class Sftp extends Component {
592
620
  let sftp = this.sftp
593
621
  try {
594
622
  if (!this.sftp) {
595
- sftp = await Client(this.terminalId, this.type)
623
+ sftp = await Client(this.terminalId, this.type, this.port)
596
624
  if (!sftp) {
597
625
  return
598
626
  }
@@ -350,10 +350,10 @@ class Tab extends Component {
350
350
  const list = sshTunnelResults.map(({ sshTunnel: obj, error }, i) => {
351
351
  const {
352
352
  sshTunnelLocalPort,
353
- sshTunnelRemoteHost = '127.0.0.1',
353
+ sshTunnelRemoteHost = 'localhost',
354
354
  sshTunnelRemotePort,
355
355
  sshTunnel,
356
- sshTunnelLocalHost = '127.0.0.1',
356
+ sshTunnelLocalHost = 'localhost',
357
357
  name
358
358
  } = obj
359
359
  let tunnel
@@ -63,14 +63,14 @@ export default class TermSearch extends PureComponent {
63
63
  }
64
64
  }
65
65
 
66
- prev = (v = this.props.termSearch) => {
66
+ prev = () => {
67
67
  const {
68
68
  activeTabId,
69
69
  termSearchOptions
70
70
  } = this.props
71
71
  refs.get('term-' + activeTabId)
72
72
  ?.searchPrev(
73
- v,
73
+ this.props.termSearch,
74
74
  copy(termSearchOptions)
75
75
  )
76
76
  }
@@ -1105,8 +1105,8 @@ clear\r`
1105
1105
  this.bufferMode = buf.type
1106
1106
  }
1107
1107
 
1108
- buildWsUrl = () => {
1109
- const { host, port, tokenElecterm } = this.props.config
1108
+ buildWsUrl = (port) => {
1109
+ const { host, tokenElecterm } = this.props.config
1110
1110
  const { id } = this.props.tab
1111
1111
  if (window.et.buildWsUrl) {
1112
1112
  return window.et.buildWsUrl(
@@ -1172,13 +1172,12 @@ clear\r`
1172
1172
  ? typeMap.remote
1173
1173
  : typeMap.local
1174
1174
  })
1175
- let r = await createTerm(opts)
1175
+ const r = await createTerm(opts)
1176
1176
  .catch(err => {
1177
1177
  const text = err.message
1178
1178
  handleErr({ message: text })
1179
1179
  })
1180
- r = r || ''
1181
- if (r.includes('fail')) {
1180
+ if (typeof r === 'string' && r.includes('fail')) {
1182
1181
  return this.promote()
1183
1182
  }
1184
1183
  if (savePassword) {
@@ -1191,11 +1190,12 @@ clear\r`
1191
1190
  this.setStatus(statusMap.error)
1192
1191
  return
1193
1192
  }
1193
+ this.port = r.port
1194
1194
  this.setStatus(statusMap.success)
1195
- refs.get('sftp-' + id)?.initData(id)
1195
+ refs.get('sftp-' + id)?.initData(id, r.port)
1196
1196
  term.pid = id
1197
1197
  this.pid = id
1198
- const wsUrl = this.buildWsUrl()
1198
+ const wsUrl = this.buildWsUrl(r.port)
1199
1199
  const socket = new WebSocket(wsUrl)
1200
1200
  socket.onclose = this.oncloseSocket
1201
1201
  socket.onerror = this.onerrorSocket
@@ -69,7 +69,6 @@ export default class VncSession extends RdpSession {
69
69
  const { config } = this.props
70
70
  const {
71
71
  host,
72
- port,
73
72
  tokenElecterm,
74
73
  server = ''
75
74
  } = config
@@ -86,25 +85,27 @@ export default class VncSession extends RdpSession {
86
85
  const opts = clone({
87
86
  term: terminalType || config.terminalType,
88
87
  tabId: id,
88
+ uid: tab.id,
89
89
  srcTabId: tab.id,
90
90
  termType: type,
91
91
  ...tab
92
92
  })
93
- let pid = await createTerm(opts)
93
+ const r = await createTerm(opts)
94
94
  .catch(err => {
95
95
  const text = err.message
96
96
  handleErr({ message: text })
97
97
  })
98
- pid = pid || ''
99
98
  this.setState({
100
99
  loading: false
101
100
  })
102
- if (!pid) {
101
+ if (!r) {
103
102
  this.setStatus(statusMap.error)
104
103
  return
105
104
  }
106
105
  this.setStatus(statusMap.success)
106
+ const { pid, port } = r
107
107
  this.pid = pid
108
+ this.port = port
108
109
  const hs = server
109
110
  ? server.replace(/https?:\/\//, '')
110
111
  : `${host}:${port}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "1.91.16",
3
+ "version": "1.100.8",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",