@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.
- package/client/common/constants.js +1 -2
- package/client/common/db.js +10 -9
- package/client/components/batch-op/batch-op.jsx +16 -5
- package/client/components/bookmark-form/index.jsx +1 -1
- package/client/components/bookmark-form/ssh-form.jsx +3 -23
- package/client/components/bookmark-form/use-submit.jsx +6 -15
- package/client/components/context-menu/context-menu.styl +5 -5
- package/client/components/context-menu/history.jsx +2 -11
- package/client/components/context-menu/sub-tab-menu.jsx +1 -1
- package/client/components/footer/batch-input.jsx +10 -10
- package/client/components/footer/footer-entry.jsx +3 -8
- package/client/components/footer/tab-select.jsx +2 -2
- package/client/components/layout/layout-item.jsx +2 -2
- package/client/components/layout/layout.jsx +7 -7
- package/client/components/main/main.jsx +9 -5
- package/client/components/session/session.jsx +22 -3
- package/client/components/session/session.styl +3 -2
- package/client/components/session/sessions.jsx +4 -4
- package/client/components/setting-panel/list.styl +0 -1
- package/client/components/setting-panel/on-tree-drop.js +5 -5
- package/client/components/setting-panel/setting-modal.jsx +0 -12
- package/client/components/sftp/confirm-modal-store.jsx +0 -7
- package/client/components/sftp/file-mode-modal.jsx +2 -2
- package/client/components/sftp/sftp-entry.jsx +2 -2
- package/client/components/sftp/transfer-conflict-store.jsx +69 -66
- package/client/components/sftp/transport-action-store.jsx +32 -50
- package/client/components/sftp/transports-action-store.jsx +15 -15
- package/client/components/sftp/transports-ui-store.jsx +9 -5
- package/client/components/shortcuts/shortcut-control.jsx +3 -3
- package/client/components/sidebar/bookmark-select.jsx +1 -1
- package/client/components/sidebar/bookmark.jsx +4 -63
- package/client/components/sidebar/history-item.jsx +34 -0
- package/client/components/sidebar/history.jsx +17 -52
- package/client/components/sidebar/index.jsx +4 -34
- package/client/components/sidebar/sidebar-panel.jsx +107 -0
- package/client/components/sidebar/sidebar.styl +14 -0
- package/client/components/sidebar/transfer-list-control.jsx +1 -0
- package/client/components/sidebar/transfer.styl +1 -1
- package/client/components/sidebar/transport-ui.jsx +179 -37
- package/client/components/tabs/index.jsx +12 -12
- package/client/components/tabs/tab.jsx +23 -14
- package/client/components/terminal/index.jsx +12 -15
- package/client/components/terminal/term-search.jsx +4 -4
- package/client/components/tree-list/tree-list.jsx +8 -10
- package/client/entry/worker.js +5 -3
- package/client/store/bookmark-group.js +3 -5
- package/client/store/common.js +11 -1
- package/client/store/db-upgrade.js +0 -2
- package/client/store/event.js +1 -1
- package/client/store/index.js +2 -5
- package/client/store/init-state.js +9 -8
- package/client/store/item.js +0 -19
- package/client/store/load-data.js +2 -0
- package/client/store/quick-command.js +1 -1
- package/client/store/session.js +1 -1
- package/client/store/setting.js +2 -51
- package/client/store/sidebar.js +7 -8
- package/client/store/sync.js +7 -7
- package/client/store/tab.js +102 -34
- package/client/store/transfer-history.js +3 -9
- package/client/store/transfer-list.js +75 -75
- package/client/store/watch.js +13 -5
- package/package.json +1 -1
- 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 {
|
|
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
|
|
51
|
+
// // todo activeTabId still need improve
|
|
51
52
|
// const pickKeys = [
|
|
52
|
-
// '
|
|
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
|
-
|
|
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(
|
|
133
|
-
let indexDrop = findIndex(
|
|
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[`
|
|
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[`
|
|
152
|
+
window.store[`activeTabId${fromBatch}`] = nextTab ? nextTab.id : ''
|
|
146
153
|
}
|
|
147
154
|
|
|
148
155
|
// Reorder tabs and update batch
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
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.
|
|
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
|
-
|
|
336
|
+
activeTabId,
|
|
337
337
|
pid,
|
|
338
338
|
inputOnly,
|
|
339
339
|
zoomValue
|
|
340
340
|
} = e?.data || {}
|
|
341
341
|
|
|
342
|
-
const { id:
|
|
343
|
-
const tabIdMatch = selectedTabIds.includes(
|
|
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 ===
|
|
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:
|
|
413
|
+
pid: activeTabIdProp
|
|
416
414
|
})
|
|
417
415
|
} else if (
|
|
418
416
|
action === commonActions.setTermLogState &&
|
|
419
|
-
pid ===
|
|
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 = `
|
|
1047
|
+
const name = `activeTabId${this.props.batch}`
|
|
1050
1048
|
const tabId = this.props.tab.id
|
|
1051
1049
|
window.store.storeAssign({
|
|
1052
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
}
|
package/client/entry/worker.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* bookmark group functions
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { find
|
|
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) {
|
package/client/store/common.js
CHANGED
|
@@ -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 {
|
package/client/store/event.js
CHANGED
package/client/store/index.js
CHANGED
|
@@ -88,10 +88,10 @@ class Store {
|
|
|
88
88
|
|
|
89
89
|
get currentTab () {
|
|
90
90
|
const {
|
|
91
|
-
|
|
91
|
+
activeTabId
|
|
92
92
|
} = this
|
|
93
93
|
const { tabs } = window.store
|
|
94
|
-
const tab = tabs.find(t => t.id ===
|
|
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
|
-
|
|
51
|
-
|
|
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
|
-
|
|
82
|
-
|
|
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
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
activeTabId0: '',
|
|
100
|
+
activeTabId1: '',
|
|
101
|
+
activeTabId2: '',
|
|
102
|
+
activeTabId3: '',
|
|
102
103
|
_terminalInfoProps: '{}',
|
|
103
104
|
rightPanelVisible: false,
|
|
104
105
|
rightPanelPinned: false,
|
package/client/store/item.js
CHANGED
|
@@ -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
|
}
|
package/client/store/session.js
CHANGED
package/client/store/setting.js
CHANGED
|
@@ -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 (
|
|
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(
|
|
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 () {
|
package/client/store/sidebar.js
CHANGED
|
@@ -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.
|
|
46
|
-
window.store.
|
|
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
|
}
|
package/client/store/sync.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* sync data to github gist related
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { get, pick, debounce
|
|
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(
|
|
190
|
-
const bi = findIndex(
|
|
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(
|
|
289
|
-
const bi = findIndex(
|
|
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(
|
|
376
|
-
const bi = findIndex(
|
|
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
|
}
|