@electerm/electerm-react 1.60.18 → 1.60.29
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/clipboard.js +1 -14
- package/client/common/constants.js +0 -43
- package/client/common/data-compare.js +55 -0
- package/client/common/default-setting.js +2 -10
- package/client/common/resolve.js +18 -22
- package/client/common/sftp.js +0 -3
- package/client/components/ai/ai-chat.jsx +30 -6
- package/client/components/ai/ai-config.jsx +17 -6
- package/client/components/batch-op/batch-op.jsx +3 -24
- package/client/components/bookmark-form/bookmark-group-tree-format.js +7 -9
- package/client/components/bookmark-form/form-ssh-common.jsx +0 -2
- package/client/components/bookmark-form/ssh-form.jsx +8 -41
- package/client/components/bookmark-form/tree-delete.jsx +6 -15
- package/client/components/common/animate-text.jsx +3 -4
- package/client/components/common/drag-handle.jsx +59 -45
- package/client/components/common/drag-handle.styl +2 -1
- package/client/components/common/input-auto-focus.jsx +29 -63
- package/client/components/common/ref.js +24 -0
- package/client/components/footer/batch-input.jsx +1 -6
- package/client/components/footer/footer-entry.jsx +13 -16
- package/client/components/footer/footer.styl +0 -5
- package/client/components/icons/ai-icon.jsx +17 -0
- package/client/components/icons/ai-icon.styl +3 -0
- package/client/components/layout/layout-item.jsx +14 -0
- package/client/components/main/main.jsx +8 -19
- package/client/components/main/upgrade.jsx +13 -25
- package/client/components/profile/profile-form-elem.jsx +1 -2
- package/client/components/quick-commands/on-drop.js +1 -12
- package/client/components/quick-commands/quick-command-transport-mod.jsx +3 -13
- package/client/components/quick-commands/quick-commands-form-elem.jsx +1 -2
- package/client/components/rdp/rdp-session.jsx +4 -4
- package/client/components/session/session.jsx +9 -11
- package/client/components/setting-panel/on-tree-drop.js +4 -35
- package/client/components/setting-panel/setting-common.jsx +4 -1
- package/client/components/setting-panel/setting-modal.jsx +7 -5
- package/client/components/setting-panel/tab-settings.jsx +0 -1
- package/client/components/setting-sync/setting-sync.jsx +0 -1
- package/client/components/sftp/address-bookmark-item.jsx +1 -15
- package/client/components/sftp/confirm-modal-store.jsx +2 -2
- package/client/components/sftp/{file-mode-modal.jsx → file-info-modal.jsx} +137 -37
- package/client/components/sftp/file-item.jsx +156 -192
- package/client/components/sftp/file-table-header.jsx +98 -0
- package/client/components/sftp/list-table-ui.jsx +125 -416
- package/client/components/sftp/sftp-entry.jsx +102 -128
- package/client/components/sftp/sftp.styl +6 -22
- package/client/components/sftp/transfer-conflict-store.jsx +8 -12
- package/client/components/sftp/transport-action-store.jsx +7 -15
- package/client/components/shortcuts/shortcut-control.jsx +72 -3
- package/client/components/shortcuts/shortcut-handler.js +0 -1
- package/client/components/side-panel-r/side-panel-r.jsx +7 -4
- package/client/components/sidebar/history.jsx +3 -0
- package/client/components/sidebar/index.jsx +1 -1
- package/client/components/sidebar/info-modal.jsx +3 -0
- package/client/components/sidebar/side-panel.jsx +7 -4
- package/client/components/sidebar/sidebar-panel.jsx +1 -1
- package/client/components/sidebar/sidebar.styl +3 -3
- package/client/components/sys-menu/icons-map.jsx +52 -0
- package/client/components/{context-menu → sys-menu}/menu-btn.jsx +33 -45
- package/client/components/sys-menu/sys-menu.jsx +163 -0
- package/client/components/{context-menu/context-menu.styl → sys-menu/sys-menu.styl} +2 -11
- package/client/components/tabs/index.jsx +5 -97
- package/client/components/tabs/tab.jsx +121 -73
- package/client/components/tabs/tabs.styl +4 -1
- package/client/components/terminal/term-search.jsx +16 -28
- package/client/components/terminal/terminal-interactive.jsx +0 -2
- package/client/components/terminal/{index.jsx → terminal.jsx} +110 -240
- package/client/components/terminal-info/base.jsx +21 -46
- package/client/components/terminal-info/terminal-info.jsx +3 -0
- package/client/components/text-editor/text-editor.jsx +38 -53
- package/client/components/theme/theme-form.jsx +0 -2
- package/client/components/tree-list/bookmark-toolbar.jsx +23 -47
- package/client/components/tree-list/bookmark-transport.jsx +2 -90
- package/client/components/tree-list/move-item-modal.jsx +101 -0
- package/client/components/tree-list/tree-list-item.jsx +6 -8
- package/client/components/tree-list/tree-list.jsx +48 -273
- package/client/components/vnc/vnc-session.jsx +5 -3
- package/client/store/app-upgrade.js +2 -5
- package/client/store/bookmark-group.js +74 -28
- package/client/store/common.js +36 -54
- package/client/store/event.js +4 -37
- package/client/store/init-state.js +9 -12
- package/client/store/item.js +34 -39
- package/client/store/load-data.js +5 -1
- package/client/store/quick-command.js +2 -12
- package/client/store/session.js +6 -7
- package/client/store/setting.js +3 -7
- package/client/store/sidebar.js +2 -8
- package/client/store/store.js +0 -20
- package/client/store/system-menu.js +1 -2
- package/client/store/tab.js +29 -1
- package/client/store/terminal-theme.js +0 -4
- package/client/store/watch.js +26 -4
- package/package.json +1 -1
- package/client/common/post-msg.js +0 -3
- package/client/components/common/native-input.jsx +0 -30
- package/client/components/context-menu/context-menu.jsx +0 -339
- package/client/components/sftp/file-props-modal.jsx +0 -210
- package/client/store/context-menu.js +0 -23
- /package/client/components/{context-menu → sys-menu}/boomarks.jsx +0 -0
- /package/client/components/{context-menu → sys-menu}/history.jsx +0 -0
- /package/client/components/{context-menu → sys-menu}/icon-holder.jsx +0 -0
- /package/client/components/{context-menu → sys-menu}/sub-tab-menu.jsx +0 -0
- /package/client/components/{context-menu → sys-menu}/tabs.jsx +0 -0
- /package/client/components/{context-menu → sys-menu}/zoom.jsx +0 -0
|
@@ -12,7 +12,7 @@ import { useRef, memo } from 'react'
|
|
|
12
12
|
import { Tooltip } from 'antd'
|
|
13
13
|
import SideBarPanel from './sidebar-panel'
|
|
14
14
|
import TransferList from './transfer-list'
|
|
15
|
-
import MenuBtn from '../
|
|
15
|
+
import MenuBtn from '../sys-menu/menu-btn'
|
|
16
16
|
import {
|
|
17
17
|
sidebarWidth,
|
|
18
18
|
settingMap,
|
|
@@ -177,6 +177,9 @@ export default memo(function InfoModal (props) {
|
|
|
177
177
|
{sponsorLink}
|
|
178
178
|
</Link>
|
|
179
179
|
</p>
|
|
180
|
+
<p className='mg1b'>
|
|
181
|
+
<InfoCircleOutlined /> <b className='mg1r'>{window.store.installSrc}</b>
|
|
182
|
+
</p>
|
|
180
183
|
<p className='mg1b'>
|
|
181
184
|
<JavaScriptOutlined /> <b className='mg1r'>Powered by</b>
|
|
182
185
|
<Link to='https://github.com/tylerlong/manate'>
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
import { useCallback } from 'react'
|
|
1
|
+
import { useCallback, useRef } from 'react'
|
|
2
2
|
import DragHandle from '../common/drag-handle'
|
|
3
3
|
|
|
4
4
|
export default function SidePanel (props) {
|
|
5
|
+
const panelRef = useRef(null)
|
|
6
|
+
|
|
5
7
|
const onDragEnd = useCallback((nw) => {
|
|
6
8
|
props.setLeftSidePanelWidth(nw)
|
|
7
9
|
window.store.onResize()
|
|
8
10
|
}, [props])
|
|
9
11
|
|
|
10
12
|
const onDragMove = useCallback((nw) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
if (panelRef.current) {
|
|
14
|
+
panelRef.current.style.width = nw + 'px'
|
|
15
|
+
}
|
|
13
16
|
const el1 = document.querySelector('.sessions')
|
|
14
17
|
if (el1) {
|
|
15
18
|
el1.style.left = (nw + 43) + 'px'
|
|
@@ -26,7 +29,7 @@ export default function SidePanel (props) {
|
|
|
26
29
|
return (
|
|
27
30
|
<div
|
|
28
31
|
{...props.sideProps}
|
|
29
|
-
|
|
32
|
+
ref={panelRef}
|
|
30
33
|
draggable={false}
|
|
31
34
|
>
|
|
32
35
|
<DragHandle
|
|
@@ -72,7 +72,7 @@ export default memo(function SidebarPanel (props) {
|
|
|
72
72
|
{...pick(props, ['onMouseEnter', 'onMouseLeave'])}
|
|
73
73
|
>
|
|
74
74
|
<div className='sidebar-pin-top'>
|
|
75
|
-
<div className='pd1y pd2t pd2x sidebar-panel-control'>
|
|
75
|
+
<div className='pd1y pd2t pd2x sidebar-panel-control alignright'>
|
|
76
76
|
<Tooltip title={e('newBookmark')}>
|
|
77
77
|
<PlusCircleOutlined
|
|
78
78
|
{...pop1}
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
position absolute
|
|
31
31
|
left 0
|
|
32
32
|
right 0
|
|
33
|
-
top
|
|
33
|
+
top 0
|
|
34
34
|
height 112px
|
|
35
35
|
.sidebar-panel-bookmarks
|
|
36
36
|
.sidebar-panel-history
|
|
37
37
|
position absolute
|
|
38
38
|
left 0
|
|
39
39
|
right 0
|
|
40
|
-
top
|
|
40
|
+
top 112px
|
|
41
41
|
bottom 0
|
|
42
42
|
overflow-y scroll
|
|
43
43
|
.not-system-ui.is-mac
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
.sidebar-list
|
|
68
68
|
position absolute
|
|
69
69
|
left 43px
|
|
70
|
-
top
|
|
70
|
+
top 0
|
|
71
71
|
bottom 0
|
|
72
72
|
z-index 200
|
|
73
73
|
width 0
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* context menu icons
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
CodeOutlined,
|
|
6
|
+
BorderHorizontalOutlined,
|
|
7
|
+
SearchOutlined,
|
|
8
|
+
SelectOutlined,
|
|
9
|
+
SwitcherOutlined,
|
|
10
|
+
CheckOutlined,
|
|
11
|
+
CloudDownloadOutlined,
|
|
12
|
+
CloudUploadOutlined,
|
|
13
|
+
ArrowRightOutlined,
|
|
14
|
+
CheckSquareOutlined,
|
|
15
|
+
CloseCircleOutlined,
|
|
16
|
+
ContainerOutlined,
|
|
17
|
+
CopyOutlined,
|
|
18
|
+
EditOutlined,
|
|
19
|
+
EnterOutlined,
|
|
20
|
+
FileAddOutlined,
|
|
21
|
+
FileExcelOutlined,
|
|
22
|
+
FolderAddOutlined,
|
|
23
|
+
InfoCircleOutlined,
|
|
24
|
+
LockOutlined,
|
|
25
|
+
ReloadOutlined
|
|
26
|
+
} from '@ant-design/icons'
|
|
27
|
+
import IconHolder from './icon-holder'
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
CodeOutlined,
|
|
31
|
+
BorderHorizontalOutlined,
|
|
32
|
+
SearchOutlined,
|
|
33
|
+
SelectOutlined,
|
|
34
|
+
SwitcherOutlined,
|
|
35
|
+
IconHolder,
|
|
36
|
+
CheckOutlined,
|
|
37
|
+
CloudDownloadOutlined,
|
|
38
|
+
CloudUploadOutlined,
|
|
39
|
+
ArrowRightOutlined,
|
|
40
|
+
CheckSquareOutlined,
|
|
41
|
+
CloseCircleOutlined,
|
|
42
|
+
ContainerOutlined,
|
|
43
|
+
CopyOutlined,
|
|
44
|
+
EditOutlined,
|
|
45
|
+
EnterOutlined,
|
|
46
|
+
FileAddOutlined,
|
|
47
|
+
FileExcelOutlined,
|
|
48
|
+
FolderAddOutlined,
|
|
49
|
+
InfoCircleOutlined,
|
|
50
|
+
LockOutlined,
|
|
51
|
+
ReloadOutlined
|
|
52
|
+
}
|
|
@@ -3,52 +3,20 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { PureComponent } from 'react'
|
|
6
|
+
import {
|
|
7
|
+
Popover
|
|
8
|
+
} from 'antd'
|
|
6
9
|
import logoRef from '@electerm/electerm-resource/res/imgs/electerm.svg'
|
|
7
|
-
import { commonActions } from '../../common/constants'
|
|
8
10
|
import { shortcutDescExtend } from '../shortcuts/shortcut-handler.js'
|
|
9
|
-
import
|
|
11
|
+
import MenuRender from './sys-menu.jsx'
|
|
12
|
+
import { refsStatic } from '../common/ref.js'
|
|
10
13
|
|
|
11
14
|
const e = window.translate
|
|
12
15
|
const logo = logoRef.replace(/^\//, '')
|
|
13
16
|
|
|
14
17
|
class MenuBtn extends PureComponent {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
onContextAction = e => {
|
|
20
|
-
const {
|
|
21
|
-
action,
|
|
22
|
-
id,
|
|
23
|
-
args = [],
|
|
24
|
-
func
|
|
25
|
-
} = e.data || {}
|
|
26
|
-
if (
|
|
27
|
-
action !== commonActions.clickContextMenu ||
|
|
28
|
-
id !== this.uid ||
|
|
29
|
-
!this[func]
|
|
30
|
-
) {
|
|
31
|
-
return false
|
|
32
|
-
}
|
|
33
|
-
window.removeEventListener('message', this.onContextAction)
|
|
34
|
-
this[func](...args)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
openMenu = () => {
|
|
38
|
-
const items = this.renderContext()
|
|
39
|
-
this.uid = generate()
|
|
40
|
-
window.store.openContextMenu({
|
|
41
|
-
items,
|
|
42
|
-
pos: {
|
|
43
|
-
left: 40,
|
|
44
|
-
top: 10
|
|
45
|
-
},
|
|
46
|
-
id: this.uid
|
|
47
|
-
})
|
|
48
|
-
window.addEventListener('message', this.onContextAction)
|
|
49
|
-
this.setState({
|
|
50
|
-
opened: true
|
|
51
|
-
})
|
|
18
|
+
componentDidMount () {
|
|
19
|
+
refsStatic.add('menu-btn', this)
|
|
52
20
|
}
|
|
53
21
|
|
|
54
22
|
onNewSsh = () => {
|
|
@@ -201,6 +169,19 @@ class MenuBtn extends PureComponent {
|
|
|
201
169
|
]
|
|
202
170
|
}
|
|
203
171
|
|
|
172
|
+
renderMenu () {
|
|
173
|
+
const { store } = window
|
|
174
|
+
const rprops = {
|
|
175
|
+
items: this.renderContext(),
|
|
176
|
+
tabs: store.getTabs(),
|
|
177
|
+
config: store.config,
|
|
178
|
+
history: store.history
|
|
179
|
+
}
|
|
180
|
+
return (
|
|
181
|
+
<MenuRender {...rprops} />
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
204
185
|
render () {
|
|
205
186
|
const pops = {
|
|
206
187
|
className: 'menu-control',
|
|
@@ -208,13 +189,20 @@ class MenuBtn extends PureComponent {
|
|
|
208
189
|
onClick: this.openMenu,
|
|
209
190
|
title: e('menu')
|
|
210
191
|
}
|
|
192
|
+
const popProps = {
|
|
193
|
+
content: this.renderMenu(),
|
|
194
|
+
// open: this.state.opened,
|
|
195
|
+
placement: 'right',
|
|
196
|
+
trigger: ['click']
|
|
197
|
+
}
|
|
211
198
|
return (
|
|
212
|
-
<
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
199
|
+
<Popover {...popProps}>
|
|
200
|
+
<div
|
|
201
|
+
{...pops}
|
|
202
|
+
>
|
|
203
|
+
<img src={logo} width={28} height={28} />
|
|
204
|
+
</div>
|
|
205
|
+
</Popover>
|
|
218
206
|
)
|
|
219
207
|
}
|
|
220
208
|
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* context menu
|
|
3
|
+
*/
|
|
4
|
+
import { PureComponent } from 'react'
|
|
5
|
+
import './sys-menu.styl'
|
|
6
|
+
import classnames from 'classnames'
|
|
7
|
+
import {
|
|
8
|
+
Popconfirm
|
|
9
|
+
} from 'antd'
|
|
10
|
+
import { noop } from 'lodash-es'
|
|
11
|
+
import History from './history'
|
|
12
|
+
import Bookmark from './boomarks'
|
|
13
|
+
import Tabs from './tabs'
|
|
14
|
+
import Zoom from './zoom'
|
|
15
|
+
import icons from './icons-map'
|
|
16
|
+
import { refsStatic } from '../common/ref'
|
|
17
|
+
|
|
18
|
+
const e = window.translate
|
|
19
|
+
|
|
20
|
+
export default class ContextMenu extends PureComponent {
|
|
21
|
+
modules = {
|
|
22
|
+
History,
|
|
23
|
+
Bookmark,
|
|
24
|
+
Tabs,
|
|
25
|
+
Zoom
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
onClick = (e, item) => {
|
|
29
|
+
const {
|
|
30
|
+
disabled,
|
|
31
|
+
func
|
|
32
|
+
} = item
|
|
33
|
+
if (disabled) {
|
|
34
|
+
return
|
|
35
|
+
}
|
|
36
|
+
const menu = refsStatic.get('menu-btn')
|
|
37
|
+
if (!menu) {
|
|
38
|
+
return
|
|
39
|
+
}
|
|
40
|
+
if (func) {
|
|
41
|
+
menu[func]()
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
renderSubText = (subText) => {
|
|
46
|
+
return subText
|
|
47
|
+
? (<span className='context-sub-text'>{subText}</span>)
|
|
48
|
+
: null
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
renderSubMenu = (submenu) => {
|
|
52
|
+
if (!submenu) {
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
const Mod = this.modules[submenu]
|
|
56
|
+
return (
|
|
57
|
+
<Mod {...this.props} />
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
renderItem = (item, i) => {
|
|
62
|
+
const {
|
|
63
|
+
disabled,
|
|
64
|
+
icon,
|
|
65
|
+
text,
|
|
66
|
+
noAutoClose,
|
|
67
|
+
requireConfirm,
|
|
68
|
+
confirmTitle,
|
|
69
|
+
subText,
|
|
70
|
+
className,
|
|
71
|
+
type,
|
|
72
|
+
module,
|
|
73
|
+
submenu
|
|
74
|
+
} = item
|
|
75
|
+
if (type === 'hr') {
|
|
76
|
+
return <hr />
|
|
77
|
+
}
|
|
78
|
+
const baseCls = 'context-item'
|
|
79
|
+
if (module && this.modules[module]) {
|
|
80
|
+
const Mod = this.modules[module]
|
|
81
|
+
return (
|
|
82
|
+
<div className={baseCls}>
|
|
83
|
+
<Mod {...this.props} />
|
|
84
|
+
</div>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
let iconElem = null
|
|
88
|
+
if (icon && icons[icon]) {
|
|
89
|
+
const Icon = icons[icon]
|
|
90
|
+
iconElem = <Icon />
|
|
91
|
+
}
|
|
92
|
+
const cls = classnames(
|
|
93
|
+
baseCls,
|
|
94
|
+
{
|
|
95
|
+
disabled
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
'no-auto-close-context': noAutoClose
|
|
99
|
+
},
|
|
100
|
+
className,
|
|
101
|
+
{
|
|
102
|
+
'with-sub-menu': submenu
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
const act = requireConfirm || submenu
|
|
106
|
+
? noop
|
|
107
|
+
: (e) => this.onClick(e, item)
|
|
108
|
+
const unit = (
|
|
109
|
+
<div
|
|
110
|
+
key={`context-item-${i}-${text}`}
|
|
111
|
+
className={cls}
|
|
112
|
+
onClick={act}
|
|
113
|
+
>
|
|
114
|
+
{iconElem}{iconElem ? ' ' : ''}{text}
|
|
115
|
+
{
|
|
116
|
+
this.renderSubText(subText)
|
|
117
|
+
}
|
|
118
|
+
{
|
|
119
|
+
this.renderSubMenu(submenu)
|
|
120
|
+
}
|
|
121
|
+
</div>
|
|
122
|
+
)
|
|
123
|
+
if (!requireConfirm) {
|
|
124
|
+
return unit
|
|
125
|
+
}
|
|
126
|
+
const title = (
|
|
127
|
+
<div className='wordbreak'>{confirmTitle}</div>
|
|
128
|
+
)
|
|
129
|
+
return (
|
|
130
|
+
<Popconfirm
|
|
131
|
+
cancelText={e('cancel')}
|
|
132
|
+
key={`context-item-${i}-${text}`}
|
|
133
|
+
okText={e('ok')}
|
|
134
|
+
title={title}
|
|
135
|
+
onConfirm={(e) => this.onClick(e, item)}
|
|
136
|
+
>
|
|
137
|
+
{unit}
|
|
138
|
+
</Popconfirm>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
renderItems = () => {
|
|
143
|
+
return this.props.items.map(this.renderItem)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
render () {
|
|
147
|
+
const cls = 'context-menu'
|
|
148
|
+
const innerProps = {
|
|
149
|
+
className: 'context-menu-inner'
|
|
150
|
+
}
|
|
151
|
+
return (
|
|
152
|
+
<div
|
|
153
|
+
className={cls}
|
|
154
|
+
>
|
|
155
|
+
<div
|
|
156
|
+
{...innerProps}
|
|
157
|
+
>
|
|
158
|
+
{this.renderItems()}
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
@require '../../css/includes/theme-default'
|
|
2
2
|
.context-menu
|
|
3
|
-
position:
|
|
3
|
+
position: relative
|
|
4
4
|
width 280px
|
|
5
|
-
|
|
6
|
-
box-shadow 0px 0px 3px 3px alpha(main-dark, .35)
|
|
7
|
-
padding 10px 0
|
|
8
|
-
z-index 999
|
|
9
|
-
-webkit-app-region no-drag
|
|
10
|
-
color text
|
|
11
|
-
&.scroll
|
|
12
|
-
.context-menu-inner
|
|
13
|
-
overflow-x hidden
|
|
14
|
-
overflow-y scroll
|
|
5
|
+
|
|
15
6
|
.context-item
|
|
16
7
|
-webkit-app-region no-drag
|
|
17
8
|
position relative
|
|
@@ -33,10 +33,8 @@ import {
|
|
|
33
33
|
extraTabWidth,
|
|
34
34
|
windowControlWidth,
|
|
35
35
|
isMacJs,
|
|
36
|
-
splitMapDesc
|
|
37
|
-
commonActions
|
|
36
|
+
splitMapDesc
|
|
38
37
|
} from '../../common/constants'
|
|
39
|
-
import findParentBySel from '../../common/find-parent'
|
|
40
38
|
import WindowControl from './window-control'
|
|
41
39
|
import BookmarksList from '../sidebar/bookmark-select'
|
|
42
40
|
import AppDrag from './app-drag'
|
|
@@ -51,12 +49,7 @@ export default class Tabs extends React.Component {
|
|
|
51
49
|
this.tabsRef = React.createRef()
|
|
52
50
|
this.domRef = React.createRef()
|
|
53
51
|
this.state = {
|
|
54
|
-
overflow: false
|
|
55
|
-
receiveDataTabId: '',
|
|
56
|
-
onContextMenuTabId: '',
|
|
57
|
-
contextFuncTabId: '',
|
|
58
|
-
contextFunc: '',
|
|
59
|
-
contextArgs: []
|
|
52
|
+
overflow: false
|
|
60
53
|
}
|
|
61
54
|
}
|
|
62
55
|
|
|
@@ -64,7 +57,6 @@ export default class Tabs extends React.Component {
|
|
|
64
57
|
const {
|
|
65
58
|
tabsRef
|
|
66
59
|
} = this
|
|
67
|
-
window.addEventListener('message', this.onEvent)
|
|
68
60
|
tabsRef.current.addEventListener('wheel', this.handleWheelEvent, {
|
|
69
61
|
passive: false
|
|
70
62
|
})
|
|
@@ -81,8 +73,6 @@ export default class Tabs extends React.Component {
|
|
|
81
73
|
}
|
|
82
74
|
|
|
83
75
|
componentWillUnmount () {
|
|
84
|
-
window.removeEventListener('message', this.onEvent)
|
|
85
|
-
this.offTimer()
|
|
86
76
|
}
|
|
87
77
|
|
|
88
78
|
modifier = (...args) => {
|
|
@@ -97,83 +87,6 @@ export default class Tabs extends React.Component {
|
|
|
97
87
|
window.store.onNewSsh()
|
|
98
88
|
}
|
|
99
89
|
|
|
100
|
-
onEvent = (e) => {
|
|
101
|
-
const {
|
|
102
|
-
action,
|
|
103
|
-
tabId
|
|
104
|
-
} = e.data || {}
|
|
105
|
-
if (
|
|
106
|
-
action === commonActions.closeContextMenuAfter
|
|
107
|
-
) {
|
|
108
|
-
this.offContextMenu()
|
|
109
|
-
} else if (
|
|
110
|
-
action === 'terminal-receive-data' &&
|
|
111
|
-
tabId
|
|
112
|
-
) {
|
|
113
|
-
this.modifier({
|
|
114
|
-
receiveDataTabId: tabId
|
|
115
|
-
})
|
|
116
|
-
this.timer = setTimeout(this.clearReceiveData, 4000)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
clearReceiveData = () => {
|
|
121
|
-
this.modifier({
|
|
122
|
-
receiveDataTabId: ''
|
|
123
|
-
})
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
offTimer = () => {
|
|
127
|
-
clearTimeout(this.timer)
|
|
128
|
-
this.timer = null
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
offContextMenu = () => {
|
|
132
|
-
window.removeEventListener('message', this.onContextAction)
|
|
133
|
-
this.setState({
|
|
134
|
-
onContextMenuTabId: ''
|
|
135
|
-
})
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
handleContextMenu = e => {
|
|
139
|
-
e.preventDefault()
|
|
140
|
-
const { target } = e
|
|
141
|
-
const tabElem = findParentBySel(target, '.tab')
|
|
142
|
-
if (!tabElem) {
|
|
143
|
-
return
|
|
144
|
-
}
|
|
145
|
-
this.setState({
|
|
146
|
-
contextFuncTabId: '',
|
|
147
|
-
onContextMenuTabId: tabElem.dataset.id
|
|
148
|
-
})
|
|
149
|
-
window.addEventListener('message', this.onContextAction)
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
onContextAction = e => {
|
|
153
|
-
const {
|
|
154
|
-
action,
|
|
155
|
-
id,
|
|
156
|
-
args = [],
|
|
157
|
-
func
|
|
158
|
-
} = e.data || {}
|
|
159
|
-
if (
|
|
160
|
-
action !== commonActions.clickContextMenu ||
|
|
161
|
-
id !== this.state.onContextMenuTabId
|
|
162
|
-
) {
|
|
163
|
-
return false
|
|
164
|
-
}
|
|
165
|
-
this.offContextMenu()
|
|
166
|
-
this.setContextFunc(id, func, args)
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
setContextFunc = (id, func, args) => {
|
|
170
|
-
this.setState({
|
|
171
|
-
contextFuncTabId: id,
|
|
172
|
-
contextFunc: func,
|
|
173
|
-
contextArgs: args
|
|
174
|
-
})
|
|
175
|
-
}
|
|
176
|
-
|
|
177
90
|
tabsWidth = () => {
|
|
178
91
|
const { batch } = this.props
|
|
179
92
|
return Array.from(
|
|
@@ -392,7 +305,7 @@ export default class Tabs extends React.Component {
|
|
|
392
305
|
const { tabs = [], width, config } = this.props
|
|
393
306
|
const len = tabs.length
|
|
394
307
|
const tabsWidthAll = tabMargin * len + 10 + this.tabsWidth()
|
|
395
|
-
const { overflow
|
|
308
|
+
const { overflow } = this.state
|
|
396
309
|
const left = overflow
|
|
397
310
|
? '100%'
|
|
398
311
|
: tabsWidthAll
|
|
@@ -427,14 +340,9 @@ export default class Tabs extends React.Component {
|
|
|
427
340
|
...this.props,
|
|
428
341
|
tab,
|
|
429
342
|
isLast,
|
|
430
|
-
|
|
431
|
-
openContextMenu: onContextMenuTabId === tab.id,
|
|
343
|
+
addTab: this.handleTabAdd,
|
|
432
344
|
tabIndex: i
|
|
433
345
|
}
|
|
434
|
-
if (this.state.contextFuncTabId === tab.id) {
|
|
435
|
-
tabProps.contextFunc = this.state.contextFunc
|
|
436
|
-
tabProps.contextArgs = this.state.contextArgs
|
|
437
|
-
}
|
|
438
346
|
return (
|
|
439
347
|
<Tab
|
|
440
348
|
{...tabProps}
|
|
@@ -533,7 +441,7 @@ export default class Tabs extends React.Component {
|
|
|
533
441
|
renderTabs () {
|
|
534
442
|
const { overflow } = this.state
|
|
535
443
|
return (
|
|
536
|
-
<div className='tabs' ref={this.tabsRef}
|
|
444
|
+
<div className='tabs' ref={this.tabsRef}>
|
|
537
445
|
{this.renderContent()}
|
|
538
446
|
{
|
|
539
447
|
this.renderWindowControl()
|