@electerm/electerm-react 1.51.1 → 1.51.3
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/components/footer/batch-input.jsx +10 -10
- package/client/components/footer/footer-entry.jsx +3 -3
- package/client/components/footer/tab-select.jsx +2 -2
- package/client/components/layout/layout.jsx +7 -7
- package/client/components/session/session.jsx +7 -2
- package/client/components/session/sessions.jsx +4 -4
- package/client/components/shortcuts/shortcut-control.jsx +3 -3
- package/client/components/tabs/index.jsx +8 -8
- package/client/components/tabs/tab.jsx +4 -4
- package/client/components/terminal/index.jsx +12 -15
- package/client/components/terminal/term-search.jsx +4 -4
- package/client/store/event.js +1 -1
- package/client/store/index.js +2 -2
- package/client/store/init-state.js +5 -5
- package/client/store/quick-command.js +1 -1
- package/client/store/session.js +1 -1
- package/client/store/tab.js +31 -31
- package/client/store/watch.js +4 -4
- package/package.json +1 -1
|
@@ -26,19 +26,19 @@ export default class BatchInput extends Component {
|
|
|
26
26
|
super(props)
|
|
27
27
|
this.state = {
|
|
28
28
|
cmd: '',
|
|
29
|
-
selectedTabIds: [props.
|
|
29
|
+
selectedTabIds: [props.activeTabId],
|
|
30
30
|
open: false,
|
|
31
31
|
enter: false
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
componentDidUpdate (prevProps) {
|
|
36
|
-
if (prevProps.
|
|
36
|
+
if (prevProps.activeTabId !== this.props.activeTabId) {
|
|
37
37
|
this.setState(prevState => {
|
|
38
38
|
const newSelectedTabIds = prevState.selectedTabIds.filter(
|
|
39
|
-
id => id !== this.props.
|
|
39
|
+
id => id !== this.props.activeTabId
|
|
40
40
|
)
|
|
41
|
-
newSelectedTabIds.unshift(this.props.
|
|
41
|
+
newSelectedTabIds.unshift(this.props.activeTabId)
|
|
42
42
|
return {
|
|
43
43
|
selectedTabIds: newSelectedTabIds
|
|
44
44
|
}
|
|
@@ -72,7 +72,7 @@ export default class BatchInput extends Component {
|
|
|
72
72
|
|
|
73
73
|
onSelectNone = () => {
|
|
74
74
|
this.setState({
|
|
75
|
-
selectedTabIds: [this.props.
|
|
75
|
+
selectedTabIds: [this.props.activeTabId]
|
|
76
76
|
})
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -91,7 +91,7 @@ export default class BatchInput extends Component {
|
|
|
91
91
|
// Ensure at least the current tab is selected
|
|
92
92
|
if (selectedTabIds.length === 0) {
|
|
93
93
|
return {
|
|
94
|
-
selectedTabIds: [this.props.
|
|
94
|
+
selectedTabIds: [this.props.activeTabId]
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -178,15 +178,15 @@ export default class BatchInput extends Component {
|
|
|
178
178
|
}
|
|
179
179
|
|
|
180
180
|
getTabs = () => {
|
|
181
|
-
const {
|
|
181
|
+
const { activeTabId } = this.props
|
|
182
182
|
return deepCopy(this.props.tabs.filter(tab => {
|
|
183
183
|
return tab.type !== terminalWebType &&
|
|
184
184
|
tab.type !== terminalRdpType &&
|
|
185
185
|
tab.type !== terminalVncType
|
|
186
186
|
})).sort((a, b) => {
|
|
187
187
|
// Current tab goes first
|
|
188
|
-
if (a.id ===
|
|
189
|
-
if (b.id ===
|
|
188
|
+
if (a.id === activeTabId) return -1
|
|
189
|
+
if (b.id === activeTabId) return 1
|
|
190
190
|
return 0
|
|
191
191
|
})
|
|
192
192
|
}
|
|
@@ -215,7 +215,7 @@ export default class BatchInput extends Component {
|
|
|
215
215
|
className: 'batch-input-holder'
|
|
216
216
|
}
|
|
217
217
|
const tabSelectProps = {
|
|
218
|
-
|
|
218
|
+
activeTabId: this.props.activeTabId,
|
|
219
219
|
tabs: this.getTabs(),
|
|
220
220
|
selectedTabIds,
|
|
221
221
|
onSelectAll: this.onSelectAll,
|
|
@@ -22,7 +22,7 @@ export default auto(function FooterEntry (props) {
|
|
|
22
22
|
store.rightPanelVisible = !store.rightPanelVisible
|
|
23
23
|
postMessage({
|
|
24
24
|
action: terminalActions.showInfoPanel,
|
|
25
|
-
|
|
25
|
+
activeTabId: store.activeTabId
|
|
26
26
|
})
|
|
27
27
|
}
|
|
28
28
|
|
|
@@ -38,7 +38,7 @@ export default auto(function FooterEntry (props) {
|
|
|
38
38
|
postMessage({
|
|
39
39
|
encode,
|
|
40
40
|
action: terminalActions.changeEncode,
|
|
41
|
-
|
|
41
|
+
activeTabId: props.store.activeTabId
|
|
42
42
|
})
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -58,7 +58,7 @@ export default auto(function FooterEntry (props) {
|
|
|
58
58
|
input: batchInput,
|
|
59
59
|
batchInputs: props.store.batchInputs,
|
|
60
60
|
tabs: props.store.tabs,
|
|
61
|
-
|
|
61
|
+
activeTabId: props.store.activeTabId
|
|
62
62
|
}
|
|
63
63
|
return (
|
|
64
64
|
<div className='terminal-footer-unit terminal-footer-center'>
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from '@ant-design/icons'
|
|
8
8
|
|
|
9
9
|
export default function TabSelect (props) {
|
|
10
|
-
const { selectedTabIds, tabs,
|
|
10
|
+
const { selectedTabIds, tabs, activeTabId } = props
|
|
11
11
|
function renderTabs () {
|
|
12
12
|
return tabs.map(tab => {
|
|
13
13
|
const selected = selectedTabIds.includes(tab.id)
|
|
@@ -16,7 +16,7 @@ export default function TabSelect (props) {
|
|
|
16
16
|
selected,
|
|
17
17
|
onSelect: props.onSelect,
|
|
18
18
|
id: tab.id,
|
|
19
|
-
isCurrent: tab.id ===
|
|
19
|
+
isCurrent: tab.id === activeTabId
|
|
20
20
|
}
|
|
21
21
|
return (
|
|
22
22
|
<TabItem
|
|
@@ -102,7 +102,7 @@ export default auto(function Layout (props) {
|
|
|
102
102
|
const sessProps = {
|
|
103
103
|
batch: i,
|
|
104
104
|
layout,
|
|
105
|
-
currentBatchTabId: store[`
|
|
105
|
+
currentBatchTabId: store[`activeTabId${i}`],
|
|
106
106
|
...v,
|
|
107
107
|
tabs: tabsBatch[i] || [],
|
|
108
108
|
...pick(store, [
|
|
@@ -132,7 +132,7 @@ export default auto(function Layout (props) {
|
|
|
132
132
|
currentTab,
|
|
133
133
|
config,
|
|
134
134
|
...pick(store, [
|
|
135
|
-
'
|
|
135
|
+
'activeTabId',
|
|
136
136
|
'termSearchOpen',
|
|
137
137
|
'termSearch',
|
|
138
138
|
'termSearchOptions',
|
|
@@ -161,11 +161,11 @@ export default auto(function Layout (props) {
|
|
|
161
161
|
height,
|
|
162
162
|
layoutStyle: pixedLayoutStyle,
|
|
163
163
|
...pick(store, [
|
|
164
|
-
'
|
|
165
|
-
'
|
|
166
|
-
'
|
|
167
|
-
'
|
|
168
|
-
'
|
|
164
|
+
'activeTabId',
|
|
165
|
+
'activeTabId0',
|
|
166
|
+
'activeTabId1',
|
|
167
|
+
'activeTabId2',
|
|
168
|
+
'activeTabId3',
|
|
169
169
|
'batch',
|
|
170
170
|
'resolutions',
|
|
171
171
|
'hideDelKeyTip',
|
|
@@ -61,6 +61,10 @@ export default class SessionWrapper extends Component {
|
|
|
61
61
|
return document.getElementById(`is-${this.props.tab.id}`)
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
handleClick = () => {
|
|
65
|
+
window.store.activeTabId = this.props.tab.id
|
|
66
|
+
}
|
|
67
|
+
|
|
64
68
|
onDrop = (e) => {
|
|
65
69
|
e.preventDefault()
|
|
66
70
|
const { target } = e
|
|
@@ -337,7 +341,7 @@ export default class SessionWrapper extends Component {
|
|
|
337
341
|
handleOpenSearch = () => {
|
|
338
342
|
postMessage({
|
|
339
343
|
action: terminalActions.openTerminalSearch,
|
|
340
|
-
|
|
344
|
+
activeTabId: this.props.tab.id
|
|
341
345
|
})
|
|
342
346
|
}
|
|
343
347
|
|
|
@@ -501,7 +505,8 @@ export default class SessionWrapper extends Component {
|
|
|
501
505
|
onDragEnter: this.onDragEnter,
|
|
502
506
|
onDragLeave: this.onDragLeave,
|
|
503
507
|
onDrop: this.onDrop,
|
|
504
|
-
onDragEnd: this.onDragEnd
|
|
508
|
+
onDragEnd: this.onDragEnd,
|
|
509
|
+
onClick: this.handleClick
|
|
505
510
|
}
|
|
506
511
|
return (
|
|
507
512
|
<div
|
|
@@ -42,17 +42,17 @@ export default class Sessions extends Component {
|
|
|
42
42
|
const {
|
|
43
43
|
config,
|
|
44
44
|
tabs,
|
|
45
|
-
|
|
45
|
+
activeTabId,
|
|
46
46
|
sizes
|
|
47
47
|
} = this.props
|
|
48
48
|
return tabs.map((tab) => {
|
|
49
49
|
const { id, batch } = tab
|
|
50
50
|
const { height, width } = sizes[batch]
|
|
51
|
-
const currentBatchTabId = this.props['
|
|
51
|
+
const currentBatchTabId = this.props['activeTabId' + batch]
|
|
52
52
|
const cls = classNames(
|
|
53
53
|
`session-wrap session-${id}`,
|
|
54
54
|
{
|
|
55
|
-
'session-current': id ===
|
|
55
|
+
'session-current': id === activeTabId,
|
|
56
56
|
'session-batch-active': id === currentBatchTabId
|
|
57
57
|
}
|
|
58
58
|
)
|
|
@@ -61,7 +61,7 @@ export default class Sessions extends Component {
|
|
|
61
61
|
className: cls
|
|
62
62
|
}
|
|
63
63
|
const sessProps = {
|
|
64
|
-
|
|
64
|
+
activeTabId,
|
|
65
65
|
tab,
|
|
66
66
|
width,
|
|
67
67
|
height,
|
|
@@ -15,9 +15,9 @@ class ShortcutControl extends React.PureComponent {
|
|
|
15
15
|
|
|
16
16
|
closeCurrentTabShortcut = throttle((e) => {
|
|
17
17
|
e.stopPropagation()
|
|
18
|
-
const {
|
|
19
|
-
if (
|
|
20
|
-
window.store.delTab(
|
|
18
|
+
const { activeTabId } = window.store
|
|
19
|
+
if (activeTabId) {
|
|
20
|
+
window.store.delTab(activeTabId)
|
|
21
21
|
}
|
|
22
22
|
}, 500)
|
|
23
23
|
|
|
@@ -60,8 +60,7 @@ export default class Tabs extends React.Component {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
componentDidMount () {
|
|
63
|
-
|
|
64
|
-
this.dom = document.querySelector(`.v${batch + 1} .tabs-inner`)
|
|
63
|
+
this.domRef = React.createRef()
|
|
65
64
|
const {
|
|
66
65
|
tabsRef
|
|
67
66
|
} = this
|
|
@@ -239,28 +238,28 @@ export default class Tabs extends React.Component {
|
|
|
239
238
|
const scrollLeft = w > tabsInnerWidth
|
|
240
239
|
? w - tabsInnerWidth
|
|
241
240
|
: 0
|
|
242
|
-
this.
|
|
241
|
+
this.domRef.current.scrollTo({ left: scrollLeft, behavior: 'smooth' })
|
|
243
242
|
this.setState({
|
|
244
243
|
overflow: this.isOverflow()
|
|
245
244
|
})
|
|
246
245
|
}
|
|
247
246
|
|
|
248
247
|
handleScrollLeft = () => {
|
|
249
|
-
let { scrollLeft } = this.
|
|
248
|
+
let { scrollLeft } = this.domRef.current
|
|
250
249
|
scrollLeft = scrollLeft - tabMargin - tabWidth
|
|
251
250
|
if (scrollLeft < 0) {
|
|
252
251
|
scrollLeft = 0
|
|
253
252
|
}
|
|
254
|
-
this.
|
|
253
|
+
this.domRef.current.scrollTo({ left: scrollLeft, behavior: 'smooth' })
|
|
255
254
|
}
|
|
256
255
|
|
|
257
256
|
handleScrollRight = () => {
|
|
258
|
-
let { scrollLeft } = this.
|
|
257
|
+
let { scrollLeft } = this.domRef.current
|
|
259
258
|
scrollLeft = scrollLeft + tabMargin + tabWidth
|
|
260
259
|
if (scrollLeft < 0) {
|
|
261
260
|
scrollLeft = 0
|
|
262
261
|
}
|
|
263
|
-
this.
|
|
262
|
+
this.domRef.current.scrollTo({ left: scrollLeft, behavior: 'smooth' })
|
|
264
263
|
}
|
|
265
264
|
|
|
266
265
|
handleWheelEvent = debounce((e) => {
|
|
@@ -275,7 +274,7 @@ export default class Tabs extends React.Component {
|
|
|
275
274
|
|
|
276
275
|
handleClickMenu = ({ key }) => {
|
|
277
276
|
const id = key.split('##')[1]
|
|
278
|
-
window.store['
|
|
277
|
+
window.store['activeTabId' + this.props.batch] = id
|
|
279
278
|
}
|
|
280
279
|
|
|
281
280
|
handleChangeLayout = ({ key }) => {
|
|
@@ -415,6 +414,7 @@ export default class Tabs extends React.Component {
|
|
|
415
414
|
return (
|
|
416
415
|
<div
|
|
417
416
|
className='tabs-inner'
|
|
417
|
+
ref={this.domRef}
|
|
418
418
|
style={style}
|
|
419
419
|
>
|
|
420
420
|
<div
|
|
@@ -47,9 +47,9 @@ class Tab extends Component {
|
|
|
47
47
|
// }
|
|
48
48
|
|
|
49
49
|
// shouldUpdate = (prevProps, nextProps) => {
|
|
50
|
-
// // todo
|
|
50
|
+
// // todo activeTabId still need improve
|
|
51
51
|
// const pickKeys = [
|
|
52
|
-
// '
|
|
52
|
+
// 'activeTabId',
|
|
53
53
|
// 'height',
|
|
54
54
|
// 'isLast',
|
|
55
55
|
// 'isMaximized',
|
|
@@ -137,12 +137,12 @@ class Tab extends Component {
|
|
|
137
137
|
const fromBatch = fromTab.batch
|
|
138
138
|
|
|
139
139
|
// Handle currentTab change if needed
|
|
140
|
-
if (window.store[`
|
|
140
|
+
if (window.store[`activeTabId${fromBatch}`] === id && fromBatch !== targetTab.batch) {
|
|
141
141
|
// Find next tab in the same batch
|
|
142
142
|
const nextTab = storeTabs.find((t, i) =>
|
|
143
143
|
i !== indexFrom && t.batch === fromBatch
|
|
144
144
|
)
|
|
145
|
-
window.store[`
|
|
145
|
+
window.store[`activeTabId${fromBatch}`] = nextTab ? nextTab.id : ''
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
// Reorder tabs and update batch
|
|
@@ -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
|
|
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
|
}
|
|
@@ -47,7 +47,7 @@ export default () => {
|
|
|
47
47
|
loadTime: 0,
|
|
48
48
|
lastDataUpdateTime: 0,
|
|
49
49
|
tabs: [],
|
|
50
|
-
|
|
50
|
+
activeTabId: '',
|
|
51
51
|
_history: '[]',
|
|
52
52
|
_bookmarks: '[]',
|
|
53
53
|
_profiles: '[]',
|
|
@@ -95,10 +95,10 @@ export default () => {
|
|
|
95
95
|
prevLayout: layout,
|
|
96
96
|
resizeTrigger: 0,
|
|
97
97
|
currentLayoutBatch: 0,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
activeTabId0: '',
|
|
99
|
+
activeTabId1: '',
|
|
100
|
+
activeTabId2: '',
|
|
101
|
+
activeTabId3: '',
|
|
102
102
|
_terminalInfoProps: '{}',
|
|
103
103
|
rightPanelVisible: false,
|
|
104
104
|
rightPanelPinned: false,
|
package/client/store/session.js
CHANGED
package/client/store/tab.js
CHANGED
|
@@ -60,10 +60,10 @@ export default Store => {
|
|
|
60
60
|
const closingTab = tabs[i]
|
|
61
61
|
if (closingTab.batch === targetBatch) {
|
|
62
62
|
// Handle current tab closure
|
|
63
|
-
if (closingTab.id === store.
|
|
64
|
-
store.
|
|
65
|
-
} else if (closingTab.id === store[`
|
|
66
|
-
store[`
|
|
63
|
+
if (closingTab.id === store.activeTabId) {
|
|
64
|
+
store.activeTabId = id
|
|
65
|
+
} else if (closingTab.id === store[`activeTabId${targetBatch}`]) {
|
|
66
|
+
store[`activeTabId${targetBatch}`] = id
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
tabs.splice(i, 1)
|
|
@@ -71,7 +71,7 @@ export default Store => {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
Store.prototype.reloadTab = function (tabId = window.store.
|
|
74
|
+
Store.prototype.reloadTab = function (tabId = window.store.activeTabId) {
|
|
75
75
|
const { store } = window
|
|
76
76
|
const { tabs } = store
|
|
77
77
|
const index = tabs.findIndex(t => t.id === tabId)
|
|
@@ -97,12 +97,12 @@ export default Store => {
|
|
|
97
97
|
tabs.splice(index, 1)
|
|
98
98
|
|
|
99
99
|
// Update current tab ID if needed
|
|
100
|
-
if (store.
|
|
101
|
-
store.
|
|
100
|
+
if (store.activeTabId === tabId) {
|
|
101
|
+
store.activeTabId = newTab.id
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
// Update batch current tab ID if needed
|
|
105
|
-
const batchProp = `
|
|
105
|
+
const batchProp = `activeTabId${oldTab.batch}`
|
|
106
106
|
if (store[batchProp] === tabId) {
|
|
107
107
|
store[batchProp] = newTab.id
|
|
108
108
|
}
|
|
@@ -130,8 +130,8 @@ export default Store => {
|
|
|
130
130
|
tabs.splice(targetIndex + 1, 0, duplicatedTab)
|
|
131
131
|
|
|
132
132
|
// Set the duplicated tab as current
|
|
133
|
-
store.
|
|
134
|
-
store[`
|
|
133
|
+
store.activeTabId = duplicatedTab.id
|
|
134
|
+
store[`activeTabId${sourceTab.batch}`] = duplicatedTab.id
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
Store.prototype.closeOtherTabs = function (id) {
|
|
@@ -146,11 +146,11 @@ export default Store => {
|
|
|
146
146
|
for (let i = tabs.length - 1; i >= 0; i--) {
|
|
147
147
|
const tab = tabs[i]
|
|
148
148
|
if (tab.batch === currentBatch && tab.id !== id) {
|
|
149
|
-
if (tab.id === store.
|
|
150
|
-
store.
|
|
149
|
+
if (tab.id === store.activeTabId) {
|
|
150
|
+
store.activeTabId = id
|
|
151
151
|
}
|
|
152
|
-
if (tab.id === store[`
|
|
153
|
-
store[`
|
|
152
|
+
if (tab.id === store[`activeTabId${currentBatch}`]) {
|
|
153
|
+
store[`activeTabId${currentBatch}`] = id
|
|
154
154
|
}
|
|
155
155
|
tabs.splice(i, 1)
|
|
156
156
|
}
|
|
@@ -208,7 +208,7 @@ export default Store => {
|
|
|
208
208
|
const store = window.store
|
|
209
209
|
const removedSet = new Set(removedIds)
|
|
210
210
|
const batchFirstTabs = {}
|
|
211
|
-
const currentIdNeedFix = removedSet.has(store.
|
|
211
|
+
const currentIdNeedFix = removedSet.has(store.activeTabId)
|
|
212
212
|
|
|
213
213
|
// Get first valid tab for each batch
|
|
214
214
|
for (const tab of remainingTabs) {
|
|
@@ -220,23 +220,23 @@ export default Store => {
|
|
|
220
220
|
// If current tab was removed, we need to set a new one
|
|
221
221
|
if (currentIdNeedFix) {
|
|
222
222
|
// Try to find current batch's first tab
|
|
223
|
-
const currentTab = remainingTabs.find(t => t.id === store.
|
|
223
|
+
const currentTab = remainingTabs.find(t => t.id === store.activeTabId)
|
|
224
224
|
const currentBatch = currentTab ? currentTab.batch : store.currentLayoutBatch
|
|
225
225
|
const newCurrentId = batchFirstTabs[currentBatch] || batchFirstTabs[0] || ''
|
|
226
226
|
|
|
227
227
|
if (newCurrentId) {
|
|
228
|
-
store.
|
|
228
|
+
store.activeTabId = newCurrentId
|
|
229
229
|
// Also update the batch-specific current tab id
|
|
230
|
-
store[`
|
|
230
|
+
store[`activeTabId${currentBatch}`] = newCurrentId
|
|
231
231
|
} else {
|
|
232
232
|
// No tabs left in any batch
|
|
233
|
-
store.
|
|
233
|
+
store.activeTabId = ''
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
// Fix batch-specific current tab IDs
|
|
238
238
|
for (const batch in batchFirstTabs) {
|
|
239
|
-
const batchTabId = `
|
|
239
|
+
const batchTabId = `activeTabId${batch}`
|
|
240
240
|
const currentBatchId = store[batchTabId]
|
|
241
241
|
|
|
242
242
|
// If the batch's current tab was removed or doesn't exist
|
|
@@ -284,10 +284,10 @@ export default Store => {
|
|
|
284
284
|
store.currentLayoutBatch = batch
|
|
285
285
|
|
|
286
286
|
// Update current tab id
|
|
287
|
-
store.
|
|
287
|
+
store.activeTabId = id
|
|
288
288
|
|
|
289
289
|
// Update batch-specific current tab id
|
|
290
|
-
store[`
|
|
290
|
+
store[`activeTabId${batch}`] = id
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
Store.prototype.addTab = function (
|
|
@@ -304,8 +304,8 @@ export default Store => {
|
|
|
304
304
|
tabs.push(newTab)
|
|
305
305
|
}
|
|
306
306
|
const batchNum = newTab.batch
|
|
307
|
-
store[`
|
|
308
|
-
store.
|
|
307
|
+
store[`activeTabId${batchNum}`] = newTab.id
|
|
308
|
+
store.activeTabId = newTab.id
|
|
309
309
|
store.currentLayoutBatch = batchNum
|
|
310
310
|
}
|
|
311
311
|
|
|
@@ -319,10 +319,10 @@ export default Store => {
|
|
|
319
319
|
|
|
320
320
|
Store.prototype.clickBioTab = function (diff) {
|
|
321
321
|
const { store } = window
|
|
322
|
-
const { tabs,
|
|
322
|
+
const { tabs, activeTabId } = store
|
|
323
323
|
|
|
324
324
|
// Find the current tab index and its batch
|
|
325
|
-
const currentIndex = tabs.findIndex(t => t.id ===
|
|
325
|
+
const currentIndex = tabs.findIndex(t => t.id === activeTabId)
|
|
326
326
|
if (currentIndex === -1) return // Current tab not found, do nothing
|
|
327
327
|
|
|
328
328
|
const currentBatch = tabs[currentIndex].batch
|
|
@@ -342,9 +342,9 @@ export default Store => {
|
|
|
342
342
|
// Find the next tab index
|
|
343
343
|
const nextIndex = findNextTabIndex(currentIndex, diff)
|
|
344
344
|
|
|
345
|
-
// If a valid next tab is found, update the
|
|
345
|
+
// If a valid next tab is found, update the activeTabId
|
|
346
346
|
if (nextIndex !== -1 && nextIndex !== currentIndex) {
|
|
347
|
-
store.
|
|
347
|
+
store.activeTabId = tabs[nextIndex].id
|
|
348
348
|
}
|
|
349
349
|
}
|
|
350
350
|
|
|
@@ -376,7 +376,7 @@ export default Store => {
|
|
|
376
376
|
Store.prototype.setLayout = function (layout) {
|
|
377
377
|
const { store } = window
|
|
378
378
|
const prevLayout = store.layout
|
|
379
|
-
const {
|
|
379
|
+
const { activeTabId } = store
|
|
380
380
|
|
|
381
381
|
// If layout hasn't changed, do nothing
|
|
382
382
|
if (prevLayout === layout) {
|
|
@@ -400,8 +400,8 @@ export default Store => {
|
|
|
400
400
|
const tab = store.tabs[i]
|
|
401
401
|
if (tab.batch >= newBatchCount) {
|
|
402
402
|
store.tabs[i].batch = nb
|
|
403
|
-
if (tab.id ===
|
|
404
|
-
store[`
|
|
403
|
+
if (tab.id === activeTabId) {
|
|
404
|
+
store[`activeTabId${nb}`] = activeTabId
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
407
|
}
|
package/client/store/watch.js
CHANGED
|
@@ -20,7 +20,7 @@ export default store => {
|
|
|
20
20
|
// store.focus()
|
|
21
21
|
// // store.termSearchOpen = false
|
|
22
22
|
// store.termSearchMatchCount = 0
|
|
23
|
-
// return store.
|
|
23
|
+
// return store.activeTabId
|
|
24
24
|
// }).start()
|
|
25
25
|
|
|
26
26
|
// autoRun(() => {
|
|
@@ -99,13 +99,13 @@ export default store => {
|
|
|
99
99
|
|
|
100
100
|
autoRun(() => {
|
|
101
101
|
const tabs = store.getTabs()
|
|
102
|
-
const {
|
|
103
|
-
const tab = tabs.find(t => t.id ===
|
|
102
|
+
const { activeTabId } = store
|
|
103
|
+
const tab = tabs.find(t => t.id === activeTabId)
|
|
104
104
|
if (tab) {
|
|
105
105
|
const title = createTitle(tab)
|
|
106
106
|
window.pre.runGlobalAsync('setTitle', title)
|
|
107
107
|
window.store.currentLayoutBatch = tab.batch
|
|
108
108
|
}
|
|
109
|
-
return store.
|
|
109
|
+
return store.activeTabId
|
|
110
110
|
}).start()
|
|
111
111
|
}
|