@electerm/electerm-react 3.5.6 → 3.6.6
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/ws.js +16 -5
- package/client/components/ai/ai-history.jsx +0 -6
- package/client/components/shortcuts/shortcut-control.jsx +9 -0
- package/client/components/shortcuts/shortcuts-defaults.js +5 -0
- package/client/components/ssh-config/load-ssh-configs.jsx +1 -1
- package/client/components/sys-menu/menu-btn.jsx +2 -1
- package/package.json +1 -1
package/client/common/ws.js
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import generate from './uid'
|
|
6
6
|
import wait from './wait'
|
|
7
|
-
import copy from 'json-deep-copy'
|
|
8
7
|
import { pick } from 'lodash-es'
|
|
9
8
|
|
|
10
9
|
const onces = {}
|
|
@@ -32,7 +31,13 @@ class Ws {
|
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
async once (func, id) {
|
|
34
|
+
const maxWait = 300
|
|
35
|
+
let waited = 0
|
|
35
36
|
while (this.closed) {
|
|
37
|
+
if (++waited >= maxWait) {
|
|
38
|
+
console.warn('ws once timeout waiting for reconnection', id)
|
|
39
|
+
return
|
|
40
|
+
}
|
|
36
41
|
await wait(100)
|
|
37
42
|
}
|
|
38
43
|
this.onceIds.push(id)
|
|
@@ -83,7 +88,7 @@ class Ws {
|
|
|
83
88
|
if (this.eid) {
|
|
84
89
|
delete persists[this.eid]
|
|
85
90
|
}
|
|
86
|
-
const ids =
|
|
91
|
+
const ids = [...this.onceIds]
|
|
87
92
|
ids.forEach(k => {
|
|
88
93
|
delete onces[k]
|
|
89
94
|
})
|
|
@@ -115,10 +120,16 @@ function onEvent (e) {
|
|
|
115
120
|
action,
|
|
116
121
|
persist
|
|
117
122
|
} = e.data
|
|
118
|
-
if (wss[id]) {
|
|
119
|
-
|
|
120
|
-
|
|
123
|
+
if (wss[id] && action === 'close') {
|
|
124
|
+
const ws = wss[id]
|
|
125
|
+
ws.onclose()
|
|
126
|
+
if (ws.persist) {
|
|
127
|
+
ws.closed = true
|
|
128
|
+
} else {
|
|
129
|
+
ws.clearOnces()
|
|
130
|
+
delete wss[id]
|
|
121
131
|
}
|
|
132
|
+
return
|
|
122
133
|
}
|
|
123
134
|
if (persists[id]) {
|
|
124
135
|
persists[id].resolve(data)
|
|
@@ -3,12 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useState, useEffect } from 'react'
|
|
5
5
|
import { Space } from 'antd'
|
|
6
|
-
import { HistoryOutlined } from '@ant-design/icons'
|
|
7
6
|
import { safeGetItemJSON, safeSetItemJSON } from '../../common/safe-local-storage'
|
|
8
7
|
import AiHistoryItem from './ai-history-item'
|
|
9
8
|
|
|
10
9
|
const MAX_HISTORY = 20
|
|
11
|
-
const e = window.translate
|
|
12
10
|
|
|
13
11
|
export function getHistory (storageKey) {
|
|
14
12
|
return safeGetItemJSON(storageKey, [])
|
|
@@ -81,10 +79,6 @@ export default function AiHistory (props) {
|
|
|
81
79
|
|
|
82
80
|
return (
|
|
83
81
|
<div className='ai-bookmark-history pd1b'>
|
|
84
|
-
<div className='pd1b text-muted'>
|
|
85
|
-
<HistoryOutlined className='mg1r' />
|
|
86
|
-
<span className='mg1r'>{e('history') || 'History'}:</span>
|
|
87
|
-
</div>
|
|
88
82
|
<Space size={[8, 8]} wrap>
|
|
89
83
|
{history.map((item, index) => {
|
|
90
84
|
const keyStr = typeof item === 'string' ? item : JSON.stringify(item)
|
|
@@ -172,6 +172,15 @@ class ShortcutControl extends React.PureComponent {
|
|
|
172
172
|
window.store.onNewSsh()
|
|
173
173
|
}, 500)
|
|
174
174
|
|
|
175
|
+
newTabShortcut = throttle((e) => {
|
|
176
|
+
e.stopPropagation()
|
|
177
|
+
if (window.store.hasNodePty) {
|
|
178
|
+
window.store.addTab()
|
|
179
|
+
} else {
|
|
180
|
+
window.store.onNewSsh()
|
|
181
|
+
}
|
|
182
|
+
}, 500)
|
|
183
|
+
|
|
175
184
|
toggleAddBtnShortcut = throttle((e) => {
|
|
176
185
|
e.stopPropagation()
|
|
177
186
|
const { currentLayoutBatch } = window.store
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Modal,
|
|
3
2
|
Spin,
|
|
4
3
|
Button,
|
|
5
4
|
Empty
|
|
@@ -9,6 +8,7 @@ import * as ls from '../../common/safe-local-storage'
|
|
|
9
8
|
import {
|
|
10
9
|
sshConfigLoadKey
|
|
11
10
|
} from '../../common/constants'
|
|
11
|
+
import Modal from '../common/modal'
|
|
12
12
|
import { ReloadOutlined } from '@ant-design/icons'
|
|
13
13
|
import LoadSshConfigsItem from './load-ssh-configs-item'
|
|
14
14
|
import './ssh-config.styl'
|