@electerm/electerm-react 1.60.50 → 1.70.0
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 -0
- package/client/common/default-log-path.js +5 -0
- package/client/common/default-setting.js +4 -2
- package/client/common/download-mirrors.js +0 -4
- package/client/common/find-bookmark-group-id.js +1 -2
- package/client/components/ai/ai-config.jsx +2 -2
- package/client/components/batch-op/batch-op-entry.jsx +13 -0
- package/client/components/bookmark-form/index.jsx +1 -1
- package/client/components/footer/footer-entry.jsx +9 -16
- package/client/components/icons/split-view.jsx +14 -0
- package/client/components/main/main.jsx +9 -10
- package/client/components/session/session.jsx +285 -70
- package/client/components/session/session.styl +2 -0
- package/client/components/setting-panel/on-tree-drop.js +10 -19
- package/client/components/setting-panel/setting-modal.jsx +1 -0
- package/client/components/setting-panel/setting-terminal.jsx +94 -20
- package/client/components/setting-panel/tab-settings.jsx +2 -1
- package/client/components/setting-sync/server-data-status.jsx +81 -0
- package/client/components/setting-sync/setting-sync-form.jsx +6 -0
- package/client/components/setting-sync/setting-sync.jsx +8 -5
- package/client/components/sftp/list-table-ui.jsx +13 -15
- package/client/components/sftp/sftp-entry.jsx +4 -22
- package/client/components/shortcuts/shortcut-control.jsx +10 -1
- package/client/components/sidebar/bookmark-select.jsx +3 -1
- package/client/components/tabs/tab.jsx +7 -8
- package/client/components/tabs/tabs.styl +3 -0
- package/client/components/terminal/term-search.jsx +2 -1
- package/client/components/terminal/terminal.jsx +26 -9
- package/client/components/terminal-info/base.jsx +9 -4
- package/client/components/tree-list/bookmark-toolbar.jsx +2 -3
- package/client/components/tree-list/tree-list.jsx +36 -51
- package/client/components/tree-list/tree-search.jsx +1 -0
- package/client/store/bookmark-group.js +1 -2
- package/client/store/init-state.js +4 -0
- package/client/store/item.js +1 -2
- package/client/store/load-data.js +6 -1
- package/client/store/setting.js +1 -2
- package/client/store/store.js +13 -15
- package/client/store/sync.js +42 -7
- package/client/store/terminal-theme.js +4 -4
- package/client/store/ui-theme.js +3 -10
- package/client/store/watch.js +11 -0
- package/package.json +1 -1
- package/client/components/main/loading.jsx +0 -25
|
@@ -3,7 +3,7 @@ import { handleErr } from '../../common/fetch.jsx'
|
|
|
3
3
|
import generate from '../../common/uid.js'
|
|
4
4
|
import { isEqual, pick, debounce, throttle } from 'lodash-es'
|
|
5
5
|
import clone from '../../common/to-simple-obj.js'
|
|
6
|
-
|
|
6
|
+
import resolve from '../../common/resolve.js'
|
|
7
7
|
import {
|
|
8
8
|
ReloadOutlined
|
|
9
9
|
} from '@ant-design/icons'
|
|
@@ -51,6 +51,7 @@ import { formatBytes } from '../../common/byte-format.js'
|
|
|
51
51
|
import * as fs from './fs.js'
|
|
52
52
|
import iconsMap from '../sys-menu/icons-map.jsx'
|
|
53
53
|
import { refs } from '../common/ref.js'
|
|
54
|
+
import createDefaultLogPath from '../../common/default-log-path.js'
|
|
54
55
|
|
|
55
56
|
const e = window.translate
|
|
56
57
|
|
|
@@ -65,13 +66,13 @@ class Term extends Component {
|
|
|
65
66
|
passType: 'password',
|
|
66
67
|
lines: []
|
|
67
68
|
}
|
|
69
|
+
this.id = `term-${this.props.tab.id}`
|
|
70
|
+
refs.add(this.id, this)
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
domRef = createRef()
|
|
71
74
|
|
|
72
75
|
componentDidMount () {
|
|
73
|
-
this.id = `term-${this.props.tab.id}`
|
|
74
|
-
refs.add(this.id, this)
|
|
75
76
|
this.initTerminal()
|
|
76
77
|
if (this.props.tab.enableSsh === false) {
|
|
77
78
|
;(
|
|
@@ -154,6 +155,9 @@ clear\r`
|
|
|
154
155
|
|
|
155
156
|
componentWillUnmount () {
|
|
156
157
|
refs.remove(this.id)
|
|
158
|
+
if (window.store.activeTerminalId === this.props.tab.id) {
|
|
159
|
+
window.store.activeTerminalId = ''
|
|
160
|
+
}
|
|
157
161
|
if (this.zsession) {
|
|
158
162
|
this.onZmodemEnd()
|
|
159
163
|
}
|
|
@@ -172,10 +176,6 @@ clear\r`
|
|
|
172
176
|
this.term.dispose()
|
|
173
177
|
this.term = null
|
|
174
178
|
}
|
|
175
|
-
window.removeEventListener(
|
|
176
|
-
'resize',
|
|
177
|
-
this.onResize
|
|
178
|
-
)
|
|
179
179
|
this.attachAddon = null
|
|
180
180
|
this.fitAddon = null
|
|
181
181
|
this.zmodemAddon = null
|
|
@@ -314,7 +314,23 @@ clear\r`
|
|
|
314
314
|
}
|
|
315
315
|
|
|
316
316
|
onDrop = e => {
|
|
317
|
-
const
|
|
317
|
+
const dt = e.dataTransfer
|
|
318
|
+
const fromFile = dt.getData('fromFile')
|
|
319
|
+
|
|
320
|
+
if (fromFile) {
|
|
321
|
+
// Handle SFTP file drop
|
|
322
|
+
try {
|
|
323
|
+
const fileData = JSON.parse(fromFile)
|
|
324
|
+
const filePath = resolve(fileData.path, fileData.name)
|
|
325
|
+
this.attachAddon._sendData(`"${filePath}" `)
|
|
326
|
+
return
|
|
327
|
+
} catch (e) {
|
|
328
|
+
log.error('Failed to parse fromFile data:', e)
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Handle regular file drop
|
|
333
|
+
const files = dt.files
|
|
318
334
|
if (files && files.length) {
|
|
319
335
|
this.attachAddon._sendData(
|
|
320
336
|
Array.from(files).map(f => `"${f.path}"`).join(' ')
|
|
@@ -1014,6 +1030,7 @@ clear\r`
|
|
|
1014
1030
|
...tab,
|
|
1015
1031
|
...extra,
|
|
1016
1032
|
logName,
|
|
1033
|
+
sessionLogPath: config.sessionLogPath || createDefaultLogPath(),
|
|
1017
1034
|
...pick(config, [
|
|
1018
1035
|
'addTimeStampToTermLog',
|
|
1019
1036
|
'keepaliveInterval',
|
|
@@ -1058,6 +1075,7 @@ clear\r`
|
|
|
1058
1075
|
return
|
|
1059
1076
|
}
|
|
1060
1077
|
this.setStatus(statusMap.success)
|
|
1078
|
+
refs.get('sftp-' + id)?.initData()
|
|
1061
1079
|
term.pid = id
|
|
1062
1080
|
this.pid = id
|
|
1063
1081
|
const wsUrl = this.buildWsUrl()
|
|
@@ -1105,7 +1123,6 @@ clear\r`
|
|
|
1105
1123
|
}, 200)
|
|
1106
1124
|
|
|
1107
1125
|
onerrorSocket = err => {
|
|
1108
|
-
this.setStatus(statusMap.error)
|
|
1109
1126
|
log.error('onerrorSocket', err)
|
|
1110
1127
|
}
|
|
1111
1128
|
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
ApiOutlined,
|
|
20
20
|
PartitionOutlined
|
|
21
21
|
} from '@ant-design/icons'
|
|
22
|
+
import createDefaultSessionLogPath from '../../common/default-log-path'
|
|
22
23
|
import { refs } from '../common/ref'
|
|
23
24
|
|
|
24
25
|
const e = window.translate
|
|
@@ -42,6 +43,10 @@ export default class TerminalInfoBase extends Component {
|
|
|
42
43
|
this.getState()
|
|
43
44
|
}
|
|
44
45
|
|
|
46
|
+
componentWillUnmount () {
|
|
47
|
+
clearTimeout(this.timer)
|
|
48
|
+
}
|
|
49
|
+
|
|
45
50
|
handleToggleTimestamp = () => {
|
|
46
51
|
const { saveTerminalLogToFile, addTimeStampToTermLog } = this.state
|
|
47
52
|
const {
|
|
@@ -102,6 +107,8 @@ export default class TerminalInfoBase extends Component {
|
|
|
102
107
|
saveTerminalLogToFile: term.state.saveTerminalLogToFile,
|
|
103
108
|
addTimeStampToTermLog: term.state.addTimeStampToTermLog
|
|
104
109
|
})
|
|
110
|
+
} else {
|
|
111
|
+
this.timer = setTimeout(this.getState, 100)
|
|
105
112
|
}
|
|
106
113
|
}
|
|
107
114
|
|
|
@@ -153,12 +160,10 @@ export default class TerminalInfoBase extends Component {
|
|
|
153
160
|
const {
|
|
154
161
|
id,
|
|
155
162
|
logName,
|
|
156
|
-
|
|
163
|
+
sessionLogPath
|
|
157
164
|
} = this.props
|
|
158
165
|
const { saveTerminalLogToFile } = this.state
|
|
159
|
-
const base =
|
|
160
|
-
? osResolve(appPath, 'electerm', 'session_logs')
|
|
161
|
-
: window.et.sessionLogPath
|
|
166
|
+
const base = sessionLogPath || createDefaultSessionLogPath()
|
|
162
167
|
const path = osResolve(base, logName + '.log')
|
|
163
168
|
const name = e('saveTerminalLogToFile')
|
|
164
169
|
const to = saveTerminalLogToFile
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import { Button, Space, Dropdown, Upload } from 'antd'
|
|
11
11
|
import copy from 'json-deep-copy'
|
|
12
12
|
import time from '../../common/time'
|
|
13
|
-
import {
|
|
13
|
+
import { uniq } from 'lodash-es'
|
|
14
14
|
import { fixBookmarks } from '../../common/db-fix'
|
|
15
15
|
import download from '../../common/download'
|
|
16
16
|
import { action } from 'manate'
|
|
@@ -59,8 +59,7 @@ export default function BookmarkToolbar (props) {
|
|
|
59
59
|
if (!bmgTree.has(bg.id)) {
|
|
60
60
|
store.bookmarkGroups.push(bg)
|
|
61
61
|
} else {
|
|
62
|
-
const bg1 = find(
|
|
63
|
-
store.bookmarkGroups,
|
|
62
|
+
const bg1 = store.bookmarkGroups.find(
|
|
64
63
|
b => b.id === bg.id
|
|
65
64
|
)
|
|
66
65
|
bg1.bookmarkIds = uniq(
|
|
@@ -10,20 +10,19 @@ import {
|
|
|
10
10
|
} from '@ant-design/icons'
|
|
11
11
|
import createName from '../../common/create-title'
|
|
12
12
|
import InputAutoFocus from '../common/input-auto-focus'
|
|
13
|
-
import {
|
|
13
|
+
import { uniq, filter, pick } from 'lodash-es'
|
|
14
14
|
import {
|
|
15
15
|
maxBookmarkGroupTitleLength,
|
|
16
16
|
defaultBookmarkGroupId,
|
|
17
17
|
settingMap
|
|
18
18
|
} from '../../common/constants'
|
|
19
19
|
import findParentBySel from '../../common/find-parent'
|
|
20
|
-
import copy
|
|
20
|
+
import copy from 'json-deep-copy'
|
|
21
21
|
import NewButtonsGroup from './bookmark-toolbar'
|
|
22
22
|
import findBookmarkGroupId from '../../common/find-bookmark-group-id'
|
|
23
23
|
import getInitItem from '../../common/init-setting-item'
|
|
24
24
|
import uid from '../../common/uid'
|
|
25
25
|
import { action } from 'manate'
|
|
26
|
-
import deepEqual from 'fast-deep-equal'
|
|
27
26
|
import './tree-list.styl'
|
|
28
27
|
import TreeExpander from './tree-expander'
|
|
29
28
|
import TreeListItem from './tree-list-item'
|
|
@@ -43,8 +42,7 @@ export default class ItemListTree extends Component {
|
|
|
43
42
|
moveItemIsGroup: false,
|
|
44
43
|
bookmarkGroupTitle: '',
|
|
45
44
|
categoryTitle: '',
|
|
46
|
-
categoryId: ''
|
|
47
|
-
expandedKeys: props.expandedKeys
|
|
45
|
+
categoryId: ''
|
|
48
46
|
}
|
|
49
47
|
}
|
|
50
48
|
|
|
@@ -60,17 +58,6 @@ export default class ItemListTree extends Component {
|
|
|
60
58
|
}, 100)
|
|
61
59
|
}
|
|
62
60
|
|
|
63
|
-
componentDidUpdate (prevProps, prevState) {
|
|
64
|
-
if (
|
|
65
|
-
!deepEqual(prevProps.expandedKeys, this.props.expandedKeys) &&
|
|
66
|
-
!deepEqual(this.props.expandedKeys, this.state.expandedKeys)
|
|
67
|
-
) {
|
|
68
|
-
this.setState({
|
|
69
|
-
expandedKeys: deepCopy(this.props.expandedKeys)
|
|
70
|
-
})
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
61
|
componentWillUnmount () {
|
|
75
62
|
clearTimeout(this.timer)
|
|
76
63
|
}
|
|
@@ -83,7 +70,7 @@ export default class ItemListTree extends Component {
|
|
|
83
70
|
})
|
|
84
71
|
}
|
|
85
72
|
|
|
86
|
-
filter = list => {
|
|
73
|
+
filter = (list) => {
|
|
87
74
|
const { keyword } = this.state
|
|
88
75
|
return keyword
|
|
89
76
|
? list.filter(item => {
|
|
@@ -92,26 +79,26 @@ export default class ItemListTree extends Component {
|
|
|
92
79
|
: list
|
|
93
80
|
}
|
|
94
81
|
|
|
95
|
-
getBookmarkTree = () => {
|
|
96
|
-
return this.filter(this.props.bookmarks).reduce((tree, bookmark) => {
|
|
97
|
-
tree[bookmark.id] = bookmark
|
|
98
|
-
return tree
|
|
99
|
-
}, {})
|
|
100
|
-
}
|
|
101
|
-
|
|
102
82
|
onExpandKey = group => {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.onExpand(
|
|
83
|
+
const {
|
|
84
|
+
expandedKeys
|
|
85
|
+
} = window.store
|
|
86
|
+
expandedKeys.push(group.id)
|
|
87
|
+
this.onExpand()
|
|
108
88
|
}
|
|
109
89
|
|
|
110
90
|
onUnExpandKey = group => {
|
|
111
|
-
const
|
|
112
|
-
|
|
91
|
+
const {
|
|
92
|
+
expandedKeys
|
|
93
|
+
} = window.store
|
|
94
|
+
const index = expandedKeys.findIndex(
|
|
95
|
+
d => d === group.id
|
|
113
96
|
)
|
|
114
|
-
|
|
97
|
+
if (index < 0) {
|
|
98
|
+
return
|
|
99
|
+
}
|
|
100
|
+
expandedKeys.splice(index, 1)
|
|
101
|
+
this.onExpand(expandedKeys)
|
|
115
102
|
}
|
|
116
103
|
|
|
117
104
|
handleChange = keyword => {
|
|
@@ -159,8 +146,7 @@ export default class ItemListTree extends Component {
|
|
|
159
146
|
return
|
|
160
147
|
}
|
|
161
148
|
const { bookmarkGroups } = window.store
|
|
162
|
-
const obj = find(
|
|
163
|
-
bookmarkGroups,
|
|
149
|
+
const obj = bookmarkGroups.find(
|
|
164
150
|
bg => bg.id === categoryId
|
|
165
151
|
)
|
|
166
152
|
if (!obj) {
|
|
@@ -242,8 +228,7 @@ export default class ItemListTree extends Component {
|
|
|
242
228
|
bookmarkIds: []
|
|
243
229
|
}
|
|
244
230
|
bookmarkGroups.unshift(newCat)
|
|
245
|
-
const cat = find(
|
|
246
|
-
bookmarkGroups,
|
|
231
|
+
const cat = bookmarkGroups.find(
|
|
247
232
|
d => d.id === id
|
|
248
233
|
)
|
|
249
234
|
if (!cat) {
|
|
@@ -280,12 +265,8 @@ export default class ItemListTree extends Component {
|
|
|
280
265
|
})
|
|
281
266
|
}
|
|
282
267
|
|
|
283
|
-
onExpand = (
|
|
284
|
-
this.setState({
|
|
285
|
-
expandedKeys
|
|
286
|
-
})
|
|
268
|
+
onExpand = () => {
|
|
287
269
|
this.closeNewGroupForm()
|
|
288
|
-
window.store.expandedKeys = deepCopy(expandedKeys)
|
|
289
270
|
}
|
|
290
271
|
|
|
291
272
|
onSelect = (
|
|
@@ -303,8 +284,7 @@ export default class ItemListTree extends Component {
|
|
|
303
284
|
currentBookmarkGroupId: findBookmarkGroupId(store.bookmarkGroups, id)
|
|
304
285
|
})
|
|
305
286
|
const { bookmarks } = this.props
|
|
306
|
-
const bookmark = find(
|
|
307
|
-
bookmarks,
|
|
287
|
+
const bookmark = bookmarks.find(
|
|
308
288
|
d => d.id === id
|
|
309
289
|
)
|
|
310
290
|
if (bookmark) {
|
|
@@ -342,13 +322,10 @@ export default class ItemListTree extends Component {
|
|
|
342
322
|
return {
|
|
343
323
|
showNewBookmarkGroupForm: true,
|
|
344
324
|
parentId: item.id,
|
|
345
|
-
bookmarkGroupTitle: ''
|
|
346
|
-
expandedKeys: uniq([
|
|
347
|
-
...old.expandedKeys,
|
|
348
|
-
item.id
|
|
349
|
-
])
|
|
325
|
+
bookmarkGroupTitle: ''
|
|
350
326
|
}
|
|
351
327
|
})
|
|
328
|
+
window.store.expandedKeys.push(item.id)
|
|
352
329
|
}
|
|
353
330
|
|
|
354
331
|
openAll = (item) => {
|
|
@@ -745,7 +722,7 @@ export default class ItemListTree extends Component {
|
|
|
745
722
|
level,
|
|
746
723
|
group,
|
|
747
724
|
keyword: this.state.keyword,
|
|
748
|
-
expandedKeys: this.
|
|
725
|
+
expandedKeys: this.props.expandedKeys,
|
|
749
726
|
onExpand: this.onExpandKey,
|
|
750
727
|
onUnExpand: this.onUnExpandKey
|
|
751
728
|
}
|
|
@@ -766,7 +743,7 @@ export default class ItemListTree extends Component {
|
|
|
766
743
|
bookmarkGroupIds = [],
|
|
767
744
|
id
|
|
768
745
|
} = group
|
|
769
|
-
const shouldRender = this.state.keyword || this.
|
|
746
|
+
const shouldRender = this.state.keyword || this.props.expandedKeys.includes(id)
|
|
770
747
|
if (!shouldRender) {
|
|
771
748
|
return null
|
|
772
749
|
}
|
|
@@ -786,8 +763,16 @@ export default class ItemListTree extends Component {
|
|
|
786
763
|
}
|
|
787
764
|
|
|
788
765
|
renderChilds = (bookmarkIds, pid) => {
|
|
766
|
+
const tree = this.props.bookmarksMap
|
|
767
|
+
const { keyword } = this.state
|
|
789
768
|
const bookmarks = bookmarkIds.map(id => {
|
|
790
|
-
|
|
769
|
+
const item = tree.get(id)
|
|
770
|
+
if (!item) {
|
|
771
|
+
return null
|
|
772
|
+
}
|
|
773
|
+
return createName(item).toLowerCase().includes(keyword.toLowerCase())
|
|
774
|
+
? item
|
|
775
|
+
: null
|
|
791
776
|
}).filter(d => d)
|
|
792
777
|
return bookmarks.map((node) => {
|
|
793
778
|
return this.renderItemTitle(node, false, pid)
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* bookmark group functions
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { find } from 'lodash-es'
|
|
6
5
|
import {
|
|
7
6
|
defaultBookmarkGroupId,
|
|
8
7
|
settingMap
|
|
@@ -32,7 +31,7 @@ export default Store => {
|
|
|
32
31
|
const gids = item.bookmarkGroupIds || []
|
|
33
32
|
const bookmarkGroups = store.bookmarkGroups
|
|
34
33
|
for (const gid of gids) {
|
|
35
|
-
const g = find(
|
|
34
|
+
const g = bookmarkGroups.find(g => g.id === gid)
|
|
36
35
|
if (g && g.bookmarkIds && g.bookmarkIds.length) {
|
|
37
36
|
ids = [
|
|
38
37
|
...ids,
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
qmSortByFrequencyKey,
|
|
21
21
|
resolutionsLsKey,
|
|
22
22
|
aiChatHistoryKey,
|
|
23
|
+
syncServerDataKey,
|
|
23
24
|
splitMap
|
|
24
25
|
} from '../common/constants'
|
|
25
26
|
import { buildDefaultThemes } from '../common/terminal-theme'
|
|
@@ -52,6 +53,7 @@ export default () => {
|
|
|
52
53
|
history: ls.getItemJSON('history', []),
|
|
53
54
|
sshConfigs: [],
|
|
54
55
|
bookmarks: [],
|
|
56
|
+
bookmarksMap: new Map(),
|
|
55
57
|
sidebarPanelTab: 'bookmarks',
|
|
56
58
|
profiles: [],
|
|
57
59
|
bookmarkGroups: getDefaultBookmarkGroups([]),
|
|
@@ -123,6 +125,8 @@ export default () => {
|
|
|
123
125
|
isSyncUpload: false,
|
|
124
126
|
isSyncDownload: false,
|
|
125
127
|
syncType: syncTypes.github,
|
|
128
|
+
// syncServerData: {},
|
|
129
|
+
syncServerStatus: ls.getItemJSON(syncServerDataKey, {}),
|
|
126
130
|
|
|
127
131
|
// term search
|
|
128
132
|
termSearchOpen: false,
|
package/client/store/item.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* common db op
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { find } from 'lodash-es'
|
|
6
5
|
import deepCopy from 'json-deep-copy'
|
|
7
6
|
import {
|
|
8
7
|
settingMap
|
|
@@ -23,7 +22,7 @@ export default Store => {
|
|
|
23
22
|
Store.prototype.editItem = function (id, updates, type) {
|
|
24
23
|
const { store } = window
|
|
25
24
|
const items = store.getItems(type)
|
|
26
|
-
const item = find(
|
|
25
|
+
const item = items.find(t => t.id === id)
|
|
27
26
|
if (!item) {
|
|
28
27
|
return
|
|
29
28
|
}
|
|
@@ -115,7 +115,7 @@ export default (Store) => {
|
|
|
115
115
|
if (!arr.length && store.config.initDefaultTabOnStart) {
|
|
116
116
|
store.initFirstTab()
|
|
117
117
|
}
|
|
118
|
-
|
|
118
|
+
store.confirmLoad()
|
|
119
119
|
const { initTime, loadTime } = window.pre.runSync('getLoadTime')
|
|
120
120
|
if (loadTime) {
|
|
121
121
|
store.loadTime = loadTime
|
|
@@ -166,6 +166,11 @@ export default (Store) => {
|
|
|
166
166
|
for (const { name, data } of arr) {
|
|
167
167
|
const dt = JSON.parse(data || '[]')
|
|
168
168
|
refsStatic.add('oldState-' + name, dt)
|
|
169
|
+
if (name === 'bookmarks') {
|
|
170
|
+
ext.bookmarksMap = new Map(
|
|
171
|
+
dt.map(d => [d.id, d])
|
|
172
|
+
)
|
|
173
|
+
}
|
|
169
174
|
ext[name] = dt
|
|
170
175
|
}
|
|
171
176
|
})
|
package/client/store/setting.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* setting modal
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
import { find } from 'lodash-es'
|
|
6
5
|
import {
|
|
7
6
|
message
|
|
8
7
|
} from 'antd'
|
|
@@ -66,7 +65,7 @@ export default Store => {
|
|
|
66
65
|
const { store } = window
|
|
67
66
|
const bookmarks = store.bookmarks
|
|
68
67
|
const item = copy(
|
|
69
|
-
find(
|
|
68
|
+
bookmarks.find(it => it.id === id)
|
|
70
69
|
)
|
|
71
70
|
if (!item) {
|
|
72
71
|
return
|
package/client/store/store.js
CHANGED
|
@@ -31,17 +31,18 @@ import deepCopy from 'json-deep-copy'
|
|
|
31
31
|
import getBrand from '../components/ai/get-brand'
|
|
32
32
|
import {
|
|
33
33
|
settingMap,
|
|
34
|
-
paneMap,
|
|
35
34
|
settingSyncId,
|
|
36
35
|
settingShortcutsId,
|
|
37
36
|
settingTerminalId,
|
|
38
|
-
terminalSshConfigType
|
|
37
|
+
terminalSshConfigType,
|
|
38
|
+
paneMap
|
|
39
39
|
} from '../common/constants'
|
|
40
40
|
import getInitItem from '../common/init-setting-item'
|
|
41
41
|
import createTitle from '../common/create-title'
|
|
42
42
|
import {
|
|
43
43
|
theme
|
|
44
44
|
} from 'antd'
|
|
45
|
+
import { refs } from '../components/common/ref'
|
|
45
46
|
|
|
46
47
|
const e = window.translate
|
|
47
48
|
|
|
@@ -65,7 +66,7 @@ class Store {
|
|
|
65
66
|
const { currentTab } = this
|
|
66
67
|
const { quickCommands } = window.store
|
|
67
68
|
const currentTabQuickCommands = (
|
|
68
|
-
currentTab
|
|
69
|
+
currentTab?.quickCommands || []
|
|
69
70
|
).map((d, i) => {
|
|
70
71
|
return {
|
|
71
72
|
...d,
|
|
@@ -82,12 +83,11 @@ class Store {
|
|
|
82
83
|
const {
|
|
83
84
|
activeTabId
|
|
84
85
|
} = this
|
|
85
|
-
const
|
|
86
|
-
const tab = tabs.find(t => t.id === activeTabId)
|
|
86
|
+
const tab = refs.get('tab-' + activeTabId)
|
|
87
87
|
if (!tab) {
|
|
88
|
-
return
|
|
88
|
+
return null
|
|
89
89
|
}
|
|
90
|
-
return tab
|
|
90
|
+
return tab.props.tab
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
get batchInputSelectedTabIds () {
|
|
@@ -112,21 +112,19 @@ class Store {
|
|
|
112
112
|
if (store.showModal) {
|
|
113
113
|
return false
|
|
114
114
|
}
|
|
115
|
-
const {
|
|
116
|
-
currentTab
|
|
117
|
-
} = store
|
|
115
|
+
const { currentTab } = store
|
|
118
116
|
if (!currentTab) {
|
|
119
117
|
return false
|
|
120
118
|
}
|
|
121
119
|
const {
|
|
122
|
-
type
|
|
123
|
-
pane
|
|
120
|
+
type
|
|
124
121
|
} = currentTab
|
|
125
|
-
if (type === '
|
|
122
|
+
if (type === 'web' || type === 'rdp' || type === 'vnc') {
|
|
126
123
|
return false
|
|
127
124
|
}
|
|
128
|
-
return
|
|
129
|
-
|
|
125
|
+
return currentTab.sshSftpSplitView ||
|
|
126
|
+
currentTab.pane === paneMap.terminal ||
|
|
127
|
+
currentTab.pane === paneMap.ssh
|
|
130
128
|
}
|
|
131
129
|
|
|
132
130
|
get quickCommandTags () {
|
package/client/store/sync.js
CHANGED
|
@@ -34,6 +34,13 @@ async function fetchData (type, func, args, token, proxy) {
|
|
|
34
34
|
return fetch(data)
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
function updateSyncServerStatusFromGist (store, gist, type) {
|
|
38
|
+
const status = parseJsonSafe(
|
|
39
|
+
get(gist, 'files["electerm-status.json"].content')
|
|
40
|
+
)
|
|
41
|
+
store.syncServerStatus[type] = status
|
|
42
|
+
}
|
|
43
|
+
|
|
37
44
|
export default (Store) => {
|
|
38
45
|
Store.prototype.updateSyncSetting = function (data) {
|
|
39
46
|
const { store } = window
|
|
@@ -167,6 +174,20 @@ export default (Store) => {
|
|
|
167
174
|
window[type + 'IsSyncing'] = false
|
|
168
175
|
}
|
|
169
176
|
|
|
177
|
+
Store.prototype.previewServerData = async function (type) {
|
|
178
|
+
const { store } = window
|
|
179
|
+
const token = store.getSyncToken(type)
|
|
180
|
+
const gistId = store.getSyncGistId(type)
|
|
181
|
+
const gist = await fetchData(
|
|
182
|
+
type,
|
|
183
|
+
'getOne',
|
|
184
|
+
[gistId],
|
|
185
|
+
token,
|
|
186
|
+
store.getProxySetting()
|
|
187
|
+
)
|
|
188
|
+
updateSyncServerStatusFromGist(store, gist, type)
|
|
189
|
+
}
|
|
190
|
+
|
|
170
191
|
Store.prototype.uploadSettingAction = async function (type) {
|
|
171
192
|
const { store } = window
|
|
172
193
|
const token = store.getSyncToken(type)
|
|
@@ -212,22 +233,33 @@ export default (Store) => {
|
|
|
212
233
|
}
|
|
213
234
|
}
|
|
214
235
|
}
|
|
215
|
-
const
|
|
236
|
+
const now = Date.now()
|
|
237
|
+
const status = {
|
|
238
|
+
lastSyncTime: now,
|
|
239
|
+
electermVersion: packVer,
|
|
240
|
+
deviceName: window.pre.osInfo().find(r => r.k === 'hostname')?.v || 'unknown'
|
|
241
|
+
}
|
|
242
|
+
const gistData = {
|
|
216
243
|
description: 'sync electerm data',
|
|
217
244
|
files: {
|
|
218
245
|
...objs,
|
|
219
246
|
'electerm-status.json': {
|
|
220
|
-
content: JSON.stringify(
|
|
221
|
-
lastSyncTime: Date.now(),
|
|
222
|
-
electermVersion: packVer
|
|
223
|
-
})
|
|
247
|
+
content: JSON.stringify(status)
|
|
224
248
|
}
|
|
225
249
|
}
|
|
226
|
-
}
|
|
250
|
+
}
|
|
251
|
+
const res = await fetchData(
|
|
252
|
+
type,
|
|
253
|
+
'update',
|
|
254
|
+
[gistId, gistData],
|
|
255
|
+
token,
|
|
256
|
+
store.getProxySetting()
|
|
257
|
+
)
|
|
227
258
|
if (res) {
|
|
228
259
|
store.updateSyncSetting({
|
|
229
|
-
[type + 'LastSyncTime']:
|
|
260
|
+
[type + 'LastSyncTime']: now
|
|
230
261
|
})
|
|
262
|
+
updateSyncServerStatusFromGist(store, gistData, type)
|
|
231
263
|
}
|
|
232
264
|
}
|
|
233
265
|
|
|
@@ -259,6 +291,9 @@ export default (Store) => {
|
|
|
259
291
|
token,
|
|
260
292
|
store.getProxySetting()
|
|
261
293
|
)
|
|
294
|
+
if (gist) {
|
|
295
|
+
updateSyncServerStatusFromGist(store, gist, type)
|
|
296
|
+
}
|
|
262
297
|
const { names, syncConfig } = store.getDataSyncNames()
|
|
263
298
|
for (const n of names) {
|
|
264
299
|
let str = get(gist, `files["${n}.json"].content`)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { message } from 'antd'
|
|
6
|
-
import {
|
|
6
|
+
import { isEqual } from 'lodash-es'
|
|
7
7
|
import {
|
|
8
8
|
defaultTheme,
|
|
9
9
|
settingMap,
|
|
@@ -42,7 +42,7 @@ export default Store => {
|
|
|
42
42
|
Store.prototype.getThemeConfig = function () {
|
|
43
43
|
const { store } = window
|
|
44
44
|
const all = store.getSidebarList(settingMap.terminalThemes)
|
|
45
|
-
return (find(
|
|
45
|
+
return (all.find(d => d.id === store.config.theme) || {}).themeConfig || {}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
Store.prototype.fixThemes = function (themes) {
|
|
@@ -82,7 +82,7 @@ export default Store => {
|
|
|
82
82
|
Store.prototype.checkDefaultTheme = async function (terminalThemes) {
|
|
83
83
|
const { store } = window
|
|
84
84
|
const themeId = defaultTheme.id
|
|
85
|
-
const currentDefaultTheme =
|
|
85
|
+
const currentDefaultTheme = store.terminalThemes.find(d => d.id === themeId)
|
|
86
86
|
if (
|
|
87
87
|
currentDefaultTheme &&
|
|
88
88
|
(
|
|
@@ -102,7 +102,7 @@ export default Store => {
|
|
|
102
102
|
`${e('default')} ${e('themeConfig')} ${e('updated')}`
|
|
103
103
|
)
|
|
104
104
|
}
|
|
105
|
-
const hasLightTheme =
|
|
105
|
+
const hasLightTheme = store.getTerminalThemes().find(d => d.id === defaultThemeLight.id)
|
|
106
106
|
if (!hasLightTheme) {
|
|
107
107
|
store.addTheme(defaultThemeLight)
|
|
108
108
|
}
|
package/client/store/ui-theme.js
CHANGED
|
@@ -2,16 +2,11 @@
|
|
|
2
2
|
* ui theme functions
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
* theme related functions
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { escapeRegExp, find } from 'lodash-es'
|
|
5
|
+
import { escapeRegExp } from 'lodash-es'
|
|
10
6
|
import {
|
|
11
7
|
defaultTheme,
|
|
12
8
|
settingMap
|
|
13
9
|
} from '../common/constants'
|
|
14
|
-
// import fetch from '../common/fetch'
|
|
15
10
|
import copy from 'json-deep-copy'
|
|
16
11
|
|
|
17
12
|
export default Store => {
|
|
@@ -51,10 +46,8 @@ export default Store => {
|
|
|
51
46
|
|
|
52
47
|
Store.prototype.getUiThemeConfig = function () {
|
|
53
48
|
const { store } = window
|
|
54
|
-
const theme =
|
|
55
|
-
|
|
56
|
-
d => d.id === store.config.theme
|
|
57
|
-
)
|
|
49
|
+
const theme = store.getSidebarList(settingMap.terminalThemes)
|
|
50
|
+
.find(d => d.id === store.config.theme)
|
|
58
51
|
return theme && theme.uiThemeConfig
|
|
59
52
|
? copy(theme.uiThemeConfig)
|
|
60
53
|
: defaultTheme.uiThemeConfig
|