@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.
@@ -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 = copy(this.onceIds)
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
- if (action === 'close') {
120
- wss[id].close && wss[id].close()
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
@@ -36,6 +36,11 @@ export default () => {
36
36
  shortcut: 'ctrl+n',
37
37
  shortcutMac: 'meta+n'
38
38
  },
39
+ {
40
+ name: 'app_newTab',
41
+ shortcut: 'alt+q',
42
+ shortcutMac: 'alt+q'
43
+ },
39
44
  {
40
45
  name: 'app_toggleAddBtn',
41
46
  shortcut: 'alt+n',
@@ -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'
@@ -76,7 +76,8 @@ class MenuBtn extends PureComponent {
76
76
  items.push({
77
77
  func: 'addTab',
78
78
  icon: 'RightSquareFilled',
79
- text: e('newTab')
79
+ text: e('newTab'),
80
+ subText: this.getShortcut('app_newTab')
80
81
  })
81
82
  }
82
83
  // {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "3.5.6",
3
+ "version": "3.6.6",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",