@electerm/electerm-react 1.39.88 → 1.39.99

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.
Files changed (101) hide show
  1. package/client/common/constants.js +2 -1
  2. package/client/common/create-title.jsx +2 -3
  3. package/client/common/init-setting-item.js +3 -6
  4. package/client/common/new-terminal.js +1 -2
  5. package/client/common/terminal-theme.js +2 -3
  6. package/client/components/auth/login.jsx +2 -3
  7. package/client/components/batch-op/batch-op.jsx +18 -36
  8. package/client/components/bookmark-form/form-ssh-common.jsx +4 -7
  9. package/client/components/bookmark-form/form-tabs.jsx +4 -8
  10. package/client/components/bookmark-form/index.jsx +5 -9
  11. package/client/components/bookmark-form/local-form-ui.jsx +3 -6
  12. package/client/components/bookmark-form/proxy.jsx +1 -2
  13. package/client/components/bookmark-form/quick-command.jsx +7 -8
  14. package/client/components/bookmark-form/rdp-form-ui.jsx +2 -4
  15. package/client/components/bookmark-form/render-auth-ssh.jsx +1 -2
  16. package/client/components/bookmark-form/render-connection-hopping.jsx +9 -11
  17. package/client/components/bookmark-form/render-delayed-scripts.jsx +1 -2
  18. package/client/components/bookmark-form/render-ssh-tunnel.jsx +9 -12
  19. package/client/components/bookmark-form/serial-form-ui.jsx +4 -8
  20. package/client/components/bookmark-form/sftp-enable.jsx +1 -2
  21. package/client/components/bookmark-form/telnet-form-ui.jsx +2 -4
  22. package/client/components/bookmark-form/tree-delete.jsx +3 -4
  23. package/client/components/bookmark-form/use-quick-commands.jsx +5 -6
  24. package/client/components/bookmark-form/use-submit.jsx +1 -2
  25. package/client/components/bookmark-form/use-ui.jsx +4 -6
  26. package/client/components/bookmark-form/vnc-form-ui.jsx +2 -4
  27. package/client/components/bookmark-form/web-form-ui.jsx +2 -4
  28. package/client/components/common/markdown.jsx +1 -1
  29. package/client/components/context-menu/context-menu.jsx +3 -4
  30. package/client/components/context-menu/menu-btn.jsx +13 -18
  31. package/client/components/footer/batch-input.jsx +1 -2
  32. package/client/components/footer/footer-entry.jsx +2 -3
  33. package/client/components/main/error-wrapper.jsx +2 -4
  34. package/client/components/main/upgrade.jsx +2 -4
  35. package/client/components/main/upgrade.styl +4 -1
  36. package/client/components/profile/profile-form-elem.jsx +28 -10
  37. package/client/components/quick-commands/quick-commands-box.jsx +1 -2
  38. package/client/components/quick-commands/quick-commands-form-elem.jsx +7 -12
  39. package/client/components/quick-commands/quick-commands-list-form.jsx +5 -6
  40. package/client/components/quick-commands/quick-commands-list.jsx +2 -3
  41. package/client/components/quick-commands/quick-commands-select.jsx +1 -2
  42. package/client/components/rdp/rdp-session.jsx +0 -3
  43. package/client/components/rdp/resolution-form.jsx +3 -6
  44. package/client/components/session/session.jsx +2 -4
  45. package/client/components/session/sessions.jsx +4 -6
  46. package/client/components/setting-panel/keywords-form.jsx +2 -3
  47. package/client/components/setting-panel/list.jsx +3 -6
  48. package/client/components/setting-panel/setting-common.jsx +10 -14
  49. package/client/components/setting-panel/setting-modal.jsx +7 -11
  50. package/client/components/setting-panel/setting-terminal.jsx +13 -16
  51. package/client/components/setting-panel/start-session-select.jsx +1 -2
  52. package/client/components/setting-panel/tab-history.jsx +2 -3
  53. package/client/components/setting-sync/data-import.jsx +4 -7
  54. package/client/components/setting-sync/data-select.jsx +4 -16
  55. package/client/components/setting-sync/setting-sync-form.jsx +8 -12
  56. package/client/components/sftp/address-bar.jsx +1 -2
  57. package/client/components/sftp/confirm-modal-store.jsx +1 -2
  58. package/client/components/sftp/file-item.jsx +6 -8
  59. package/client/components/sftp/file-mode-modal.jsx +1 -2
  60. package/client/components/sftp/file-props-modal.jsx +1 -2
  61. package/client/components/sftp/list-table-ui.jsx +1 -2
  62. package/client/components/sftp/permission-render.jsx +1 -2
  63. package/client/components/sftp/sftp-entry.jsx +21 -7
  64. package/client/components/sftp/transfer-tag.jsx +1 -2
  65. package/client/components/shortcuts/shortcuts.jsx +5 -28
  66. package/client/components/sidebar/bookmark.jsx +6 -9
  67. package/client/components/sidebar/history.jsx +4 -6
  68. package/client/components/sidebar/index.jsx +9 -16
  69. package/client/components/sidebar/info-modal.jsx +10 -15
  70. package/client/components/sidebar/transfer-history-modal.jsx +3 -6
  71. package/client/components/sidebar/transfer-list-control.jsx +1 -2
  72. package/client/components/sidebar/transfer-list.jsx +1 -2
  73. package/client/components/sidebar/transfer-modal.jsx +2 -4
  74. package/client/components/sidebar/transport-ui.jsx +1 -2
  75. package/client/components/tabs/index.jsx +28 -20
  76. package/client/components/tabs/tab.jsx +5 -9
  77. package/client/components/tabs/window-control.jsx +4 -5
  78. package/client/components/terminal/index.jsx +5 -7
  79. package/client/components/terminal/term-search.jsx +2 -3
  80. package/client/components/terminal/terminal-interactive.jsx +2 -4
  81. package/client/components/terminal-info/activity.jsx +4 -5
  82. package/client/components/terminal-info/base.jsx +3 -4
  83. package/client/components/terminal-info/terminal-info.styl +1 -0
  84. package/client/components/terminal-theme/index.jsx +6 -9
  85. package/client/components/terminal-theme/theme-list.jsx +1 -2
  86. package/client/components/text-editor/text-editor-form.jsx +4 -8
  87. package/client/components/text-editor/text-editor.jsx +2 -3
  88. package/client/components/tree-list/bookmark-transport.jsx +4 -7
  89. package/client/components/tree-list/tree-list-item.jsx +4 -7
  90. package/client/components/tree-list/tree-list.jsx +3 -6
  91. package/client/components/vnc/vnc-form.jsx +2 -4
  92. package/client/components/vnc/vnc-session.jsx +1 -2
  93. package/client/entry/basic.js +4 -6
  94. package/client/store/common.js +10 -12
  95. package/client/store/index.js +4 -7
  96. package/client/store/init-state.js +2 -3
  97. package/client/store/load-data.js +10 -0
  98. package/client/store/setting.js +2 -3
  99. package/client/store/system-menu.js +4 -6
  100. package/client/store/terminal-theme.js +2 -4
  101. package/package.json +1 -1
@@ -22,8 +22,7 @@ import postMsg from '../../common/post-msg'
22
22
  import { filesize } from 'filesize'
23
23
  import { runCmd } from '../terminal/terminal-apis'
24
24
 
25
- const { prefix } = window
26
- const e = prefix('sftp')
25
+ const e = window.translate
27
26
  const formatTime = time
28
27
 
29
28
  export default function FileInfoModal () {
@@ -29,8 +29,7 @@ import {
29
29
  } from '@ant-design/icons'
30
30
  import IconHolder from '../context-menu/icon-holder'
31
31
 
32
- const { prefix } = window
33
- const e = prefix('sftp')
32
+ const e = window.translate
34
33
 
35
34
  export default class FileListTable extends Component {
36
35
  constructor (props) {
@@ -5,8 +5,7 @@
5
5
  import { Button, Space } from 'antd'
6
6
  import { isFunction, noop } from 'lodash-es'
7
7
 
8
- const { prefix } = window
9
- const e = prefix('permission')
8
+ const e = window.translate
10
9
 
11
10
  export default (perm, _onClick) => {
12
11
  const {
@@ -36,9 +36,7 @@ import AddressBar from './address-bar'
36
36
  import getProxy from '../../common/get-proxy'
37
37
  import './sftp.styl'
38
38
 
39
- const { prefix } = window
40
- const e = prefix('sftp')
41
- const c = prefix('common')
39
+ const e = window.translate
42
40
 
43
41
  const buildTree = arr => {
44
42
  return arr.reduce((prev, curr) => {
@@ -390,8 +388,8 @@ export default class Sftp extends Component {
390
388
  onDel = (type, files) => {
391
389
  this.onDelete = true
392
390
  Modal.confirm({
393
- cancelText: c('cancel'),
394
- okText: c('ok'),
391
+ cancelText: e('cancel'),
392
+ okText: e('ok'),
395
393
  title: this.renderDelConfirmTitle(files),
396
394
  onOk: () => this.delFiles(type, files)
397
395
  })
@@ -845,6 +843,22 @@ export default class Sftp extends Component {
845
843
  }, () => this[`${type}List`](undefined, undefined, oldPath))
846
844
  }
847
845
 
846
+ parsePath = (type, pth) => {
847
+ const reg = /^%([^%]+)%/
848
+ if (!reg.test(pth)) {
849
+ return pth
850
+ }
851
+ const m = pth.match(reg)
852
+ if (!m || !m[1]) {
853
+ return pth
854
+ }
855
+ const envName = m[1]
856
+ const envPath = window.pre.env[envName]
857
+ if (envPath) {
858
+ return pth.replace(reg, envPath)
859
+ }
860
+ }
861
+
848
862
  onGoto = (type, e) => {
849
863
  e && e.preventDefault()
850
864
  if (type === typeMap.remote && !this.sftp) {
@@ -853,14 +867,14 @@ export default class Sftp extends Component {
853
867
  const n = `${type}Path`
854
868
  const nt = n + 'Temp'
855
869
  const oldPath = this.state[type + 'Path']
856
- const np = this.state[nt]
870
+ const np = this.parsePath(type, this.state[nt])
857
871
  if (!isValidPath(np)) {
858
872
  return notification.warning({
859
873
  message: 'path not valid'
860
874
  })
861
875
  }
862
876
  this.setState({
863
- [n]: this.state[nt]
877
+ [n]: np
864
878
  }, () => this[`${type}List`](undefined, undefined, oldPath))
865
879
  }
866
880
 
@@ -4,8 +4,7 @@
4
4
  */
5
5
 
6
6
  import './transfer-tag.styl'
7
- const { prefix } = window
8
- const e = prefix('sftp')
7
+ const e = window.translate
9
8
 
10
9
  export default function TransferTag (props) {
11
10
  const {
@@ -10,12 +10,7 @@ import {
10
10
  isMacJs as isMac
11
11
  } from '../../common/constants.js'
12
12
 
13
- const { prefix } = window
14
- const e = prefix('form')
15
- const c = prefix('control')
16
- const m = prefix('menu')
17
- const ss = prefix('ssh')
18
- const s = prefix('setting')
13
+ const e = window.translate
19
14
  const shortcutsDefaults = shortcutsDefaultsGen()
20
15
 
21
16
  export default class Shortcuts extends Component {
@@ -105,30 +100,12 @@ export default class Shortcuts extends Component {
105
100
  key: 'name',
106
101
  render: (name) => {
107
102
  const [a, b] = name.split('_')
108
- const pre = a === 'terminal' ? `[${ss('terminal')}] ` : ''
109
- if (
110
- [
111
- 'clear', 'selectAll', 'search', 'split'
112
- ].includes(b)
113
- ) {
114
- return pre + ss(b)
115
- } else if (b === 'copy') {
116
- return pre + m(b)
117
- } else if (b === 'newBookmark') {
118
- return pre + c(b)
119
- } else if (b.includes('zoomin')) {
120
- return pre + m('zoomin')
121
- } else if (b.includes('zoomout')) {
122
- return pre + m('zoomout')
123
- } else if (['togglefullscreen'].includes(b)) {
124
- return pre + m(b)
125
- } else {
126
- return pre + s(b)
127
- }
103
+ const pre = a === 'terminal' ? `[${e('terminal')}] ` : ''
104
+ return pre + e(b)
128
105
  }
129
106
  },
130
107
  {
131
- title: s('settingShortcuts'),
108
+ title: e('settingShortcuts'),
132
109
  dataIndex: 'shortcut',
133
110
  key: 'shortcut',
134
111
  render: (shortcut, inst) => {
@@ -174,7 +151,7 @@ export default class Shortcuts extends Component {
174
151
  <Button
175
152
  onClick={this.handleResetAll}
176
153
  >
177
- {s('resetAllToDefault')}
154
+ {e('resetAllToDefault')}
178
155
  </Button>
179
156
  </div>
180
157
  </div>
@@ -8,10 +8,7 @@ import { pick } from 'lodash-es'
8
8
  import { ArrowsAltOutlined, EditOutlined, PlusCircleOutlined, ShrinkOutlined, PushpinOutlined } from '@ant-design/icons'
9
9
  import { Tooltip } from 'antd'
10
10
 
11
- const { prefix } = window
12
- const c = prefix('common')
13
- const m = prefix('menu')
14
- const e = prefix('control')
11
+ const e = window.translate
15
12
 
16
13
  export default class BookmarkPanel extends Component {
17
14
  render () {
@@ -42,29 +39,29 @@ export default class BookmarkPanel extends Component {
42
39
  >
43
40
  <div className='pd1y pd2t pd2x'>
44
41
  <div className='fix'>
45
- <div className='fleft'>{c('bookmarks')}</div>
42
+ <div className='fleft'>{e('bookmarks')}</div>
46
43
  <div className='fright'>
47
44
  <Tooltip title={e('newBookmark')}>
48
45
  <PlusCircleOutlined
49
46
  {...pop1}
50
47
  />
51
48
  </Tooltip>
52
- <Tooltip title={`${m('edit')} ${c('bookmarks')}`}>
49
+ <Tooltip title={`${e('edit')} ${e('bookmarks')}`}>
53
50
  <EditOutlined
54
51
  {...pop1}
55
52
  />
56
53
  </Tooltip>
57
- <Tooltip title={c('expandAll')}>
54
+ <Tooltip title={e('expandAll')}>
58
55
  <ArrowsAltOutlined
59
56
  {...pop2}
60
57
  />
61
58
  </Tooltip>
62
- <Tooltip title={c('collapseAll')}>
59
+ <Tooltip title={e('collapseAll')}>
63
60
  <ShrinkOutlined
64
61
  {...pop3}
65
62
  />
66
63
  </Tooltip>
67
- <Tooltip title={c('pin')}>
64
+ <Tooltip title={e('pin')}>
68
65
  <PushpinOutlined
69
66
  {...prps1}
70
67
  onClick={store.handlePin}
@@ -8,9 +8,7 @@ import { pick } from 'lodash-es'
8
8
  import { EditOutlined, PushpinOutlined } from '@ant-design/icons'
9
9
  import { Tooltip } from 'antd'
10
10
 
11
- const { prefix } = window
12
- const c = prefix('common')
13
- const m = prefix('menu')
11
+ const e = window.translate
14
12
 
15
13
  export default class HistoryPanel extends Component {
16
14
  render () {
@@ -35,15 +33,15 @@ export default class HistoryPanel extends Component {
35
33
  >
36
34
  <div className='pd1y pd2t pd2x'>
37
35
  <div className='fix'>
38
- <div className='fleft'>{c('history')}</div>
36
+ <div className='fleft'>{e('history')}</div>
39
37
  <div className='fleft'>
40
- <Tooltip title={`${m('edit')} ${c('history')}`}>
38
+ <Tooltip title={`${e('edit')} ${e('history')}`}>
41
39
  <EditOutlined
42
40
  className='font16 mg1x mg2l pointer iblock control-icon icon-do-edit'
43
41
  onClick={store.handleEditHistory}
44
42
  />
45
43
  </Tooltip>
46
- <Tooltip title={c('pin')}>
44
+ <Tooltip title={e('pin')}>
47
45
  <PushpinOutlined
48
46
  {...prps1}
49
47
  onClick={store.handlePin}
@@ -26,14 +26,7 @@ import SideIcon from './side-icon'
26
26
  import SidePanel from './side-panel'
27
27
  import './sidebar.styl'
28
28
 
29
- const { prefix } = window
30
- const e = prefix('control')
31
- const c = prefix('common')
32
- const m = prefix('menu')
33
- const t = prefix('terminalThemes')
34
- const u = prefix('updater')
35
- const ss = prefix('settingSync')
36
- const b = prefix('batchOp')
29
+ const e = window.translate
37
30
 
38
31
  export default class Sidebar extends Component {
39
32
  handler = null
@@ -141,7 +134,7 @@ export default class Sidebar extends Component {
141
134
  />
142
135
  </SideIcon>
143
136
  <SideIcon
144
- title={c(settingMap.bookmarks)}
137
+ title={e(settingMap.bookmarks)}
145
138
  active={bookmarksActive}
146
139
  >
147
140
  <BookOutlined
@@ -152,7 +145,7 @@ export default class Sidebar extends Component {
152
145
  />
153
146
  </SideIcon>
154
147
  <SideIcon
155
- title={c(settingMap.history)}
148
+ title={e(settingMap.history)}
156
149
  active={historyActive}
157
150
  >
158
151
  <ClockCircleOutlined
@@ -164,7 +157,7 @@ export default class Sidebar extends Component {
164
157
  </SideIcon>
165
158
  <TransferList store={store} />
166
159
  <SideIcon
167
- title={t(settingMap.terminalThemes)}
160
+ title={e(settingMap.terminalThemes)}
168
161
  active={themeActive}
169
162
  >
170
163
  <PictureOutlined
@@ -173,13 +166,13 @@ export default class Sidebar extends Component {
173
166
  />
174
167
  </SideIcon>
175
168
  <SideIcon
176
- title={c(settingMap.setting)}
169
+ title={e(settingMap.setting)}
177
170
  active={settingActive}
178
171
  >
179
172
  <SettingOutlined className='iblock font20 control-icon' onClick={openSetting} />
180
173
  </SideIcon>
181
174
  <SideIcon
182
- title={ss('settingSync')}
175
+ title={e('settingSync')}
183
176
  active={syncActive}
184
177
  >
185
178
  <CloudSyncOutlined
@@ -189,13 +182,13 @@ export default class Sidebar extends Component {
189
182
  />
190
183
  </SideIcon>
191
184
  <SideIcon
192
- title={b('batchOp')}
185
+ title={e('batchOp')}
193
186
  active={showBatchOp}
194
187
  >
195
188
  <BarsOutlined className='iblock font20 control-icon' onClick={toggleBatchOp} />
196
189
  </SideIcon>
197
190
  <SideIcon
198
- title={m('about')}
191
+ title={e('about')}
199
192
  active={showInfoModal}
200
193
  >
201
194
  <InfoCircleOutlined
@@ -207,7 +200,7 @@ export default class Sidebar extends Component {
207
200
  !checkingRemoteVersion && !showUpgradeModal && shouldUpgrade
208
201
  ? (
209
202
  <Tooltip
210
- title={`${u('upgrading')} ${upgradePercent || 0}%`}
203
+ title={`${e('upgrading')} ${upgradePercent || 0}%`}
211
204
  placement='right'
212
205
  >
213
206
  <div
@@ -22,12 +22,7 @@ import {
22
22
  } from '../../common/constants'
23
23
  import './info.styl'
24
24
 
25
- const { prefix } = window
26
- const e = prefix('control')
27
- const m = prefix('menu')
28
- const c = prefix('common')
29
- const a = prefix('app')
30
- const s = prefix('setting')
25
+ const e = window.translate
31
26
 
32
27
  export default class InfoModal extends Component {
33
28
  handleChangeTab = key => {
@@ -103,14 +98,14 @@ export default class InfoModal extends Component {
103
98
  }
104
99
  const title = (
105
100
  <div className='ant-modal-confirm-title font16'>
106
- <InfoCircleOutlined className='font20 mg1r' /> {m('about')} {name}
101
+ <InfoCircleOutlined className='font20 mg1r' /> {e('about')} {name}
107
102
  </div>
108
103
  )
109
104
  const attrs = {
110
105
  title,
111
106
  width: window.innerWidth - 100,
112
107
  maskClosable: true,
113
- okText: c('ok'),
108
+ okText: e('ok'),
114
109
  onCancel: onCloseAbout,
115
110
  footer: null,
116
111
  open: true,
@@ -119,11 +114,11 @@ export default class InfoModal extends Component {
119
114
  const items = [
120
115
  {
121
116
  key: infoTabs.info,
122
- label: m('about'),
117
+ label: e('about'),
123
118
  children: (
124
119
  <div>
125
120
  <LogoElem />
126
- <p className='mg2b'>{a('desc')}</p>
121
+ <p className='mg2b'>{e('desc')}</p>
127
122
  <p className='mg1b'>
128
123
  <UserOutlined /> <b className='mg1r'>{e('author')} ➾</b>
129
124
  <Link to={authorUrl} className='mg1l'>
@@ -143,7 +138,7 @@ export default class InfoModal extends Component {
143
138
  </Link>
144
139
  </p>
145
140
  <p className='mg1b'>
146
- <GlobalOutlined /> <b className='mg1r'>{s('language')} repo ➾</b>
141
+ <GlobalOutlined /> <b className='mg1r'>{e('language')} repo ➾</b>
147
142
  <Link to={langugeRepo} className='mg1l'>
148
143
  {langugeRepo}
149
144
  </Link>
@@ -155,25 +150,25 @@ export default class InfoModal extends Component {
155
150
  </Link>
156
151
  </p>
157
152
  <p className='mg1b'>
158
- <HighlightOutlined /> <b className='mg1r'>{a('changeLog')} ➾</b>
153
+ <HighlightOutlined /> <b className='mg1r'>{e('changeLog')} ➾</b>
159
154
  <Link to={releaseLink} className='mg1l'>
160
155
  {releaseLink}
161
156
  </Link>
162
157
  </p>
163
158
  <p className='mg1b'>
164
- <AlignLeftOutlined /> <b className='mg1r'>{a('knownIssues')} ➾</b>
159
+ <AlignLeftOutlined /> <b className='mg1r'>{e('knownIssues')} ➾</b>
165
160
  <Link to={knownIssuesLink} className='mg1l'>
166
161
  {knownIssuesLink}
167
162
  </Link>
168
163
  </p>
169
164
  <p className='mg1b'>
170
- <WarningOutlined /> <b className='mg1r'>{a('privacyNotice')} ➾</b>
165
+ <WarningOutlined /> <b className='mg1r'>{e('privacyNotice')} ➾</b>
171
166
  <Link to={privacyNoticeLink} className='mg1l'>
172
167
  {privacyNoticeLink}
173
168
  </Link>
174
169
  </p>
175
170
  <p className='mg1b'>
176
- <HeartOutlined /> <b className='mg1r'>{a('sponsorElecterm')} ➾</b>
171
+ <HeartOutlined /> <b className='mg1r'>{e('sponsorElecterm')} ➾</b>
177
172
  <Link to={sponsorLink} className='mg1l'>
178
173
  {sponsorLink}
179
174
  </Link>
@@ -11,10 +11,7 @@ import './transfer-history.styl'
11
11
  import { get as _get } from 'lodash-es'
12
12
  import { filesize } from 'filesize'
13
13
 
14
- const { prefix } = window
15
- const e = prefix('transferHistory')
16
- const f = prefix('sftp')
17
- const m = prefix('menu')
14
+ const e = window.translate
18
15
  const timeRender = t => time(t)
19
16
  const sorterFactory = prop => {
20
17
  return (a, b) => {
@@ -59,7 +56,7 @@ export default class TransferHistoryModal extends Component {
59
56
  )
60
57
  }
61
58
  }, {
62
- title: m('host'),
59
+ title: e('host'),
63
60
  dataIndex: 'host',
64
61
  key: 'host',
65
62
  sorter: sorterFactory('host')
@@ -80,7 +77,7 @@ export default class TransferHistoryModal extends Component {
80
77
  },
81
78
  sorter: sorterFactory('toPath')
82
79
  }, {
83
- title: f('size'),
80
+ title: e('size'),
84
81
  dataIndex: 'size',
85
82
  key: 'size',
86
83
  sorter: sorterFactory('size'),
@@ -11,8 +11,7 @@ import { get } from 'lodash-es'
11
11
 
12
12
  const { Option } = Select
13
13
 
14
- const { prefix } = window
15
- const e = prefix('sftp')
14
+ const e = window.translate
16
15
 
17
16
  export default class TransferModalUI extends Component {
18
17
  state = {
@@ -9,8 +9,7 @@ import {
9
9
  import TransferModal from './transfer-modal'
10
10
  import './transfer.styl'
11
11
 
12
- const { prefix } = window
13
- const e = prefix('sftp')
12
+ const e = window.translate
14
13
 
15
14
  export default class TransferList extends Component {
16
15
  render () {
@@ -5,9 +5,7 @@ import {
5
5
  import Transports from './transfer-list-control'
6
6
  import TransportHistory from './transfer-history-modal'
7
7
 
8
- const { prefix } = window
9
- const e = prefix('sftp')
10
- const t = prefix('transferHistory')
8
+ const e = window.translate
11
9
 
12
10
  export default class TransferModal extends Component {
13
11
  renderTransfer = () => {
@@ -46,7 +44,7 @@ export default class TransferModal extends Component {
46
44
  }
47
45
  if (transferHistory.length) {
48
46
  tabs.push({
49
- title: t('transferHistory'),
47
+ title: e('transferHistory'),
50
48
  id: 'history',
51
49
  render: this.renderHistory
52
50
  })
@@ -10,8 +10,7 @@ import {
10
10
  } from '@ant-design/icons'
11
11
  import './transfer.styl'
12
12
 
13
- const { prefix } = window
14
- const e = prefix('sftp')
13
+ const e = window.translate
15
14
 
16
15
  export default function Transporter (props) {
17
16
  const {
@@ -31,16 +31,16 @@ import BookmarksList from '../sidebar/bookmark-select'
31
31
  import AppDrag from './app-drag'
32
32
  import classNames from 'classnames'
33
33
 
34
- const { prefix } = window
35
- const e = prefix('tabs')
36
- const c = prefix('control')
37
- const t = prefix('tabs')
34
+ const e = window.translate
38
35
  const MenuItem = Menu.Item
39
36
 
40
37
  export default class Tabs extends React.Component {
41
38
  constructor (props) {
42
39
  super(props)
43
40
  this.tabsRef = React.createRef()
41
+ this.state = {
42
+ overflow: false
43
+ }
44
44
  }
45
45
 
46
46
  componentDidMount () {
@@ -53,11 +53,10 @@ export default class Tabs extends React.Component {
53
53
  }
54
54
 
55
55
  componentDidUpdate (prevProps) {
56
- prevProps = prevProps || {}
57
56
  if (
58
57
  prevProps.currentTabId !== this.props.currentTabId ||
59
58
  prevProps.width !== this.props.width ||
60
- prevProps.tabs.map(d => d.title).join('#') !== this.props.tabs.map(d => d.title).join('#')
59
+ prevProps.tabs.length !== this.props.tabs.length
61
60
  ) {
62
61
  this.adjustScroll()
63
62
  }
@@ -72,12 +71,17 @@ export default class Tabs extends React.Component {
72
71
  }
73
72
 
74
73
  isOverflow = () => {
75
- const { tabs = [], width } = this.props
74
+ const { tabs = [] } = this.props
76
75
  const len = tabs.length
77
76
  const addBtnWidth = 22
78
- const tabsWidth = this.tabsWidth()
79
- const tabsWidthAll = tabMargin * len + 166 + tabsWidth
80
- return width < (tabsWidthAll + addBtnWidth)
77
+ const tabsWidth = this.tabsWidth() + tabMargin * len + addBtnWidth
78
+ const tabsInnerWidth = this.getInnerWidth()
79
+ return tabsWidth > tabsInnerWidth
80
+ }
81
+
82
+ getInnerWidth = () => {
83
+ const inner = document.querySelector('.tabs-inner')
84
+ return inner ? inner.clientWidth : 0
81
85
  }
82
86
 
83
87
  handleClickEvent = (e) => {
@@ -98,7 +102,7 @@ export default class Tabs extends React.Component {
98
102
  }
99
103
 
100
104
  adjustScroll = () => {
101
- const { width, tabs, currentTabId } = this.props
105
+ const { tabs, currentTabId } = this.props
102
106
  const index = findIndex(tabs, t => t.id === currentTabId)
103
107
  const tabsDomWith = Array.from(
104
108
  document.querySelectorAll('.tab')
@@ -106,10 +110,14 @@ export default class Tabs extends React.Component {
106
110
  return prev + c.clientWidth
107
111
  }, 0)
108
112
  const w = (index + 1) * tabMargin + 5 + tabsDomWith
109
- const scrollLeft = w > width - extraTabWidth
110
- ? w - width + extraTabWidth
113
+ const tabsInnerWidth = this.getInnerWidth()
114
+ const scrollLeft = w > tabsInnerWidth
115
+ ? w - tabsInnerWidth
111
116
  : 0
112
117
  this.dom.scrollLeft = scrollLeft
118
+ this.setState({
119
+ overflow: this.isOverflow()
120
+ })
113
121
  }
114
122
 
115
123
  handleScrollLeft = () => {
@@ -178,13 +186,13 @@ export default class Tabs extends React.Component {
178
186
  className={cls}
179
187
  onClick={onNewSsh}
180
188
  >
181
- <CodeFilled /> {c('newBookmark')}
189
+ <CodeFilled /> {e('newBookmark')}
182
190
  </div>
183
191
  <div
184
192
  className={cls}
185
193
  onClick={() => addTab()}
186
194
  >
187
- <RightSquareFilled /> {t('newTab')}
195
+ <RightSquareFilled /> {e('newTab')}
188
196
  </div>
189
197
  <BookmarksList
190
198
  store={window.store}
@@ -252,7 +260,7 @@ export default class Tabs extends React.Component {
252
260
  const { tabs = [], width } = this.props
253
261
  const len = tabs.length
254
262
  const tabsWidthAll = tabMargin * len + 10 + this.tabsWidth()
255
- const overflow = this.isOverflow()
263
+ const { overflow } = this.state
256
264
  const left = overflow
257
265
  ? '100%'
258
266
  : tabsWidthAll
@@ -291,9 +299,9 @@ export default class Tabs extends React.Component {
291
299
  })
292
300
  }
293
301
  {
294
- !overflow
295
- ? this.renderAddBtn()
296
- : null
302
+ overflow
303
+ ? null
304
+ : this.renderAddBtn()
297
305
  }
298
306
  </div>
299
307
  </div>
@@ -301,7 +309,7 @@ export default class Tabs extends React.Component {
301
309
  }
302
310
 
303
311
  render () {
304
- const overflow = this.isOverflow()
312
+ const { overflow } = this.state
305
313
  return (
306
314
  <div className='tabs' ref={this.tabsRef}>
307
315
  {this.renderContent()}
@@ -23,10 +23,7 @@ import {
23
23
  } from '../../common/constants'
24
24
  import { shortcutDescExtend } from '../shortcuts/shortcut-handler.js'
25
25
 
26
- const { prefix } = window
27
- const e = prefix('tabs')
28
- const m = prefix('menu')
29
- const s = prefix('sftp')
26
+ const e = window.translate
30
27
  const onDragCls = 'ondrag-tab'
31
28
  const onDragOverCls = 'dragover-tab'
32
29
 
@@ -40,7 +37,6 @@ class Tab extends Component {
40
37
  }
41
38
 
42
39
  componentDidMount () {
43
- console.log(this.props)
44
40
  this.dom = document.getElementById('id' + this.state.tab.id)
45
41
  window.addEventListener('message', this.onEvent)
46
42
  }
@@ -316,7 +312,7 @@ class Tab extends Component {
316
312
  res.push({
317
313
  func: 'handleReloadTab',
318
314
  icon: 'Loading3QuartersOutlined',
319
- text: m('reload'),
315
+ text: e('reload'),
320
316
  subText: reloadShortcut
321
317
  })
322
318
  return res
@@ -389,8 +385,8 @@ class Tab extends Component {
389
385
  tunnel = `sock5://${sshTunnelLocalHost}:${sshTunnelLocalPort}`
390
386
  } else {
391
387
  tunnel = sshTunnel === 'forwardRemoteToLocal'
392
- ? `-> ${s('remote')}:${sshTunnelRemoteHost}:${sshTunnelRemotePort} -> ${sshTunnelLocalHost}:${sshTunnelLocalPort}`
393
- : `-> ${s('local')}:${sshTunnelLocalHost}:${sshTunnelLocalPort} -> ${sshTunnelRemoteHost}:${sshTunnelRemotePort}`
388
+ ? `-> ${e('remote')}:${sshTunnelRemoteHost}:${sshTunnelRemotePort} -> ${sshTunnelLocalHost}:${sshTunnelLocalPort}`
389
+ : `-> ${e('local')}:${sshTunnelLocalHost}:${sshTunnelLocalPort} -> ${sshTunnelRemoteHost}:${sshTunnelRemotePort}`
394
390
  }
395
391
  if (error) {
396
392
  tunnel = `error: ${tunnel}`
@@ -488,7 +484,7 @@ class Tab extends Component {
488
484
  <Loading3QuartersOutlined
489
485
  className='pointer tab-reload mg1r'
490
486
  onClick={this.handleReloadTab}
491
- title={m('reload')}
487
+ title={e('reload')}
492
488
  />
493
489
  <span className='tab-title'>
494
490
  {tabCount}. {title}