@electerm/electerm-react 1.51.1 → 1.51.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.
Files changed (64) hide show
  1. package/client/common/constants.js +1 -2
  2. package/client/common/db.js +10 -9
  3. package/client/components/batch-op/batch-op.jsx +16 -5
  4. package/client/components/bookmark-form/index.jsx +1 -1
  5. package/client/components/bookmark-form/ssh-form.jsx +3 -23
  6. package/client/components/bookmark-form/use-submit.jsx +6 -15
  7. package/client/components/context-menu/context-menu.styl +5 -5
  8. package/client/components/context-menu/history.jsx +2 -11
  9. package/client/components/context-menu/sub-tab-menu.jsx +1 -1
  10. package/client/components/footer/batch-input.jsx +10 -10
  11. package/client/components/footer/footer-entry.jsx +3 -8
  12. package/client/components/footer/tab-select.jsx +2 -2
  13. package/client/components/layout/layout-item.jsx +2 -2
  14. package/client/components/layout/layout.jsx +7 -7
  15. package/client/components/main/main.jsx +9 -5
  16. package/client/components/session/session.jsx +22 -3
  17. package/client/components/session/session.styl +3 -2
  18. package/client/components/session/sessions.jsx +4 -4
  19. package/client/components/setting-panel/list.styl +0 -1
  20. package/client/components/setting-panel/on-tree-drop.js +5 -5
  21. package/client/components/setting-panel/setting-modal.jsx +0 -12
  22. package/client/components/sftp/confirm-modal-store.jsx +0 -7
  23. package/client/components/sftp/file-mode-modal.jsx +2 -2
  24. package/client/components/sftp/sftp-entry.jsx +2 -2
  25. package/client/components/sftp/transfer-conflict-store.jsx +69 -66
  26. package/client/components/sftp/transport-action-store.jsx +32 -50
  27. package/client/components/sftp/transports-action-store.jsx +15 -15
  28. package/client/components/sftp/transports-ui-store.jsx +9 -5
  29. package/client/components/shortcuts/shortcut-control.jsx +3 -3
  30. package/client/components/sidebar/bookmark-select.jsx +1 -1
  31. package/client/components/sidebar/bookmark.jsx +4 -63
  32. package/client/components/sidebar/history-item.jsx +34 -0
  33. package/client/components/sidebar/history.jsx +17 -52
  34. package/client/components/sidebar/index.jsx +4 -34
  35. package/client/components/sidebar/sidebar-panel.jsx +107 -0
  36. package/client/components/sidebar/sidebar.styl +14 -0
  37. package/client/components/sidebar/transfer-list-control.jsx +1 -0
  38. package/client/components/sidebar/transfer.styl +1 -1
  39. package/client/components/sidebar/transport-ui.jsx +179 -37
  40. package/client/components/tabs/index.jsx +12 -12
  41. package/client/components/tabs/tab.jsx +23 -14
  42. package/client/components/terminal/index.jsx +12 -15
  43. package/client/components/terminal/term-search.jsx +4 -4
  44. package/client/components/tree-list/tree-list.jsx +8 -10
  45. package/client/entry/worker.js +5 -3
  46. package/client/store/bookmark-group.js +3 -5
  47. package/client/store/common.js +11 -1
  48. package/client/store/db-upgrade.js +0 -2
  49. package/client/store/event.js +1 -1
  50. package/client/store/index.js +2 -5
  51. package/client/store/init-state.js +9 -8
  52. package/client/store/item.js +0 -19
  53. package/client/store/load-data.js +2 -0
  54. package/client/store/quick-command.js +1 -1
  55. package/client/store/session.js +1 -1
  56. package/client/store/setting.js +2 -51
  57. package/client/store/sidebar.js +7 -8
  58. package/client/store/sync.js +7 -7
  59. package/client/store/tab.js +102 -34
  60. package/client/store/transfer-history.js +3 -9
  61. package/client/store/transfer-list.js +75 -75
  62. package/client/store/watch.js +13 -5
  63. package/package.json +1 -1
  64. package/client/components/setting-panel/tab-history.jsx +0 -43
@@ -10,13 +10,14 @@ import {
10
10
  } from '@ant-design/icons'
11
11
  import { Tooltip, message } from 'antd'
12
12
  import classnames from 'classnames'
13
- import { findIndex, pick } from 'lodash-es'
13
+ import { pick } from 'lodash-es'
14
14
  import Input from '../common/input-auto-focus'
15
15
  import createName from '../../common/create-title'
16
16
  import { addClass, removeClass } from '../../common/class'
17
17
  import {
18
18
  terminalSshConfigType
19
19
  } from '../../common/constants'
20
+ import { action } from 'manate'
20
21
  import { shortcutDescExtend } from '../shortcuts/shortcut-handler.js'
21
22
 
22
23
  const e = window.translate
@@ -47,9 +48,9 @@ class Tab extends Component {
47
48
  // }
48
49
 
49
50
  // shouldUpdate = (prevProps, nextProps) => {
50
- // // todo currentTabId still need improve
51
+ // // todo activeTabId still need improve
51
52
  // const pickKeys = [
52
- // 'currentTabId',
53
+ // 'activeTabId',
53
54
  // 'height',
54
55
  // 'isLast',
55
56
  // 'isMaximized',
@@ -117,7 +118,13 @@ class Tab extends Component {
117
118
  }
118
119
 
119
120
  const fromTab = JSON.parse(e.dataTransfer.getData('fromFile'))
120
- const onDropTab = document.querySelector('.' + onDragOverCls)
121
+ let onDropTab = target
122
+ while (onDropTab) {
123
+ if (onDropTab.classList && onDropTab.classList.contains('tab')) {
124
+ break
125
+ }
126
+ onDropTab = onDropTab.parentElement
127
+ }
121
128
  if (!onDropTab || !fromTab) {
122
129
  return
123
130
  }
@@ -129,29 +136,31 @@ class Tab extends Component {
129
136
 
130
137
  const { id } = fromTab
131
138
  const storeTabs = window.store.tabs
132
- const indexFrom = findIndex(storeTabs, t => t.id === id)
133
- let indexDrop = findIndex(storeTabs, t => t.id === dropId)
139
+ const indexFrom = storeTabs.findIndex(t => t.id === id)
140
+ let indexDrop = storeTabs.findIndex(t => t.id === dropId)
134
141
 
135
142
  if (indexFrom >= 0 && indexDrop >= 0) {
136
143
  const targetTab = storeTabs[indexDrop]
137
144
  const fromBatch = fromTab.batch
138
145
 
139
146
  // Handle currentTab change if needed
140
- if (window.store[`currentTabId${fromBatch}`] === id && fromBatch !== targetTab.batch) {
147
+ if (window.store[`activeTabId${fromBatch}`] === id && fromBatch !== targetTab.batch) {
141
148
  // Find next tab in the same batch
142
149
  const nextTab = storeTabs.find((t, i) =>
143
150
  i !== indexFrom && t.batch === fromBatch
144
151
  )
145
- window.store[`currentTabId${fromBatch}`] = nextTab ? nextTab.id : ''
152
+ window.store[`activeTabId${fromBatch}`] = nextTab ? nextTab.id : ''
146
153
  }
147
154
 
148
155
  // Reorder tabs and update batch
149
- const [tab] = storeTabs.splice(indexFrom, 1)
150
- tab.batch = targetTab.batch // Update the batch to match target tab's batch
151
- if (indexFrom < indexDrop) {
152
- indexDrop = indexDrop - 1
153
- }
154
- storeTabs.splice(indexDrop, 0, tab)
156
+ action(function () {
157
+ const [tab] = storeTabs.splice(indexFrom, 1)
158
+ tab.batch = targetTab.batch // Update the batch to match target tab's batch
159
+ if (indexFrom < indexDrop) {
160
+ indexDrop = indexDrop - 1
161
+ }
162
+ storeTabs.splice(indexDrop, 0, tab)
163
+ })()
155
164
  window.store.focus()
156
165
  }
157
166
  }
@@ -271,7 +271,7 @@ clear\r`
271
271
  }
272
272
 
273
273
  isActiveTerminal = () => {
274
- return this.props.tab.id === this.props.currentTabId &&
274
+ return this.props.tab.id === this.props.activeTabId &&
275
275
  this.props.pane === paneMap.terminal
276
276
  }
277
277
 
@@ -333,14 +333,14 @@ clear\r`
333
333
  type,
334
334
  cmd,
335
335
  selectedTabIds = [],
336
- currentTabId,
336
+ activeTabId,
337
337
  pid,
338
338
  inputOnly,
339
339
  zoomValue
340
340
  } = e?.data || {}
341
341
 
342
- const { id: currentTabIdProp } = this.props.tab
343
- const tabIdMatch = selectedTabIds.includes(currentTabIdProp) || currentTabId === currentTabIdProp
342
+ const { id: activeTabIdProp } = this.props.tab
343
+ const tabIdMatch = selectedTabIds.includes(activeTabIdProp) || activeTabId === activeTabIdProp
344
344
  if (
345
345
  action === terminalActions.zoom &&
346
346
  tabIdMatch
@@ -357,9 +357,7 @@ clear\r`
357
357
  this.batchInput(cmd)
358
358
  } else if (
359
359
  action === terminalActions.showInfoPanel &&
360
- (
361
- tabIdMatch
362
- )
360
+ tabIdMatch
363
361
  ) {
364
362
  this.handleShowInfo()
365
363
  } else if (
@@ -404,7 +402,7 @@ clear\r`
404
402
  this.searchAddon.clearDecorations()
405
403
  } else if (
406
404
  action === commonActions.getTermLogState &&
407
- pid === currentTabIdProp
405
+ pid === activeTabIdProp
408
406
  ) {
409
407
  postMessage({
410
408
  action: commonActions.returnTermLogState,
@@ -412,11 +410,11 @@ clear\r`
412
410
  saveTerminalLogToFile: this.state.saveTerminalLogToFile,
413
411
  addTimeStampToTermLog: this.state.addTimeStampToTermLog
414
412
  },
415
- pid: currentTabIdProp
413
+ pid: activeTabIdProp
416
414
  })
417
415
  } else if (
418
416
  action === commonActions.setTermLogState &&
419
- pid === currentTabIdProp
417
+ pid === activeTabIdProp
420
418
  ) {
421
419
  this.setState({
422
420
  addTimeStampToTermLog,
@@ -1046,10 +1044,10 @@ clear\r`
1046
1044
  }
1047
1045
 
1048
1046
  setActive = () => {
1049
- const name = `currentTabId${this.props.batch}`
1047
+ const name = `activeTabId${this.props.batch}`
1050
1048
  const tabId = this.props.tab.id
1051
1049
  window.store.storeAssign({
1052
- currentTabId: tabId,
1050
+ activeTabId: tabId,
1053
1051
  [name]: tabId
1054
1052
  })
1055
1053
  }
@@ -1319,12 +1317,11 @@ clear\r`
1319
1317
  }
1320
1318
 
1321
1319
  handleShowInfo = () => {
1322
- const { id, sessionId, logName } = this.props
1323
- const { pid } = this.state
1320
+ const { id, sessionId, logName, tab } = this.props
1324
1321
  const infoProps = {
1325
1322
  logName,
1326
1323
  id,
1327
- pid,
1324
+ pid: tab.id,
1328
1325
  sessionId,
1329
1326
  isRemote: this.isRemote(),
1330
1327
  isActive: this.isActiveTerminal()
@@ -68,14 +68,14 @@ class TermSearch extends PureComponent {
68
68
 
69
69
  prev = () => {
70
70
  const {
71
- currentTabId,
71
+ activeTabId,
72
72
  termSearch,
73
73
  termSearchOptions
74
74
  } = this.props
75
75
  postMessage({
76
76
  action: terminalActions.doSearchPrev,
77
77
  keyword: termSearch,
78
- currentTabId,
78
+ activeTabId,
79
79
  options: copy(termSearchOptions)
80
80
  })
81
81
  }
@@ -83,7 +83,7 @@ class TermSearch extends PureComponent {
83
83
  next = () => {
84
84
  postMessage({
85
85
  action: terminalActions.doSearchNext,
86
- currentTabId: this.props.currentTabId,
86
+ activeTabId: this.props.activeTabId,
87
87
  keyword: this.props.termSearch,
88
88
  options: copy(this.props.termSearchOptions)
89
89
  })
@@ -97,7 +97,7 @@ class TermSearch extends PureComponent {
97
97
  clearSearch = () => {
98
98
  postMessage({
99
99
  action: terminalActions.clearSearch,
100
- currentTabId: this.props.currentTabId
100
+ activeTabId: this.props.activeTabId
101
101
  })
102
102
  }
103
103
 
@@ -21,7 +21,7 @@ import {
21
21
  } from 'antd'
22
22
  import createName from '../../common/create-title'
23
23
  import InputAutoFocus from '../common/input-auto-focus'
24
- import { find, uniq, findIndex, isEqual, filter, pick } from 'lodash-es'
24
+ import { find, uniq, isEqual, filter, pick } from 'lodash-es'
25
25
  import {
26
26
  maxBookmarkGroupTitleLength,
27
27
  defaultBookmarkGroupId,
@@ -597,13 +597,13 @@ export default class ItemListTree extends Component {
597
597
  } = window.store
598
598
 
599
599
  if (!pidDragged && !pidDrop) {
600
- const indexDrag = findIndex(bookmarkGroups, item => item.id === idDragged)
600
+ const indexDrag = bookmarkGroups.findIndex(item => item.id === idDragged)
601
601
  if (indexDrag < 0) {
602
602
  return
603
603
  }
604
604
  const dragItem = bookmarkGroups.splice(indexDrag, 1)[0]
605
605
  dragItem.level = 1
606
- const indexDrop = findIndex(bookmarkGroups, item => item.id === idDrop)
606
+ const indexDrop = bookmarkGroups.findIndex(item => item.id === idDrop)
607
607
  if (indexDrop < 0) {
608
608
  return
609
609
  }
@@ -653,7 +653,7 @@ export default class ItemListTree extends Component {
653
653
  )
654
654
  } else {
655
655
  const arr = parentDrop.bookmarkGroupIds || []
656
- let index = findIndex(arr, item => item === idDrop)
656
+ let index = arr.findIndex(item => item === idDrop)
657
657
  if (index < 0) {
658
658
  index = 0
659
659
  }
@@ -704,7 +704,7 @@ export default class ItemListTree extends Component {
704
704
  )
705
705
  } else {
706
706
  const arr = parentDrop.bookmarkIds || []
707
- let index = findIndex(arr, item => item === idDrop)
707
+ let index = arr.findIndex(item => item === idDrop)
708
708
  if (index < 0) {
709
709
  index = 0
710
710
  }
@@ -724,7 +724,7 @@ export default class ItemListTree extends Component {
724
724
  pidDrop &&
725
725
  !pidDragged
726
726
  ) {
727
- const i = findIndex(bookmarkGroups, item => item.id === idDragged)
727
+ const i = bookmarkGroups.findIndex(item => item.id === idDragged)
728
728
  if (i >= 0) {
729
729
  const item = bookmarkGroups[i]
730
730
  item.level = 2
@@ -795,13 +795,11 @@ export default class ItemListTree extends Component {
795
795
  }
796
796
 
797
797
  updateBookmarkGroups = (bookmarkGroups, bookmark, categoryId) => {
798
- let index = findIndex(
799
- bookmarkGroups,
798
+ let index = bookmarkGroups.findIndex(
800
799
  bg => bg.id === categoryId
801
800
  )
802
801
  if (index < 0) {
803
- index = findIndex(
804
- bookmarkGroups,
802
+ index = bookmarkGroups.findIndex(
805
803
  bg => bg.id === defaultBookmarkGroupId
806
804
  )
807
805
  }
@@ -136,6 +136,8 @@ async function onMsg (e) {
136
136
  }
137
137
 
138
138
  self.addEventListener('message', onMsg)
139
- send({
140
- action: 'worker-init'
141
- })
139
+ setTimeout(() => {
140
+ send({
141
+ action: 'worker-init'
142
+ })
143
+ }, 10)
@@ -2,7 +2,7 @@
2
2
  * bookmark group functions
3
3
  */
4
4
 
5
- import { find, findIndex } from 'lodash-es'
5
+ import { find } from 'lodash-es'
6
6
  import {
7
7
  defaultBookmarkGroupId,
8
8
  settingMap,
@@ -82,12 +82,10 @@ export default Store => {
82
82
  const groupIds = groups.map(g => g.id)
83
83
  const updates = []
84
84
  const defaultCatIndex = tobeDel.level !== 2
85
- ? findIndex(
86
- bookmarkGroups,
85
+ ? bookmarkGroups.findIndex(
87
86
  g => g.id === defaultBookmarkGroupId
88
87
  )
89
- : findIndex(
90
- bookmarkGroups,
88
+ : bookmarkGroups.findIndex(
91
89
  g => (g.bookmarkGroupIds || []).includes(tobeDel.id)
92
90
  )
93
91
  for (const g of groups) {
@@ -12,7 +12,8 @@ import {
12
12
  leftSidebarWidthKey,
13
13
  rightSidebarWidthKey,
14
14
  dismissDelKeyTipLsKey,
15
- connectionMap
15
+ connectionMap,
16
+ terminalActions
16
17
  } from '../common/constants'
17
18
  import * as ls from '../common/safe-local-storage'
18
19
 
@@ -46,6 +47,15 @@ export default Store => {
46
47
  })
47
48
  }
48
49
 
50
+ Store.prototype.openInfoPanel = function () {
51
+ const { store } = window
52
+ store.rightPanelVisible = true
53
+ postMessage({
54
+ action: terminalActions.showInfoPanel,
55
+ activeTabId: store.activeTabId
56
+ })
57
+ }
58
+
49
59
  Store.prototype.onResize = debounce(async function () {
50
60
  const { width, height } = await window.pre.runGlobalAsync('getScreenSize')
51
61
  const isMaximized = window.pre.runSync('isMaximized')
@@ -4,7 +4,6 @@
4
4
 
5
5
  import { Modal } from 'antd'
6
6
  import delay from '../common/wait'
7
- import initWatch from './watch'
8
7
 
9
8
  export default (Store) => {
10
9
  Store.prototype.checkForDbUpgrade = async function () {
@@ -14,7 +13,6 @@ export default (Store) => {
14
13
  }
15
14
  const shouldUpgrade = await window.pre.runGlobalAsync('checkDbUpgrade')
16
15
  if (!shouldUpgrade) {
17
- initWatch(store)
18
16
  return false
19
17
  }
20
18
  const {
@@ -57,7 +57,7 @@ export default Store => {
57
57
  document.activeElement.select()
58
58
  postMessage({
59
59
  event: 'selectall',
60
- id: window.store.currentTabId
60
+ id: window.store.activeTabId
61
61
  })
62
62
  }
63
63
 
@@ -88,10 +88,10 @@ class Store {
88
88
 
89
89
  get currentTab () {
90
90
  const {
91
- currentTabId
91
+ activeTabId
92
92
  } = this
93
93
  const { tabs } = window.store
94
- const tab = tabs.find(t => t.id === currentTabId)
94
+ const tab = tabs.find(t => t.id === activeTabId)
95
95
  if (!tab) {
96
96
  return false
97
97
  }
@@ -238,12 +238,9 @@ const arrGetterProps = [
238
238
  'addressBookmarksLocal',
239
239
  'sshConfigItems',
240
240
  'itermThemes',
241
- 'history',
242
241
  'bookmarks',
243
242
  'bookmarkGroups',
244
243
  'profiles',
245
- 'fileTransfers',
246
- 'transferHistory',
247
244
  'quickCommands',
248
245
  'terminalThemes',
249
246
  'serials',
@@ -47,9 +47,10 @@ export default () => {
47
47
  loadTime: 0,
48
48
  lastDataUpdateTime: 0,
49
49
  tabs: [],
50
- currentTabId: '',
51
- _history: '[]',
50
+ activeTabId: '',
51
+ history: ls.getItemJSON('history', []),
52
52
  _bookmarks: '[]',
53
+ sidebarPanelTab: 'bookmarks',
53
54
  _profiles: '[]',
54
55
  _bookmarkGroups: JSON.stringify(
55
56
  getDefaultBookmarkGroups([])
@@ -78,8 +79,8 @@ export default () => {
78
79
  fileOperation: fileOperationsMap.cp, // cp or mv
79
80
  pauseAllTransfer: false,
80
81
  transferTab: 'transfer',
81
- _transferHistory: '[]',
82
- _fileTransfers: '[]',
82
+ transferHistory: [],
83
+ fileTransfers: [],
83
84
  _transferToConfirm: '{}',
84
85
  _sftpSortSetting: ls.getItem(sftpDefaultSortSettingKey) || JSON.stringify({
85
86
  local: {
@@ -95,10 +96,10 @@ export default () => {
95
96
  prevLayout: layout,
96
97
  resizeTrigger: 0,
97
98
  currentLayoutBatch: 0,
98
- currentTabId0: '',
99
- currentTabId1: '',
100
- currentTabId2: '',
101
- currentTabId3: '',
99
+ activeTabId0: '',
100
+ activeTabId1: '',
101
+ activeTabId2: '',
102
+ activeTabId3: '',
102
103
  _terminalInfoProps: '{}',
103
104
  rightPanelVisible: false,
104
105
  rightPanelPinned: false,
@@ -4,24 +4,12 @@
4
4
 
5
5
  import { find } from 'lodash-es'
6
6
  import {
7
- maxHistory,
8
7
  settingMap
9
8
  } from '../common/constants'
10
9
  import getInitItem from '../common/init-setting-item'
11
10
  import { update, remove, dbNames } from '../common/db'
12
- import copy from 'json-deep-copy'
13
11
 
14
12
  export default Store => {
15
- Store.prototype.removeOldHistoryFromDb = function (items) {
16
- const arr = items.slice(maxHistory).map(k => {
17
- return {
18
- db: 'history',
19
- id: k.id
20
- }
21
- })
22
- window.store.batchDbDel(arr)
23
- }
24
-
25
13
  Store.prototype.addItem = function (item, type) {
26
14
  return window.store.addItems([item], type)
27
15
  }
@@ -33,12 +21,6 @@ export default Store => {
33
21
  ...objs,
34
22
  ...items
35
23
  ]
36
- if (type === settingMap.history && items.length > maxHistory) {
37
- store.removeOldHistoryFromDb(
38
- copy(items)
39
- )
40
- items.slice(0, maxHistory)
41
- }
42
24
  store.setItems(type, items)
43
25
  if (dbNames.includes(type)) {
44
26
  store.batchDbAdd(
@@ -59,7 +41,6 @@ export default Store => {
59
41
  if (!item) {
60
42
  return
61
43
  }
62
- // let index = findIndex(items, t => t.id === id)
63
44
  Object.assign(item, updates)
64
45
  store.setItems(type, items)
65
46
  if (dbNames.includes(type)) {
@@ -12,6 +12,7 @@ import encodes from '../components/bookmark-form/encodes'
12
12
  import runIdle from '../common/run-idle'
13
13
  import { initWsCommon } from '../common/fetch-from-server'
14
14
  import safeParse from '../common/parse-json-safe'
15
+ import initWatch from './watch'
15
16
 
16
17
  function getHost (argv, opts) {
17
18
  const arr = argv
@@ -201,6 +202,7 @@ export default (Store) => {
201
202
  store.fetchSshConfigItems()
202
203
  }
203
204
  store.initCommandLine().catch(store.onError)
205
+ initWatch(store)
204
206
  if (store.config.checkUpdateOnStart) {
205
207
  store.onCheckUpdate(false)
206
208
  }
@@ -38,7 +38,7 @@ export default Store => {
38
38
  action: terminalActions.quickCommand,
39
39
  cmd,
40
40
  inputOnly,
41
- currentTabId: window.store.currentTabId
41
+ activeTabId: window.store.activeTabId
42
42
  })
43
43
  }
44
44
 
@@ -11,7 +11,7 @@ export default Store => {
11
11
  postMsg({
12
12
  action: terminalActions.zoom,
13
13
  zoomValue: delta > 0 ? 1 : -1,
14
- currentTabId: window.store.currentTabId
14
+ activeTabId: window.store.activeTabId
15
15
  })
16
16
  }, 500)
17
17
  }
@@ -6,7 +6,6 @@ import { find } from 'lodash-es'
6
6
  import {
7
7
  message
8
8
  } from 'antd'
9
- import generate from '../common/uid'
10
9
  import copy from 'json-deep-copy'
11
10
  import {
12
11
  settingMap,
@@ -40,16 +39,6 @@ export default Store => {
40
39
  }
41
40
  )
42
41
  }
43
- Store.prototype.handleEditHistory = function () {
44
- const { store } = window
45
- const all = store.history
46
- store.storeAssign({
47
- settingTab: settingMap.history,
48
- autofocustrigger: Date.now()
49
- })
50
- store.setSettingItem(all[0] || getInitItem([], settingMap.history))
51
- store.openSettingModal()
52
- }
53
42
 
54
43
  Store.prototype.openBookmarkEdit = function (item) {
55
44
  const { store } = window
@@ -71,14 +60,10 @@ export default Store => {
71
60
  store.openSettingModal()
72
61
  }
73
62
 
74
- Store.prototype.onSelectHistory = function (id) {
63
+ Store.prototype.onSelectHistory = function (tab) {
75
64
  const { store } = window
76
- const history = store.history
77
- const item = find(history, it => it.id === id)
78
65
  store.addTab({
79
- ...copy(item),
80
- from: 'history',
81
- srcId: item.id,
66
+ ...copy(tab),
82
67
  ...newTerm(true, true),
83
68
  batch: window.openTabBatch ?? store.currentLayoutBatch
84
69
  })
@@ -87,7 +72,6 @@ export default Store => {
87
72
 
88
73
  Store.prototype.onSelectBookmark = function (id) {
89
74
  const { store } = window
90
- const history = store.history
91
75
  const bookmarks = store.bookmarks
92
76
  const item = copy(
93
77
  find(bookmarks, it => it.id === id) ||
@@ -105,39 +89,6 @@ export default Store => {
105
89
  })
106
90
 
107
91
  delete window.openTabBatch
108
-
109
- if (store.config.disableSshHistory) {
110
- return
111
- }
112
-
113
- // Critical Change: Use bookmarkId for matching instead of history id
114
- const bookmarkId = item.id
115
- const existingIndex = history.findIndex(h => h.bookmarkId === bookmarkId)
116
- if (existingIndex >= 0) {
117
- history[existingIndex].count = (history[existingIndex].count || 0) + 1
118
- history[existingIndex].lastUse = Date.now()
119
- const updatedItem = history.splice(existingIndex, 1)[0]
120
- history.unshift(updatedItem)
121
- } else {
122
- const historyItem = {
123
- ...item,
124
- id: generate(),
125
- bookmarkId,
126
- count: 1,
127
- lastUse: Date.now()
128
- }
129
- history.unshift(historyItem)
130
- }
131
-
132
- history.sort((a, b) => b.count - a.count || b.lastUse - a.lastUse)
133
-
134
- // Optional: Consider max history length
135
- const maxHistoryLength = store.config.maxHistoryLength || 50
136
- if (history.length > maxHistoryLength) {
137
- history.length = maxHistoryLength
138
- }
139
-
140
- store.setItems('history', history)
141
92
  }
142
93
 
143
94
  Store.prototype.openSetting = function () {
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
  import {
6
- settingMap,
7
6
  openedSidebarKey,
8
7
  sidebarPinnedKey
9
8
  } from '../common/constants'
@@ -26,11 +25,6 @@ export default Store => {
26
25
  )
27
26
  }
28
27
 
29
- Store.prototype.setOpenedSideBar = function (bar) {
30
- ls.setItem(openedSidebarKey, bar)
31
- window.store.openedSideBar = bar
32
- }
33
-
34
28
  Store.prototype.handlePin = function (pinned) {
35
29
  const { store } = window
36
30
  const current = !store.pinned
@@ -42,7 +36,12 @@ export default Store => {
42
36
  window.store.onNewSsh()
43
37
  }
44
38
 
45
- Store.prototype.onClickHistory = function () {
46
- window.store.handleChangeSettingTab(settingMap.history)
39
+ Store.prototype.handleSidebarPanelTab = function (tab) {
40
+ window.store.sidebarPanelTab = tab
41
+ }
42
+
43
+ Store.prototype.setOpenedSideBar = function (v) {
44
+ ls.setItem(openedSidebarKey, v)
45
+ window.store.openedSideBar = v
47
46
  }
48
47
  }
@@ -2,7 +2,7 @@
2
2
  * sync data to github gist related
3
3
  */
4
4
 
5
- import { get, pick, debounce, findIndex } from 'lodash-es'
5
+ import { get, pick, debounce } from 'lodash-es'
6
6
  import copy from 'json-deep-copy'
7
7
  import {
8
8
  settingMap, packInfo, syncTypes, syncDataMaps
@@ -186,8 +186,8 @@ export default (Store) => {
186
186
  const order = await getData(`${n}:order`)
187
187
  if (order && order.length) {
188
188
  str.sort((a, b) => {
189
- const ai = findIndex(order, r => r === a.id)
190
- const bi = findIndex(order, r => r === b.id)
189
+ const ai = order.findIndex(r => r === a.id)
190
+ const bi = order.findIndex(r => r === b.id)
191
191
  return ai - bi
192
192
  })
193
193
  }
@@ -285,8 +285,8 @@ export default (Store) => {
285
285
  if (isJSON(strOrder)) {
286
286
  strOrder = JSON.parse(strOrder)
287
287
  arr.sort((a, b) => {
288
- const ai = findIndex(strOrder, r => r === a.id)
289
- const bi = findIndex(strOrder, r => r === b.id)
288
+ const ai = strOrder.findIndex(r => r === a.id)
289
+ const bi = strOrder.findIndex(r => r === b.id)
290
290
  return ai - bi
291
291
  })
292
292
  }
@@ -372,8 +372,8 @@ export default (Store) => {
372
372
  const order = await getData(`${n}:order`)
373
373
  if (order && order.length) {
374
374
  objs[n].sort((a, b) => {
375
- const ai = findIndex(order, r => r === a.id)
376
- const bi = findIndex(order, r => r === b.id)
375
+ const ai = order.findIndex(r => r === a.id)
376
+ const bi = order.findIndex(r => r === b.id)
377
377
  return ai - bi
378
378
  })
379
379
  }