@electerm/electerm-react 1.34.30
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/LICENSE +21 -0
- package/README.md +31 -0
- package/client/common/auto-complete-data-mapper.js +6 -0
- package/client/common/byte-format.js +14 -0
- package/client/common/class.js +52 -0
- package/client/common/clipboard.js +49 -0
- package/client/common/constants.js +308 -0
- package/client/common/create-lang-edit-link.js +7 -0
- package/client/common/create-title.js +29 -0
- package/client/common/db-fix.js +24 -0
- package/client/common/db.js +155 -0
- package/client/common/download-mirrors.js +10 -0
- package/client/common/download.js +16 -0
- package/client/common/error-handler.jsx +27 -0
- package/client/common/fetch-from-server.js +47 -0
- package/client/common/fetch.jsx +71 -0
- package/client/common/find-bookmark-group-id.js +15 -0
- package/client/common/find-parent.js +30 -0
- package/client/common/form-layout.js +27 -0
- package/client/common/fs.js +21 -0
- package/client/common/get-proxy.js +8 -0
- package/client/common/id-with-stamp.js +10 -0
- package/client/common/index-sorter.js +4 -0
- package/client/common/init-setting-item.js +32 -0
- package/client/common/is-absolute-path.js +3 -0
- package/client/common/is-ip.js +16 -0
- package/client/common/is-valid-path.js +7 -0
- package/client/common/key-control-pressed.js +13 -0
- package/client/common/key-pressed.js +13 -0
- package/client/common/key-shift-pressed.js +7 -0
- package/client/common/mode2permission.js +81 -0
- package/client/common/new-terminal.js +31 -0
- package/client/common/parse-int10.js +3 -0
- package/client/common/parse-json-safe.js +11 -0
- package/client/common/pass-enc.js +25 -0
- package/client/common/post-msg.js +3 -0
- package/client/common/pre.js +156 -0
- package/client/common/promise-timeout.js +27 -0
- package/client/common/resolve.js +31 -0
- package/client/common/run-idle.js +1 -0
- package/client/common/safe-local-storage.js +35 -0
- package/client/common/safe-name.js +19 -0
- package/client/common/sftp.js +74 -0
- package/client/common/terminal-theme.js +158 -0
- package/client/common/test-connection.js +12 -0
- package/client/common/time.js +30 -0
- package/client/common/to-simple-obj.js +5 -0
- package/client/common/track.js +7 -0
- package/client/common/transfer.js +76 -0
- package/client/common/trzsz.js +62 -0
- package/client/common/ui-theme.js +44 -0
- package/client/common/uid.js +5 -0
- package/client/common/update-check.js +79 -0
- package/client/common/upgrade.js +68 -0
- package/client/common/wait.js +8 -0
- package/client/common/ws.js +161 -0
- package/client/components/batch-op/batch-op.jsx +650 -0
- package/client/components/bookmark-form/bookmark-form.styl +8 -0
- package/client/components/bookmark-form/bookmark-group-tree-format.js +39 -0
- package/client/components/bookmark-form/encodes.js +44 -0
- package/client/components/bookmark-form/form-ssh-common.jsx +208 -0
- package/client/components/bookmark-form/form-tabs.jsx +69 -0
- package/client/components/bookmark-form/index.jsx +159 -0
- package/client/components/bookmark-form/local-form-ui.jsx +152 -0
- package/client/components/bookmark-form/local-form.jsx +16 -0
- package/client/components/bookmark-form/proxy.jsx +49 -0
- package/client/components/bookmark-form/quick-command-list.jsx +31 -0
- package/client/components/bookmark-form/quick-command.jsx +228 -0
- package/client/components/bookmark-form/render-auth-ssh.jsx +104 -0
- package/client/components/bookmark-form/render-connection-hopping.jsx +229 -0
- package/client/components/bookmark-form/render-delayed-scripts.jsx +88 -0
- package/client/components/bookmark-form/render-ssh-tunnel.jsx +116 -0
- package/client/components/bookmark-form/serial-form-ui.jsx +311 -0
- package/client/components/bookmark-form/serial-form.jsx +20 -0
- package/client/components/bookmark-form/sftp-enable.jsx +33 -0
- package/client/components/bookmark-form/ssh-form-ui.jsx +100 -0
- package/client/components/bookmark-form/ssh-form.jsx +348 -0
- package/client/components/bookmark-form/telnet-form-ui.jsx +154 -0
- package/client/components/bookmark-form/telnet-form.jsx +16 -0
- package/client/components/bookmark-form/tree-delete.jsx +87 -0
- package/client/components/bookmark-form/use-form-funcs.jsx +50 -0
- package/client/components/bookmark-form/use-quick-commands.jsx +83 -0
- package/client/components/bookmark-form/use-submit.jsx +77 -0
- package/client/components/bookmark-form/use-ui.jsx +82 -0
- package/client/components/bookmark-form/x11.jsx +23 -0
- package/client/components/common/animate-text.jsx +37 -0
- package/client/components/common/animate-text.styl +54 -0
- package/client/components/common/external-link.jsx +28 -0
- package/client/components/common/help-icon.jsx +25 -0
- package/client/components/common/highlight.jsx +23 -0
- package/client/components/common/highlight.styl +3 -0
- package/client/components/common/input-auto-focus.jsx +68 -0
- package/client/components/common/input-confirm.jsx +66 -0
- package/client/components/common/logo-elem.jsx +22 -0
- package/client/components/common/markdown.jsx +27 -0
- package/client/components/common/react-subx.jsx +1 -0
- package/client/components/common/resize-wrap.jsx +222 -0
- package/client/components/common/resize-wrap.styl +9 -0
- package/client/components/common/search.jsx +9 -0
- package/client/components/common/show-item.jsx +27 -0
- package/client/components/context-menu/boomarks.jsx +15 -0
- package/client/components/context-menu/context-menu.jsx +340 -0
- package/client/components/context-menu/context-menu.styl +90 -0
- package/client/components/context-menu/history.jsx +27 -0
- package/client/components/context-menu/icon-holder.jsx +5 -0
- package/client/components/context-menu/menu-btn.jsx +224 -0
- package/client/components/context-menu/sub-tab-menu.jsx +23 -0
- package/client/components/context-menu/tabs.jsx +22 -0
- package/client/components/context-menu/zoom.jsx +40 -0
- package/client/components/footer/batch-input.jsx +177 -0
- package/client/components/footer/footer-entry.jsx +141 -0
- package/client/components/footer/footer.styl +47 -0
- package/client/components/icons/match-case.jsx +10 -0
- package/client/components/icons/match-whole-word.jsx +13 -0
- package/client/components/icons/regular-exp.jsx +10 -0
- package/client/components/main/css-overwrite.jsx +92 -0
- package/client/components/main/error-wrapper.jsx +59 -0
- package/client/components/main/index.jsx +11 -0
- package/client/components/main/loading.jsx +25 -0
- package/client/components/main/main.jsx +149 -0
- package/client/components/main/term-fullscreen-control.jsx +21 -0
- package/client/components/main/term-fullscreen.styl +27 -0
- package/client/components/main/ui-theme.jsx +31 -0
- package/client/components/main/upgrade.jsx +351 -0
- package/client/components/main/upgrade.styl +27 -0
- package/client/components/main/wrapper.styl +41 -0
- package/client/components/quick-commands/qm.styl +29 -0
- package/client/components/quick-commands/quick-command-item.jsx +36 -0
- package/client/components/quick-commands/quick-command-transport-mod.jsx +54 -0
- package/client/components/quick-commands/quick-command-transport.jsx +12 -0
- package/client/components/quick-commands/quick-commands-box.jsx +233 -0
- package/client/components/quick-commands/quick-commands-form-elem.jsx +119 -0
- package/client/components/quick-commands/quick-commands-form.jsx +33 -0
- package/client/components/quick-commands/quick-commands-list.jsx +128 -0
- package/client/components/quick-commands/quick-commands-select.jsx +38 -0
- package/client/components/session/session.jsx +533 -0
- package/client/components/session/session.styl +53 -0
- package/client/components/session/sessions.jsx +445 -0
- package/client/components/setting-panel/bookmark-transport.jsx +148 -0
- package/client/components/setting-panel/bookmark-tree-list.jsx +14 -0
- package/client/components/setting-panel/col.jsx +18 -0
- package/client/components/setting-panel/list.jsx +186 -0
- package/client/components/setting-panel/list.styl +33 -0
- package/client/components/setting-panel/on-tree-drop.js +222 -0
- package/client/components/setting-panel/setting-modal.jsx +163 -0
- package/client/components/setting-panel/setting-wrap.jsx +37 -0
- package/client/components/setting-panel/setting-wrap.styl +52 -0
- package/client/components/setting-panel/setting.jsx +858 -0
- package/client/components/setting-panel/setting.styl +4 -0
- package/client/components/setting-panel/start-session-select.jsx +91 -0
- package/client/components/setting-panel/tab-bookmarks.jsx +37 -0
- package/client/components/setting-panel/tab-history.jsx +44 -0
- package/client/components/setting-panel/tab-quick-commands.jsx +38 -0
- package/client/components/setting-panel/tab-settings.jsx +42 -0
- package/client/components/setting-panel/tab-themes.jsx +34 -0
- package/client/components/setting-panel/tree-list.jsx +978 -0
- package/client/components/setting-panel/tree-list.styl +57 -0
- package/client/components/setting-sync/data-import.jsx +65 -0
- package/client/components/setting-sync/setting-sync-form.jsx +271 -0
- package/client/components/setting-sync/setting-sync.jsx +81 -0
- package/client/components/setting-sync/sync.styl +7 -0
- package/client/components/sftp/address-bar.jsx +139 -0
- package/client/components/sftp/address-bookmark-item.jsx +47 -0
- package/client/components/sftp/address-bookmark.jsx +81 -0
- package/client/components/sftp/address-bookmark.styl +8 -0
- package/client/components/sftp/confirm-modal.jsx +184 -0
- package/client/components/sftp/file-icon.jsx +22 -0
- package/client/components/sftp/file-item.jsx +1226 -0
- package/client/components/sftp/file-mode-modal.jsx +205 -0
- package/client/components/sftp/file-props-modal.jsx +211 -0
- package/client/components/sftp/file-read.js +81 -0
- package/client/components/sftp/list-table-ui.jsx +547 -0
- package/client/components/sftp/owner-list.js +97 -0
- package/client/components/sftp/paged-list.jsx +60 -0
- package/client/components/sftp/permission-render.jsx +42 -0
- package/client/components/sftp/sftp-entry.jsx +1069 -0
- package/client/components/sftp/sftp.styl +217 -0
- package/client/components/sftp/transfer-common.js +9 -0
- package/client/components/sftp/transfer-conflict.jsx +315 -0
- package/client/components/sftp/transfer-speed-format.js +60 -0
- package/client/components/sftp/transfer-tag.jsx +40 -0
- package/client/components/sftp/transfer-tag.styl +11 -0
- package/client/components/sftp/transfer.styl +55 -0
- package/client/components/sftp/transport-action.jsx +410 -0
- package/client/components/sftp/transport-entry.jsx +108 -0
- package/client/components/sftp/transport-types.js +8 -0
- package/client/components/sftp/transports-action.jsx +111 -0
- package/client/components/sftp/transports-ui.jsx +93 -0
- package/client/components/sftp/zip.js +42 -0
- package/client/components/sidebar/bookmark-select.jsx +48 -0
- package/client/components/sidebar/bookmark.jsx +82 -0
- package/client/components/sidebar/history.jsx +66 -0
- package/client/components/sidebar/index.jsx +230 -0
- package/client/components/sidebar/info-modal.jsx +250 -0
- package/client/components/sidebar/info.styl +27 -0
- package/client/components/sidebar/side-icon.jsx +25 -0
- package/client/components/sidebar/sidebar.styl +128 -0
- package/client/components/sidebar/transfer-history-modal.jsx +110 -0
- package/client/components/sidebar/transfer-history.styl +3 -0
- package/client/components/sidebar/transfer-list-control.jsx +205 -0
- package/client/components/sidebar/transfer-list.jsx +55 -0
- package/client/components/sidebar/transfer-modal.jsx +76 -0
- package/client/components/sidebar/transfer.styl +8 -0
- package/client/components/sidebar/transport-ui.jsx +109 -0
- package/client/components/tabs/index.jsx +320 -0
- package/client/components/tabs/tab.jsx +427 -0
- package/client/components/tabs/tabs.styl +220 -0
- package/client/components/tabs/window-control.jsx +55 -0
- package/client/components/terminal/attach-addon-custom.js +70 -0
- package/client/components/terminal/build-ls-term-id.js +5 -0
- package/client/components/terminal/index.jsx +1358 -0
- package/client/components/terminal/normal-buffer.jsx +33 -0
- package/client/components/terminal/term-search.jsx +224 -0
- package/client/components/terminal/term-search.styl +15 -0
- package/client/components/terminal/terminal-apis.js +31 -0
- package/client/components/terminal/terminal-interactive.jsx +148 -0
- package/client/components/terminal/terminal.styl +96 -0
- package/client/components/terminal/xterm-zmodem.js +48 -0
- package/client/components/terminal/zmodem-transfer.jsx +98 -0
- package/client/components/terminal/zmodem.styl +14 -0
- package/client/components/terminal-info/activity.jsx +54 -0
- package/client/components/terminal-info/base.jsx +25 -0
- package/client/components/terminal-info/content.jsx +101 -0
- package/client/components/terminal-info/data-cols-parser.jsx +50 -0
- package/client/components/terminal-info/disk.jsx +29 -0
- package/client/components/terminal-info/index.jsx +25 -0
- package/client/components/terminal-info/network.jsx +114 -0
- package/client/components/terminal-info/resource.jsx +80 -0
- package/client/components/terminal-info/run-cmd.jsx +273 -0
- package/client/components/terminal-info/terminal-info.styl +29 -0
- package/client/components/terminal-info/up.jsx +15 -0
- package/client/components/terminal-theme/index.jsx +264 -0
- package/client/components/terminal-theme/terminal-theme-list.styl +3 -0
- package/client/components/terminal-theme/theme-list.jsx +146 -0
- package/client/components/text-editor/text-editor-form.jsx +97 -0
- package/client/components/text-editor/text-editor.jsx +182 -0
- package/client/css/antd-overwrite.styl +14 -0
- package/client/css/basic.styl +38 -0
- package/client/css/includes/box.styl +154 -0
- package/client/css/includes/font-size.styl +6 -0
- package/client/css/includes/index.styl +3 -0
- package/client/css/includes/text.styl +31 -0
- package/client/css/includes/theme-default.styl +20 -0
- package/client/entry/basic.js +58 -0
- package/client/entry/index.jsx +15 -0
- package/client/entry/worker.js +137 -0
- package/client/store/address-bookmark.js +25 -0
- package/client/store/app-upgrade.js +23 -0
- package/client/store/batch-input-history.js +26 -0
- package/client/store/bookmark-group.js +128 -0
- package/client/store/bookmark.js +22 -0
- package/client/store/common.js +140 -0
- package/client/store/context-menu.js +23 -0
- package/client/store/db-upgrade.js +43 -0
- package/client/store/event.js +70 -0
- package/client/store/index.js +335 -0
- package/client/store/init-state.js +191 -0
- package/client/store/item.js +120 -0
- package/client/store/load-data.js +198 -0
- package/client/store/quick-command.js +43 -0
- package/client/store/session.js +54 -0
- package/client/store/setting.js +208 -0
- package/client/store/sidebar.js +48 -0
- package/client/store/sync.js +390 -0
- package/client/store/system-menu.js +120 -0
- package/client/store/tab.js +74 -0
- package/client/store/terminal-theme.js +116 -0
- package/client/store/transfer-history.js +27 -0
- package/client/store/transfer-list.js +20 -0
- package/client/store/ui-theme.js +71 -0
- package/client/store/watch.js +116 -0
- package/client/views/index.pug +58 -0
- package/package.json +34 -0
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session tabs component
|
|
3
|
+
* @param {array} props.tabs {id, title}
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react'
|
|
7
|
+
import { findIndex } from 'lodash-es'
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
CodeFilled,
|
|
11
|
+
DownOutlined,
|
|
12
|
+
LeftOutlined,
|
|
13
|
+
PlusCircleOutlined,
|
|
14
|
+
RightOutlined,
|
|
15
|
+
RightSquareFilled
|
|
16
|
+
} from '@ant-design/icons'
|
|
17
|
+
|
|
18
|
+
import { Dropdown, Menu, Popover } from 'antd'
|
|
19
|
+
import Tab from './tab'
|
|
20
|
+
import './tabs.styl'
|
|
21
|
+
import { tabWidth, tabMargin, extraTabWidth, windowControlWidth } from '../../common/constants'
|
|
22
|
+
import createName from '../../common/create-title'
|
|
23
|
+
import findParentBySel from '../../common/find-parent'
|
|
24
|
+
import WindowControl from './window-control'
|
|
25
|
+
import BookmarksList from '../sidebar/bookmark-select'
|
|
26
|
+
import { hasClass } from '../../common/class'
|
|
27
|
+
|
|
28
|
+
const { prefix } = window
|
|
29
|
+
const e = prefix('tabs')
|
|
30
|
+
const c = prefix('control')
|
|
31
|
+
const t = prefix('tabs')
|
|
32
|
+
const MenuItem = Menu.Item
|
|
33
|
+
|
|
34
|
+
export default class Tabs extends React.Component {
|
|
35
|
+
constructor (props) {
|
|
36
|
+
super(props)
|
|
37
|
+
this.tabsRef = React.createRef()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
componentDidMount () {
|
|
41
|
+
this.dom = document.querySelector('.tabs-inner')
|
|
42
|
+
const {
|
|
43
|
+
tabsRef
|
|
44
|
+
} = this
|
|
45
|
+
window.addEventListener('keypress', this.handleTabHotkey)
|
|
46
|
+
tabsRef.current.addEventListener('dblclick', this.handleDblClickEvent)
|
|
47
|
+
tabsRef.current.addEventListener('mousedown', this.handleClickEvent)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
componentDidUpdate (prevProps) {
|
|
51
|
+
prevProps = prevProps || {}
|
|
52
|
+
if (
|
|
53
|
+
prevProps.currentTabId !== this.props.currentTabId ||
|
|
54
|
+
prevProps.width !== this.props.width ||
|
|
55
|
+
prevProps.tabs.map(d => d.title).join('#') !== this.props.tabs.map(d => d.title).join('#')
|
|
56
|
+
) {
|
|
57
|
+
this.adjustScroll()
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// componentWillUnmount () {
|
|
62
|
+
// const {
|
|
63
|
+
// tabsRef
|
|
64
|
+
// } = this
|
|
65
|
+
// window.removeEventListener('keydown', this.handleTabHotkey)
|
|
66
|
+
// tabsRef.current.removeEventListener('mousedown', this.handleClickEvent)
|
|
67
|
+
// }
|
|
68
|
+
|
|
69
|
+
tabsWidth = () => {
|
|
70
|
+
return Array.from(
|
|
71
|
+
document.querySelectorAll('.tab')
|
|
72
|
+
).reduce((prev, c) => {
|
|
73
|
+
return prev + c.clientWidth
|
|
74
|
+
}, 0)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
isOverflow = () => {
|
|
78
|
+
const { tabs = [], width } = this.props
|
|
79
|
+
const len = tabs.length
|
|
80
|
+
const addBtnWidth = 22
|
|
81
|
+
const tabsWidth = this.tabsWidth()
|
|
82
|
+
const tabsWidthAll = tabMargin * len + 130 + tabsWidth
|
|
83
|
+
return width < (tabsWidthAll + addBtnWidth)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
handleTabHotkey = e => {
|
|
87
|
+
if (
|
|
88
|
+
e.ctrlKey &&
|
|
89
|
+
e.code === 'Tab' &&
|
|
90
|
+
!e.shiftKey
|
|
91
|
+
) {
|
|
92
|
+
window.store.clickNextTab()
|
|
93
|
+
} else if (
|
|
94
|
+
e.ctrlKey &&
|
|
95
|
+
e.code === 'Tab' &&
|
|
96
|
+
e.shiftKey
|
|
97
|
+
) {
|
|
98
|
+
window.store.clickPrevTab()
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
handleClickEvent = (e) => {
|
|
103
|
+
if (e.button === 1) {
|
|
104
|
+
const p = findParentBySel(e.target, '.tab')
|
|
105
|
+
if (p) {
|
|
106
|
+
const id = p.dataset.id
|
|
107
|
+
this.props.delTab(id)
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
handleDblClickEvent = e => {
|
|
113
|
+
const t = e.target
|
|
114
|
+
if (
|
|
115
|
+
hasClass(t, 'app-drag-area') ||
|
|
116
|
+
hasClass(t, 'tabs-inner')
|
|
117
|
+
) {
|
|
118
|
+
const {
|
|
119
|
+
isMaximized
|
|
120
|
+
} = window.store
|
|
121
|
+
if (isMaximized) {
|
|
122
|
+
window.pre.runGlobalAsync('unmaximize')
|
|
123
|
+
} else {
|
|
124
|
+
window.pre.runGlobalAsync('maximize')
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
handleAdd = e => {
|
|
130
|
+
if (!e.target.className.includes('tabs-wrapper')) {
|
|
131
|
+
return
|
|
132
|
+
}
|
|
133
|
+
this.props.addTab()
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
adjustScroll = () => {
|
|
137
|
+
const { width, tabs, currentTabId } = this.props
|
|
138
|
+
const index = findIndex(tabs, t => t.id === currentTabId)
|
|
139
|
+
const tabsDomWith = Array.from(
|
|
140
|
+
document.querySelectorAll('.tab')
|
|
141
|
+
).slice(0, index + 2).reduce((prev, c) => {
|
|
142
|
+
return prev + c.clientWidth
|
|
143
|
+
}, 0)
|
|
144
|
+
const w = (index + 1) * tabMargin + 5 + tabsDomWith
|
|
145
|
+
const scrollLeft = w > width - extraTabWidth
|
|
146
|
+
? w - width + extraTabWidth
|
|
147
|
+
: 0
|
|
148
|
+
this.dom.scrollLeft = scrollLeft
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
handleScrollLeft = () => {
|
|
152
|
+
let { scrollLeft } = this.dom
|
|
153
|
+
scrollLeft = scrollLeft - tabMargin - tabWidth
|
|
154
|
+
if (scrollLeft < 0) {
|
|
155
|
+
scrollLeft = 0
|
|
156
|
+
}
|
|
157
|
+
this.dom.scrollLeft = scrollLeft
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
handleScrollRight = () => {
|
|
161
|
+
let { scrollLeft } = this.dom
|
|
162
|
+
scrollLeft = scrollLeft + tabMargin + tabWidth
|
|
163
|
+
if (scrollLeft < 0) {
|
|
164
|
+
scrollLeft = 0
|
|
165
|
+
}
|
|
166
|
+
this.dom.scrollLeft = scrollLeft
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
handleClickMenu = ({ key }) => {
|
|
170
|
+
const id = key.split('##')[1]
|
|
171
|
+
this.props.onChangeTabId(id)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
renderList = () => {
|
|
175
|
+
const { tabs = [] } = this.props
|
|
176
|
+
return (
|
|
177
|
+
<Menu onClick={this.handleClickMenu}>
|
|
178
|
+
{
|
|
179
|
+
tabs.map((t, i) => {
|
|
180
|
+
return (
|
|
181
|
+
<MenuItem
|
|
182
|
+
key={i + '##' + t.id}
|
|
183
|
+
>{createName(t)}
|
|
184
|
+
</MenuItem>
|
|
185
|
+
)
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
</Menu>
|
|
189
|
+
)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
renderMenus () {
|
|
193
|
+
const { addTab } = this.props
|
|
194
|
+
const { onNewSsh } = window.store
|
|
195
|
+
const cls = 'pd2x pd1y context-item pointer'
|
|
196
|
+
return (
|
|
197
|
+
<div
|
|
198
|
+
className='add-menu-wrap' style={{
|
|
199
|
+
maxHeight: window.innerHeight - 200
|
|
200
|
+
}}
|
|
201
|
+
>
|
|
202
|
+
<div
|
|
203
|
+
className={cls}
|
|
204
|
+
onClick={onNewSsh}
|
|
205
|
+
>
|
|
206
|
+
<CodeFilled /> {c('newBookmark')}
|
|
207
|
+
</div>
|
|
208
|
+
<div
|
|
209
|
+
className={cls}
|
|
210
|
+
onClick={() => addTab()}
|
|
211
|
+
>
|
|
212
|
+
<RightSquareFilled /> {t('newTab')}
|
|
213
|
+
</div>
|
|
214
|
+
<BookmarksList
|
|
215
|
+
store={window.store}
|
|
216
|
+
/>
|
|
217
|
+
</div>
|
|
218
|
+
)
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
renderAddBtn = () => {
|
|
222
|
+
return (
|
|
223
|
+
<Popover
|
|
224
|
+
content={this.renderMenus()}
|
|
225
|
+
>
|
|
226
|
+
<PlusCircleOutlined
|
|
227
|
+
title={e('openNewTerm')}
|
|
228
|
+
className='pointer tabs-add-btn font16'
|
|
229
|
+
onClick={() => this.props.addTab()}
|
|
230
|
+
/>
|
|
231
|
+
</Popover>
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
renderExtra () {
|
|
236
|
+
return (
|
|
237
|
+
<div className='tabs-extra pd1x'>
|
|
238
|
+
{this.renderAddBtn()}
|
|
239
|
+
<LeftOutlined
|
|
240
|
+
className='mg1l iblock pointer font12 tab-scroll-icon'
|
|
241
|
+
onClick={this.handleScrollLeft}
|
|
242
|
+
/>
|
|
243
|
+
<RightOutlined
|
|
244
|
+
className='mg1x iblock pointer font12 tab-scroll-icon'
|
|
245
|
+
onClick={this.handleScrollRight}
|
|
246
|
+
/>
|
|
247
|
+
<Dropdown
|
|
248
|
+
className='iblock'
|
|
249
|
+
placement='bottomRight'
|
|
250
|
+
overlay={this.renderList()}
|
|
251
|
+
>
|
|
252
|
+
<DownOutlined className='tabs-dd-icon' />
|
|
253
|
+
</Dropdown>
|
|
254
|
+
</div>
|
|
255
|
+
)
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
render () {
|
|
259
|
+
const { tabs = [], width } = this.props
|
|
260
|
+
const len = tabs.length
|
|
261
|
+
const tabsWidthAll = tabMargin * len + 10 + this.tabsWidth()
|
|
262
|
+
const overflow = this.isOverflow()
|
|
263
|
+
const left = overflow
|
|
264
|
+
? '100%'
|
|
265
|
+
: tabsWidthAll
|
|
266
|
+
const style = {
|
|
267
|
+
width: width - windowControlWidth
|
|
268
|
+
}
|
|
269
|
+
return (
|
|
270
|
+
<div className='tabs' ref={this.tabsRef}>
|
|
271
|
+
<div
|
|
272
|
+
className='tabs-inner'
|
|
273
|
+
style={style}
|
|
274
|
+
>
|
|
275
|
+
<div
|
|
276
|
+
style={{
|
|
277
|
+
left
|
|
278
|
+
}}
|
|
279
|
+
/>
|
|
280
|
+
<div
|
|
281
|
+
className='tabs-wrapper relative'
|
|
282
|
+
style={{
|
|
283
|
+
width: tabsWidthAll + extraTabWidth + 10
|
|
284
|
+
}}
|
|
285
|
+
onDoubleClick={this.handleAdd}
|
|
286
|
+
>
|
|
287
|
+
{
|
|
288
|
+
tabs.map((tab, i) => {
|
|
289
|
+
const isLast = i === len - 1
|
|
290
|
+
return (
|
|
291
|
+
<Tab
|
|
292
|
+
{...this.props}
|
|
293
|
+
tab={tab}
|
|
294
|
+
isLast={isLast}
|
|
295
|
+
key={tab.id}
|
|
296
|
+
/>
|
|
297
|
+
)
|
|
298
|
+
})
|
|
299
|
+
}
|
|
300
|
+
{
|
|
301
|
+
!overflow
|
|
302
|
+
? this.renderAddBtn()
|
|
303
|
+
: null
|
|
304
|
+
}
|
|
305
|
+
</div>
|
|
306
|
+
</div>
|
|
307
|
+
<div className='app-drag' />
|
|
308
|
+
<div className='app-drag-area' />
|
|
309
|
+
<WindowControl
|
|
310
|
+
store={window.store}
|
|
311
|
+
/>
|
|
312
|
+
{
|
|
313
|
+
overflow
|
|
314
|
+
? this.renderExtra()
|
|
315
|
+
: null
|
|
316
|
+
}
|
|
317
|
+
</div>
|
|
318
|
+
)
|
|
319
|
+
}
|
|
320
|
+
}
|