@electerm/electerm-react 1.37.58 → 1.37.66

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 (33) hide show
  1. package/client/common/{create-title.js → create-title.jsx} +22 -1
  2. package/client/common/promise-timeout.js +1 -1
  3. package/client/components/batch-op/batch-op.jsx +4 -2
  4. package/client/components/bookmark-form/color-picker.jsx +2 -2
  5. package/client/components/bookmark-form/index.jsx +2 -2
  6. package/client/components/bookmark-form/render-auth-ssh.jsx +1 -1
  7. package/client/components/bookmark-form/telnet-form-ui.jsx +1 -1
  8. package/client/components/context-menu/history.jsx +2 -2
  9. package/client/components/context-menu/sub-tab-menu.jsx +2 -2
  10. package/client/components/main/upgrade.jsx +21 -9
  11. package/client/components/main/upgrade.styl +3 -5
  12. package/client/components/quick-commands/quick-commands-list.jsx +3 -0
  13. package/client/components/setting-panel/bookmark-transport.jsx +4 -4
  14. package/client/components/setting-panel/list.jsx +4 -2
  15. package/client/components/setting-panel/setting-modal.jsx +4 -4
  16. package/client/components/setting-panel/setting-terminal.jsx +9 -5
  17. package/client/components/setting-panel/setting-wrap.jsx +4 -2
  18. package/client/components/setting-panel/setting.styl +3 -1
  19. package/client/components/setting-panel/start-session-select.jsx +4 -4
  20. package/client/components/setting-panel/tree-list.jsx +4 -3
  21. package/client/components/sidebar/bookmark-select.jsx +1 -1
  22. package/client/components/sidebar/side-panel.jsx +15 -6
  23. package/client/components/sidebar/sidebar.styl +3 -5
  24. package/client/components/terminal-info/content.jsx +6 -2
  25. package/client/components/terminal-info/terminal-info.styl +4 -1
  26. package/client/store/bookmark-group.js +4 -7
  27. package/client/store/bookmark.js +0 -3
  28. package/client/store/index.js +29 -66
  29. package/client/store/load-data.js +1 -1
  30. package/client/store/quick-command.js +0 -4
  31. package/client/store/setting.js +6 -14
  32. package/client/store/watch.js +2 -2
  33. package/package.json +1 -1
@@ -9,7 +9,10 @@ import {
9
9
  const { prefix } = window
10
10
  const p = prefix('sftp')
11
11
 
12
- export default (res = {}) => {
12
+ export default function createTitle (res) {
13
+ if (!res) {
14
+ return ''
15
+ }
13
16
  const {
14
17
  host, port, username, title, type,
15
18
  path, connectionHoppings
@@ -27,3 +30,21 @@ export default (res = {}) => {
27
30
  }
28
31
  return f || p(terminalLocalType)
29
32
  }
33
+
34
+ export function createTitleTag (obj) {
35
+ const { color } = obj
36
+ const styleTag = color
37
+ ? { color }
38
+ : {}
39
+ return (
40
+ <span style={styleTag}>♦</span>
41
+ )
42
+ }
43
+
44
+ export function createTitleWithTag (obj) {
45
+ return (
46
+ <span className='tab-title'>
47
+ {createTitleTag(obj)} {createTitle(obj)}
48
+ </span>
49
+ )
50
+ }
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  export class NewPromise extends Promise {
6
- constructor (executor, timeout = 30000) {
6
+ constructor (executor, timeout = 120000) {
7
7
  let timeoutId
8
8
 
9
9
  super((resolve, reject) => {
@@ -632,8 +632,10 @@ export default class BatchOp extends Component {
632
632
  width: innerWidth - sidebarWidth,
633
633
  zIndex: 888,
634
634
  placement: 'left',
635
- headerStyle: {
636
- display: 'none'
635
+ styles: {
636
+ header: {
637
+ display: 'none'
638
+ }
637
639
  }
638
640
  }
639
641
  return (
@@ -75,9 +75,9 @@ export const ColorPicker = React.forwardRef((props, ref) => {
75
75
  <Popover
76
76
  content={renderContent()}
77
77
  trigger='click'
78
- visible={visible}
78
+ open={visible}
79
79
  placement='bottomLeft'
80
- onVisibleChange={handleVisibleChange}
80
+ onOpenChange={handleVisibleChange}
81
81
  >
82
82
  <div
83
83
  ref={ref}
@@ -17,7 +17,7 @@ import SshForm from './ssh-form'
17
17
  import SerialForm from './serial-form'
18
18
  import LocalForm from './local-form'
19
19
  import TelnetForm from './telnet-form'
20
- import createTitle from '../../common/create-title'
20
+ import { createTitleWithTag } from '../../common/create-title'
21
21
  import {
22
22
  LoadingOutlined,
23
23
  BookOutlined
@@ -104,7 +104,7 @@ export default class BookmarkIndex extends Component {
104
104
  }
105
105
  return (
106
106
  <b className='mg1x'>
107
- {createTitle(formData)}
107
+ {createTitleWithTag(formData)}
108
108
  </b>
109
109
  )
110
110
  }
@@ -26,7 +26,7 @@ export default function renderAuth (props) {
26
26
  if (authType === 'password') {
27
27
  const opts = {
28
28
  options: uniqBy(
29
- store.getBookmarks()
29
+ store.bookmarks
30
30
  .filter(d => d.password),
31
31
  (d) => d.password
32
32
  )
@@ -71,7 +71,7 @@ export default function TelnetFormUI (props) {
71
71
  function renderAuth () {
72
72
  const opts = {
73
73
  options: uniqBy(
74
- props.store.getBookmarks()
74
+ props.store.bookmarks
75
75
  .filter(d => d.password),
76
76
  (d) => d.password
77
77
  )
@@ -1,5 +1,5 @@
1
1
  import { Component } from '../common/react-subx'
2
- import createTitle from '../../common/create-title'
2
+ import { createTitleWithTag } from '../../common/create-title'
3
3
 
4
4
  export default class HistorySubMenu extends Component {
5
5
  render () {
@@ -8,7 +8,7 @@ export default class HistorySubMenu extends Component {
8
8
  <div className='sub-context-menu'>
9
9
  {
10
10
  store.history.map(item => {
11
- const title = createTitle(item)
11
+ const title = createTitleWithTag(item)
12
12
  return (
13
13
  <div
14
14
  className='sub-context-menu-item'
@@ -1,5 +1,5 @@
1
1
  import { PureComponent } from 'react'
2
- import createTitle from '../../common/create-title'
2
+ import { createTitleWithTag } from '../../common/create-title'
3
3
 
4
4
  export default class TabsSubMenuChild extends PureComponent {
5
5
  handleClick = () => {
@@ -8,7 +8,7 @@ export default class TabsSubMenuChild extends PureComponent {
8
8
 
9
9
  render () {
10
10
  const { item } = this.props
11
- const title = createTitle(item)
11
+ const title = createTitleWithTag(item)
12
12
  return (
13
13
  <div
14
14
  className='sub-context-menu-item'
@@ -202,9 +202,13 @@ export default class Upgrade extends PureComponent {
202
202
  renderError = (err) => {
203
203
  return (
204
204
  <div className='upgrade-panel'>
205
- <div className='upgrade-panel-title'>
206
- <CloseOutlined className='pointer font16 close-upgrade-panel' onClick={this.handleClose} />
207
- {e('fail')}: {err}
205
+ <div className='upgrade-panel-title fix'>
206
+ <span className='fleft'>
207
+ {e('fail')}: {err}
208
+ </span>
209
+ <span className='fright'>
210
+ <CloseOutlined className='pointer font16 close-upgrade-panel' onClick={this.handleClose} />
211
+ </span>
208
212
  </div>
209
213
  <div className='upgrade-panel-body'>
210
214
  You can visit
@@ -225,9 +229,13 @@ export default class Upgrade extends PureComponent {
225
229
  const cls = `animate upgrade-panel${showUpgradeModal ? '' : ' upgrade-panel-hide'}`
226
230
  return (
227
231
  <div className={cls}>
228
- <div className='upgrade-panel-title'>
229
- <CloseOutlined className='pointer font16 close-upgrade-panel' onClick={this.handleClose} />
230
- {e('noNeed')}
232
+ <div className='upgrade-panel-title fix'>
233
+ <span className='fleft'>
234
+ {e('noNeed')}
235
+ </span>
236
+ <span className='fright'>
237
+ <CloseOutlined className='pointer font16 close-upgrade-panel' onClick={this.handleClose} />
238
+ </span>
231
239
  </div>
232
240
  <div className='upgrade-panel-body'>
233
241
  {e('noNeedDesc')}
@@ -316,9 +324,13 @@ export default class Upgrade extends PureComponent {
316
324
  const skip = srcsSkipUpgradeCheck.includes(installSrc)
317
325
  return (
318
326
  <div className={cls}>
319
- <div className='upgrade-panel-title'>
320
- <MinusSquareOutlined className='pointer font16 close-upgrade-panel' onClick={this.handleMinimize} />
321
- {e('newVersion')} <b>{remoteVersion} [{releaseInfo.date}]</b>
327
+ <div className='upgrade-panel-title fix'>
328
+ <span className='fleft'>
329
+ {e('newVersion')} <b>{remoteVersion} [{releaseInfo.date}]</b>
330
+ </span>
331
+ <span className='fright'>
332
+ <MinusSquareOutlined className='pointer font16 close-upgrade-panel' onClick={this.handleMinimize} />
333
+ </span>
322
334
  </div>
323
335
  <div className='upgrade-panel-body'>
324
336
  {
@@ -6,7 +6,8 @@
6
6
  z-index 9999
7
7
  background main
8
8
  color text
9
- box-shadow 0px 0px 5px 5px alpha(main, .25)
9
+ border-radius 5px
10
+ border 1px solid darken(main, 30%)
10
11
  padding 0
11
12
  width 440px
12
13
  .upgrade-panel-hide
@@ -15,13 +16,10 @@
15
16
  right auto
16
17
  bottom auto
17
18
  .close-upgrade-panel
18
- position absolute
19
- right 5px
20
- top 8px
21
19
  &:hover
22
20
  color success
23
21
  .upgrade-panel-title
24
22
  .upgrade-panel-body
25
23
  padding 10px 15px
26
24
  .upgrade-panel-title
27
- border-bottom 1px solid main-dark
25
+ border-bottom 1px solid darken(main, 30%)
@@ -34,6 +34,9 @@ export default class QuickCommandsList extends List {
34
34
  }
35
35
 
36
36
  renderItem = (item, i) => {
37
+ if (!item) {
38
+ return null
39
+ }
37
40
  const { activeItemId } = this.props
38
41
  const { name, id } = item
39
42
  const cls = classnames(
@@ -30,8 +30,8 @@ export default class BookmarkTransport extends Component {
30
30
  bookmarkGroups: bookmarkGroups1,
31
31
  bookmarks: bookmarks1
32
32
  } = content
33
- const bookmarkGroups = copy(store.getBookmarkGroups())
34
- const bookmarks = copy(store.getBookmarks())
33
+ const bookmarkGroups = copy(store.bookmarkGroups)
34
+ const bookmarks = copy(store.bookmarks)
35
35
  const bmTree = bookmarks.reduce((p, v) => {
36
36
  return {
37
37
  ...p,
@@ -99,8 +99,8 @@ export default class BookmarkTransport extends Component {
99
99
 
100
100
  handleDownload = () => {
101
101
  const { store } = this.props
102
- const bookmarkGroups = store.getBookmarkGroups()
103
- const bookmarks = store.getBookmarks()
102
+ const bookmarkGroups = store.bookmarkGroups
103
+ const bookmarks = store.bookmarks
104
104
  const txt = JSON.stringify({
105
105
  bookmarkGroups: copy(bookmarkGroups),
106
106
  bookmarks: copy(bookmarks)
@@ -5,7 +5,7 @@ import React from 'react'
5
5
  import { CloseOutlined, EditOutlined, LoadingOutlined } from '@ant-design/icons'
6
6
  import { Popconfirm } from 'antd'
7
7
  import Search from '../common/search'
8
- import createName from '../../common/create-title'
8
+ import createName, { createTitleTag } from '../../common/create-title'
9
9
  import classnames from 'classnames'
10
10
  import { noop } from 'lodash-es'
11
11
  import highlight from '../common/highlight'
@@ -102,6 +102,7 @@ export default class ItemList extends React.PureComponent {
102
102
  const { onClickItem, type, activeItemId } = this.props
103
103
  const { id } = item
104
104
  const title = createName(item)
105
+ const tag = createTitleTag(item)
105
106
  const cls = classnames(
106
107
  'item-list-unit',
107
108
  {
@@ -122,7 +123,8 @@ export default class ItemList extends React.PureComponent {
122
123
  <div
123
124
  title={title}
124
125
  className='elli pd1y pd2x list-item-title'
125
- >{titleHighlight || s('new')}
126
+ >
127
+ {tag}{titleHighlight || s('new')}
126
128
  </div>
127
129
  {this.renderDelBtn(item)}
128
130
  {this.renderEditBtn(item, isGroup)}
@@ -51,16 +51,16 @@ export default class SettingModalWrap extends Component {
51
51
  'currentBookmarkGroupId',
52
52
  'config'
53
53
  ]),
54
- bookmarkGroups: store.getBookmarkGroups(),
55
- bookmarks: store.getBookmarks(),
54
+ bookmarkGroups: store.bookmarkGroups,
55
+ bookmarks: store.bookmarks,
56
56
  serials: store.serials,
57
57
  loaddingSerials: store.loaddingSerials
58
58
  }
59
59
  const treeProps = {
60
60
  ...props0,
61
61
  bookmarkSelectMode,
62
- bookmarkGroups: store.getBookmarkGroups(),
63
- bookmarks: store.getBookmarks(),
62
+ bookmarkGroups: store.bookmarkGroups,
63
+ bookmarks: store.bookmarks,
64
64
  ...pick(store, [
65
65
  'currentBookmarkGroupId',
66
66
  'autofocustrigger',
@@ -361,8 +361,9 @@ export default class SettingTerminal extends Component {
361
361
  const { fontFamily } = this.props.config
362
362
  const props = {
363
363
  mode: 'multiple',
364
+ className: 'font-sel',
364
365
  onChange: this.handleChangeFont,
365
- value: fontFamily.split(/, */g)
366
+ value: fontFamily.split(/, */g).filter(d => d.trim())
366
367
  }
367
368
  return (
368
369
  <Select
@@ -373,10 +374,13 @@ export default class SettingTerminal extends Component {
373
374
  fonts.map(f => {
374
375
  return (
375
376
  <Option value={f} key={f}>
376
- <span style={{
377
- fontFamily: f
378
- }}
379
- >{f}
377
+ <span
378
+ className='font-option'
379
+ style={{
380
+ fontFamily: f
381
+ }}
382
+ >
383
+ {f}
380
384
  </span>
381
385
  </Option>
382
386
  )
@@ -18,8 +18,10 @@ export default class SettingWrap extends Component {
18
18
  zIndex: 888,
19
19
  placement: 'left',
20
20
  destroyOnClose: true,
21
- headerStyle: {
22
- display: 'none'
21
+ styles: {
22
+ header: {
23
+ display: 'none'
24
+ }
23
25
  }
24
26
  }
25
27
  return (
@@ -1,4 +1,6 @@
1
1
  .pd2b.bg-img-setting
2
2
  display inline-block
3
3
  padding 0
4
- margin 5px 5px 0 0
4
+ margin 5px 5px 0 0
5
+ .font-sel
6
+ min-width 200px
@@ -1,7 +1,7 @@
1
1
  import { TreeSelect } from 'antd'
2
2
  import { Component } from '../common/react-subx'
3
3
  import copy from 'json-deep-copy'
4
- import createTitle from '../../common/create-title'
4
+ import { createTitleWithTag } from '../../common/create-title'
5
5
 
6
6
  const { prefix } = window
7
7
  const e = prefix('setting')
@@ -9,8 +9,8 @@ const { SHOW_CHILD } = TreeSelect
9
9
 
10
10
  export default class StartSessionSelect extends Component {
11
11
  buildData = () => {
12
- const cats = this.props.store.getBookmarkGroups()
13
- const tree = this.props.store.getBookmarks()
12
+ const cats = this.props.store.bookmarkGroups
13
+ const tree = this.props.store.bookmarks
14
14
  .reduce((p, k) => {
15
15
  return {
16
16
  ...p,
@@ -50,7 +50,7 @@ export default class StartSessionSelect extends Component {
50
50
  return {
51
51
  value: x.id,
52
52
  key: x.id,
53
- title: createTitle(x)
53
+ title: createTitleWithTag(x)
54
54
  }
55
55
  }
56
56
  const level1 = cats.filter(d => d.level !== 2)
@@ -27,7 +27,7 @@ import {
27
27
  Tooltip,
28
28
  Space
29
29
  } from 'antd'
30
- import createName from '../../common/create-title'
30
+ import createName, { createTitleTag } from '../../common/create-title'
31
31
  import classnames from 'classnames'
32
32
  import InputAutoFocus from '../common/input-auto-focus'
33
33
  import { find, uniq, findIndex, isEqual, filter } from 'lodash-es'
@@ -319,7 +319,7 @@ export default class ItemListTree extends Component {
319
319
  })
320
320
  } else {
321
321
  this.props.store.storeAssign({
322
- currentBookmarkGroupId: findBookmarkGroupId(this.props.store.getBookmarkGroups(), id)
322
+ currentBookmarkGroupId: findBookmarkGroupId(this.props.store.bookmarkGroups, id)
323
323
  })
324
324
  }
325
325
  const bookmarks = copy(this.props.bookmarks)
@@ -712,6 +712,7 @@ export default class ItemListTree extends Component {
712
712
  level2: item.level === 2
713
713
  }
714
714
  )
715
+ const tag = isGroup ? '' : createTitleTag(item)
715
716
  const title = isGroup
716
717
  ? item.title
717
718
  : createName(item)
@@ -732,7 +733,7 @@ export default class ItemListTree extends Component {
732
733
  <div
733
734
  className='tree-item-title elli'
734
735
  >
735
- {titleHighlight}
736
+ {tag}{titleHighlight}
736
737
  </div>
737
738
  {
738
739
  isGroup
@@ -24,7 +24,7 @@ export default class BookmarkSelect extends Component {
24
24
  }
25
25
  const base = {
26
26
  store,
27
- bookmarks: store.getBookmarks() || [],
27
+ bookmarks: store.bookmarks || [],
28
28
  type: 'bookmarks',
29
29
  onClickItem,
30
30
  listStyle,
@@ -3,8 +3,8 @@ export default class SidePanel extends PureComponent {
3
3
  handleMousedown = (e) => {
4
4
  this.dragStart = true
5
5
  this.clientX = e.clientX
6
- document.body.addEventListener('mouseup', this.handleMouseup)
7
- document.body.addEventListener('mousemove', this.handleMousemove)
6
+ window.addEventListener('mouseup', this.handleMouseup)
7
+ window.addEventListener('mousemove', this.handleMousemove)
8
8
  }
9
9
 
10
10
  handleMouseup = (e) => {
@@ -12,15 +12,15 @@ export default class SidePanel extends PureComponent {
12
12
  const {
13
13
  clientX
14
14
  } = e
15
- let nw = clientX - this.clientX + 300
15
+ let nw = clientX - this.clientX + this.props.leftSidebarWidth
16
16
  if (nw < 343) {
17
17
  nw = 343
18
18
  } else if (nw > 600) {
19
19
  nw = 600
20
20
  }
21
21
  this.props.setLeftSidePanelWidth(nw)
22
- document.body.removeEventListener('mouseup', this.handleMouseup)
23
- document.body.removeEventListener('mousemove', this.handleMousemove)
22
+ window.removeEventListener('mouseup', this.handleMouseup)
23
+ window.removeEventListener('mousemove', this.handleMousemove)
24
24
  }
25
25
 
26
26
  handleMousemove = (e) => {
@@ -28,8 +28,17 @@ export default class SidePanel extends PureComponent {
28
28
  clientX
29
29
  } = e
30
30
  const el = document.getElementById('side-panel')
31
- const nw = clientX - this.clientX + this.props.leftSidebarWidth
31
+ let nw = clientX - this.clientX + this.props.leftSidebarWidth
32
+ if (nw < 343) {
33
+ nw = 343
34
+ } else if (nw > 600) {
35
+ nw = 600
36
+ }
32
37
  el.style.width = nw + 'px'
38
+ const el1 = document.querySelector('.sessions')
39
+ if (el1) {
40
+ el1.style.marginLeft = (nw + 43) + 'px'
41
+ }
33
42
  }
34
43
 
35
44
  render () {
@@ -9,7 +9,7 @@
9
9
  z-index 200
10
10
  width 0
11
11
  overflow-y scroll
12
- background main-light
12
+ background main
13
13
  color text
14
14
  .item-list-unit:hover
15
15
  .list-item-remove
@@ -51,14 +51,12 @@
51
51
  position absolute
52
52
  left 43px
53
53
  top 45px
54
- bottom 36px
54
+ bottom 0
55
55
  z-index 200
56
56
  width 0
57
- border-top 5px solid main
57
+ border-right 1px solid darken(main, 30%)
58
58
 
59
59
  .pinned
60
- .sidebar-list
61
- bottom 0
62
60
  .drag-handle
63
61
  display block
64
62
  .sidebar-panel .pinned
@@ -67,8 +67,12 @@ export default class TerminalInfoContent extends PureComponent {
67
67
  clientX
68
68
  } = e
69
69
  const el = document.getElementById('info-panel-wrap')
70
- const nw = this.clientX - clientX + this.props.rightSidebarWidth
71
- console.log(nw, this.clientX, clientX, this.props.rightSidebarWidth)
70
+ let nw = this.clientX - clientX + this.props.rightSidebarWidth
71
+ if (nw < 400) {
72
+ nw = 400
73
+ } else if (nw > 1000) {
74
+ nw = 1000
75
+ }
72
76
  el.style.width = nw + 'px'
73
77
  }
74
78
 
@@ -9,7 +9,10 @@
9
9
  top 100px
10
10
  bottom 0
11
11
  width 500px
12
- background main-light
12
+ background main
13
+ border 1px solid darken(main, 30%)
14
+ border-radius 5px 0 0 5px
15
+ border-right none
13
16
  color text
14
17
  z-index 100
15
18
  overflow-y scroll
@@ -10,21 +10,18 @@ import {
10
10
  } from '../common/constants'
11
11
 
12
12
  export default Store => {
13
- Store.prototype.getBookmarkGroups = function () {
14
- return window.store.getItems(settingMap.bookmarkGroups)
15
- }
16
13
  Store.prototype.getBookmarkGroupsTotal = function () {
17
14
  const { store } = window
18
15
  return store.sshConfigItems.length && !store.config.hideSshConfig
19
16
  ? [
20
- ...store.getBookmarkGroups(),
17
+ ...store.bookmarkGroups,
21
18
  {
22
19
  title: terminalSshConfigType,
23
20
  id: terminalSshConfigType,
24
21
  bookmarkIds: store.sshConfigItems.map(d => d.id)
25
22
  }
26
23
  ]
27
- : store.getBookmarkGroups()
24
+ : store.bookmarkGroups
28
25
  }
29
26
 
30
27
  Store.prototype.setBookmarkGroups = function (items) {
@@ -43,7 +40,7 @@ export default Store => {
43
40
  const { store } = window
44
41
  let ids = item.bookmarkIds
45
42
  const gids = item.bookmarkGroupIds || []
46
- const bookmarkGroups = store.getBookmarkGroups()
43
+ const bookmarkGroups = store.bookmarkGroups
47
44
  for (const gid of gids) {
48
45
  const g = find(bookmarkGroups, g => g.id === gid)
49
46
  if (g && g.bookmarkIds && g.bookmarkIds.length) {
@@ -63,7 +60,7 @@ export default Store => {
63
60
  if (id === defaultBookmarkGroupId) {
64
61
  return
65
62
  }
66
- let bookmarkGroups = store.getBookmarkGroups()
63
+ let bookmarkGroups = store.bookmarkGroups
67
64
  const tobeDel = find(bookmarkGroups, bg => bg.id === id)
68
65
  if (!tobeDel) {
69
66
  return
@@ -13,9 +13,6 @@ export default Store => {
13
13
  }
14
14
  store.loaddingSerials = false
15
15
  }
16
- Store.prototype.getBookmarks = function () {
17
- return window.store.getItems('bookmarks')
18
- }
19
16
  Store.prototype.setBookmarks = function (items) {
20
17
  return window.store.setItems('bookmarks', items)
21
18
  }
@@ -99,7 +99,7 @@ class Store {
99
99
 
100
100
  get currentQuickCommands () {
101
101
  const { currentTab } = this
102
- const quickCommands = window.store.getQuickCommands()
102
+ const { quickCommands } = window.store
103
103
  const currentTabQuickCommands = (
104
104
  currentTab.quickCommands || []
105
105
  ).map((d, i) => {
@@ -138,7 +138,7 @@ class Store {
138
138
  }
139
139
 
140
140
  get quickCommandTags () {
141
- const quickCommands = window.store.getQuickCommands()
141
+ const { quickCommands } = window.store
142
142
  return uniq(
143
143
  quickCommands.reduce((p, q) => {
144
144
  return [
@@ -149,26 +149,10 @@ class Store {
149
149
  )
150
150
  }
151
151
 
152
- get expandedKeys () {
153
- return JSON.parse(window.store._expandedKeys || '[]')
154
- }
155
-
156
- get checkedKeys () {
157
- return JSON.parse(window.store._checkedKeys || '[]')
158
- }
159
-
160
152
  get isTransporting () {
161
153
  return window.store.getTabs().some(t => t.isTransporting)
162
154
  }
163
155
 
164
- get addressBookmarks () {
165
- return JSON.parse(window.store._addressBookmarks || '[]')
166
- }
167
-
168
- get addressBookmarksLocal () {
169
- return JSON.parse(window.store._addressBookmarksLocal || '[]')
170
- }
171
-
172
156
  get settingSidebarList () {
173
157
  const {
174
158
  settingTab
@@ -203,50 +187,6 @@ class Store {
203
187
  return window.store.getTabs().map(d => d.title).join('#')
204
188
  }
205
189
 
206
- get sshConfigItems () {
207
- return JSON.parse(window.store._sshConfigItems || '[]')
208
- }
209
-
210
- get itermThemes () {
211
- return JSON.parse(window.store._itermThemes || '[]')
212
- }
213
-
214
- get history () {
215
- return JSON.parse(window.store._history || '[]')
216
- }
217
-
218
- get bookmarks () {
219
- return JSON.parse(window.store._bookmarks || '[]')
220
- }
221
-
222
- get bookmarkGroups () {
223
- return JSON.parse(window.store._bookmarkGroups || '[]')
224
- }
225
-
226
- get tabs () {
227
- return JSON.parse(window.store._tabs || '[]')
228
- }
229
-
230
- get fileTransfers () {
231
- return JSON.parse(window.store._fileTransfers || '[]')
232
- }
233
-
234
- get transferHistory () {
235
- return JSON.parse(window.store._transferHistory || '[]')
236
- }
237
-
238
- get quickCommands () {
239
- return JSON.parse(window.store._quickCommands || '[]')
240
- }
241
-
242
- get terminalThemes () {
243
- return JSON.parse(window.store._terminalThemes || '[]')
244
- }
245
-
246
- get serials () {
247
- return JSON.parse(window.store._serials || '[]')
248
- }
249
-
250
190
  get setting () {
251
191
  return [
252
192
  {
@@ -272,10 +212,6 @@ class Store {
272
212
  return JSON.parse(window.store._sftpSortSetting)
273
213
  }
274
214
 
275
- get fonts () {
276
- return JSON.parse(window.store._fonts || '[]')
277
- }
278
-
279
215
  get onOperation () {
280
216
  const {
281
217
  store
@@ -327,6 +263,33 @@ class Store {
327
263
  }
328
264
  }
329
265
 
266
+ const getterProps = [
267
+ 'expandedKeys',
268
+ 'checkedKeys',
269
+ 'addressBookmarks',
270
+ 'addressBookmarksLocal',
271
+ 'sshConfigItems',
272
+ 'itermThemes',
273
+ 'history',
274
+ 'bookmarks',
275
+ 'bookmarkGroups',
276
+ 'tabs',
277
+ 'fileTransfers',
278
+ 'transferHistory',
279
+ 'quickCommands',
280
+ 'terminalThemes',
281
+ 'serials',
282
+ 'fonts'
283
+ ]
284
+
285
+ for (const prop of getterProps) {
286
+ Object.defineProperty(Store.prototype, prop, {
287
+ get: function () {
288
+ return JSON.parse(window.store[`_${prop}`] || '[]').filter(d => d)
289
+ }
290
+ })
291
+ }
292
+
330
293
  loadDataExtend(Store)
331
294
  eventExtend(Store)
332
295
  dbUpgradeExtend(Store)
@@ -154,7 +154,7 @@ export default (Store) => {
154
154
  globs.langs
155
155
  )
156
156
  store.zoom(store.config.zoom, false, true)
157
- initWsCommon()
157
+ await initWsCommon()
158
158
  }
159
159
  Store.prototype.initData = async function () {
160
160
  const { store } = window
@@ -9,10 +9,6 @@ import {
9
9
  import postMessage from '../common/post-msg'
10
10
 
11
11
  export default Store => {
12
- Store.prototype.getQuickCommands = function () {
13
- return window.store.getItems(settingMap.quickCommands)
14
- }
15
-
16
12
  Store.prototype.setQuickCommands = function (list) {
17
13
  return window.store.setItems(settingMap.quickCommands, list)
18
14
  }
@@ -2,7 +2,7 @@
2
2
  * setting modal
3
3
  */
4
4
 
5
- import { find, isEqual, pick, without } from 'lodash-es'
5
+ import { find } from 'lodash-es'
6
6
  import {
7
7
  message
8
8
  } from 'antd'
@@ -43,7 +43,7 @@ export default Store => {
43
43
  }
44
44
  Store.prototype.handleEditHistory = function () {
45
45
  const { store } = window
46
- const all = store.getItems('history')
46
+ const all = store.history
47
47
  store.storeAssign({
48
48
  settingTab: settingMap.history,
49
49
  autofocustrigger: Date.now()
@@ -74,7 +74,7 @@ export default Store => {
74
74
 
75
75
  Store.prototype.onSelectHistory = function (id) {
76
76
  const { store } = window
77
- const history = store.getItems('history')
77
+ const history = store.history
78
78
  const item = find(history, it => it.id === id)
79
79
  store.addTab({
80
80
  ...copy(item),
@@ -86,8 +86,8 @@ export default Store => {
86
86
 
87
87
  Store.prototype.onSelectBookmark = function (id) {
88
88
  const { store } = window
89
- const history = store.getItems('history')
90
- const bookmarks = store.getBookmarks()
89
+ const history = store.history
90
+ const bookmarks = store.bookmarks
91
91
  const item = copy(
92
92
  find(bookmarks, it => it.id === id) ||
93
93
  find(store.sshConfigItems, it => it.id === id)
@@ -105,15 +105,7 @@ export default Store => {
105
105
  if (store.config.disableSshHistory) {
106
106
  return
107
107
  }
108
- const existItem = find(history, j => {
109
- const keysj = Object.keys(j)
110
- const keysi = Object.keys(item)
111
- return isEqual(
112
- pick(item, without(keysi, 'id')),
113
- pick(j, without(keysj, 'id'))
114
- )
115
- })
116
- history.unshift(existItem)
108
+ history.unshift(item)
117
109
  store.setItems('history', history)
118
110
  }
119
111
 
@@ -14,7 +14,7 @@ import {
14
14
  } from '../common/constants'
15
15
  import postMsg from '../common/post-msg'
16
16
  import * as ls from '../common/safe-local-storage'
17
- import { debounce } from 'lodash-es'
17
+ import { debounce, isEmpty } from 'lodash-es'
18
18
 
19
19
  export default store => {
20
20
  autoRun(store, () => {
@@ -65,7 +65,7 @@ export default store => {
65
65
  }).start()
66
66
 
67
67
  autoRun(store, () => {
68
- if (store.config) {
68
+ if (!isEmpty(store.config)) {
69
69
  window.pre.runGlobalAsync('saveUserConfig', store.config)
70
70
  }
71
71
  return store._config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "1.37.58",
3
+ "version": "1.37.66",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",