@electerm/electerm-react 1.50.66 → 1.51.1

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.
Files changed (33) hide show
  1. package/client/common/constants.js +0 -13
  2. package/client/common/is-color-dark.js +33 -0
  3. package/client/components/footer/batch-input.jsx +3 -2
  4. package/client/components/layout/layout-item.jsx +1 -23
  5. package/client/components/layout/layout.jsx +55 -19
  6. package/client/components/layout/layouts.jsx +2 -10
  7. package/client/components/layout/pixed.js +9 -0
  8. package/client/components/main/css-overwrite.jsx +2 -2
  9. package/client/components/quick-commands/quick-commands-select.jsx +1 -1
  10. package/client/components/session/session.jsx +99 -22
  11. package/client/components/session/session.styl +9 -5
  12. package/client/components/session/sessions.jsx +45 -451
  13. package/client/components/setting-panel/setting-modal.jsx +2 -1
  14. package/client/components/sftp/sftp-entry.jsx +1 -1
  15. package/client/components/shortcuts/shortcut-control.jsx +18 -6
  16. package/client/components/sidebar/info-modal.jsx +8 -1
  17. package/client/components/sidebar/side-panel.jsx +1 -1
  18. package/client/components/tabs/index.jsx +70 -9
  19. package/client/components/tabs/on-tab-drop.js +25 -0
  20. package/client/components/tabs/tab.jsx +67 -119
  21. package/client/components/tabs/tabs.styl +12 -1
  22. package/client/components/terminal/index.jsx +10 -5
  23. package/client/components/terminal/terminal-interactive.jsx +1 -7
  24. package/client/components/terminal/terminal.styl +7 -2
  25. package/client/components/theme/theme-form.jsx +1 -1
  26. package/client/components/theme/theme-list-item.jsx +148 -0
  27. package/client/components/theme/theme-list.jsx +18 -72
  28. package/client/store/common.js +0 -7
  29. package/client/store/index.js +5 -39
  30. package/client/store/init-state.js +1 -1
  31. package/client/store/tab.js +338 -86
  32. package/client/store/watch.js +1 -6
  33. package/package.json +1 -1
@@ -0,0 +1,148 @@
1
+ /**
2
+ * theme list render
3
+ */
4
+
5
+ import {
6
+ CheckCircleOutlined,
7
+ PlusOutlined,
8
+ SunOutlined,
9
+ MoonOutlined
10
+ } from '@ant-design/icons'
11
+ import { Tooltip, Tag } from 'antd'
12
+ import classnames from 'classnames'
13
+ import { defaultTheme } from '../../common/constants'
14
+ import highlight from '../common/highlight'
15
+ import isColorDark from '../../common/is-color-dark'
16
+
17
+ const e = window.translate
18
+
19
+ export default function ThemeListItem (props) {
20
+ const {
21
+ item,
22
+ activeItemId,
23
+ theme,
24
+ keyword
25
+ } = props
26
+ const { store } = window
27
+
28
+ function handleClickApply () {
29
+ store.setTheme(item.id)
30
+ }
31
+
32
+ function renderPreview () {
33
+ const {
34
+ main,
35
+ text
36
+ } = item.uiThemeConfig
37
+ const arr = [
38
+ 'error',
39
+ 'success',
40
+ 'warn',
41
+ 'info',
42
+ 'primary'
43
+ ]
44
+ return (
45
+ <div
46
+ className='theme-preview pd2'
47
+ style={{ background: main, color: text }}
48
+ >
49
+ {
50
+ arr.map(k => {
51
+ return (
52
+ <Tag
53
+ color={item.uiThemeConfig[k]}
54
+ key={k}
55
+ className='mg1l mg1b'
56
+ >
57
+ {e(k)}
58
+ </Tag>
59
+ )
60
+ })
61
+ }
62
+ </div>
63
+ )
64
+ }
65
+
66
+ function renderApplyBtn () {
67
+ if (!item.id) {
68
+ return null
69
+ }
70
+ return (
71
+ <Tooltip
72
+ title={renderPreview()}
73
+ placement='topLeft'
74
+ >
75
+ <CheckCircleOutlined
76
+ className='pointer list-item-apply'
77
+ onClick={handleClickApply}
78
+ />
79
+ </Tooltip>
80
+ )
81
+ }
82
+
83
+ function handleClickTheme () {
84
+ props.onClickItem(item)
85
+ }
86
+
87
+ function renderTag () {
88
+ if (!id) {
89
+ return null
90
+ }
91
+ const { main, text } = item.uiThemeConfig
92
+ const isDark = isColorDark(main)
93
+ const txt = isDark ? <MoonOutlined /> : <SunOutlined />
94
+ return (
95
+ <Tag
96
+ color={main}
97
+ className='mg1l'
98
+ style={
99
+ {
100
+ color: text
101
+ }
102
+ }
103
+ >
104
+ {txt}
105
+ </Tag>
106
+ )
107
+ }
108
+
109
+ const { name, id, type } = item
110
+ const cls = classnames(
111
+ 'item-list-unit theme-item',
112
+ {
113
+ current: theme === id
114
+ },
115
+ {
116
+ active: activeItemId === id
117
+ }
118
+ )
119
+ let title = id === defaultTheme.id
120
+ ? e(id)
121
+ : name
122
+ title = highlight(
123
+ title,
124
+ keyword
125
+ )
126
+
127
+ return (
128
+ <div
129
+ className={cls}
130
+ onClick={handleClickTheme}
131
+ >
132
+ <div className='elli pd1y pd2x' title={name}>
133
+ {
134
+ !id
135
+ ? <PlusOutlined className='mg1r' />
136
+ : null
137
+ }
138
+ {renderTag()}{title}
139
+ </div>
140
+ {
141
+ id === defaultTheme.id || type === 'iterm'
142
+ ? null
143
+ : props.renderDelBtn(item)
144
+ }
145
+ {renderApplyBtn(item)}
146
+ </div>
147
+ )
148
+ }
@@ -3,21 +3,13 @@
3
3
  */
4
4
 
5
5
  import List from '../setting-panel/list'
6
- import { CheckCircleOutlined, PlusOutlined, LoadingOutlined } from '@ant-design/icons'
7
- import { Tooltip, Pagination } from 'antd'
8
- import classnames from 'classnames'
9
- import { defaultTheme } from '../../common/constants'
10
- import highlight from '../common/highlight'
6
+ import { LoadingOutlined } from '@ant-design/icons'
7
+ import { pick } from 'lodash-es'
8
+ import { Pagination } from 'antd'
9
+ import ThemeListItem from './theme-list-item'
11
10
  import './terminal-theme-list.styl'
12
11
 
13
- const e = window.translate
14
-
15
12
  export default class ThemeList extends List {
16
- del = (item, e) => {
17
- e.stopPropagation()
18
- this.props.store.delTheme(item)
19
- }
20
-
21
13
  handlePager = page => {
22
14
  this.setState({ page })
23
15
  }
@@ -26,68 +18,22 @@ export default class ThemeList extends List {
26
18
  this.setState({ pageSize, page })
27
19
  }
28
20
 
29
- renderApplyBtn = item => {
30
- if (!item.id) {
31
- return null
32
- }
33
- return (
34
- <Tooltip
35
- title={e('apply')}
36
- placement='topLeft'
37
- >
38
- <CheckCircleOutlined
39
- className='pointer list-item-apply'
40
- onClick={() => this.props.store.setTheme(item.id)}
41
- />
42
- </Tooltip>
43
- )
44
- }
45
-
46
- onClickTheme = item => {
47
- this.props.onClickItem(item)
48
- }
49
-
50
21
  renderItem = (item, i) => {
51
- const { activeItemId } = this.props
52
- const { theme } = this.props
53
- const { name, id, type } = item
54
- const cls = classnames(
55
- 'item-list-unit theme-item',
56
- {
57
- current: theme === id
58
- },
59
- {
60
- active: activeItemId === id
61
- }
62
- )
63
- let title = id === defaultTheme.id
64
- ? e(id)
65
- : name
66
- title = highlight(
67
- title,
68
- this.state.keyword
69
- )
22
+ const itemProps = {
23
+ item,
24
+ renderDelBtn: this.renderDelBtn,
25
+ activeItemId: this.props.activeItemId,
26
+ ...pick(
27
+ this.props,
28
+ [
29
+ 'onClickItem',
30
+ 'theme',
31
+ 'keyword'
32
+ ]
33
+ )
34
+ }
70
35
  return (
71
- <div
72
- key={i + id}
73
- className={cls}
74
- onClick={() => this.onClickTheme(item)}
75
- >
76
- <div className='elli pd1y pd2x' title={name}>
77
- {
78
- !id
79
- ? <PlusOutlined className='mg1r' />
80
- : null
81
- }
82
- {title}
83
- </div>
84
- {
85
- id === defaultTheme.id || type === 'iterm'
86
- ? null
87
- : this.renderDelBtn(item)
88
- }
89
- {this.renderApplyBtn(item)}
90
- </div>
36
+ <ThemeListItem key={item.id} {...itemProps} />
91
37
  )
92
38
  }
93
39
 
@@ -8,7 +8,6 @@ import { debounce, some } from 'lodash-es'
8
8
  import postMessage from '../common/post-msg'
9
9
  import {
10
10
  commonActions,
11
- tabActions,
12
11
  modals,
13
12
  leftSidebarWidthKey,
14
13
  rightSidebarWidthKey,
@@ -24,12 +23,6 @@ export default Store => {
24
23
  Object.assign(this, updates)
25
24
  }
26
25
 
27
- Store.prototype.setOffline = function () {
28
- postMessage({
29
- action: tabActions.setAllTabOffline
30
- })
31
- }
32
-
33
26
  Store.prototype.onError = function (e) {
34
27
  handleError(e)
35
28
  }
@@ -26,6 +26,7 @@ import transferHistoryExtend from './transfer-history'
26
26
  import batchInputHistory from './batch-input-history'
27
27
  import transferExtend from './transfer-list'
28
28
  import addressBookmarkExtend from './address-bookmark'
29
+ import isColorDark from '../common/is-color-dark'
29
30
 
30
31
  import { uniq } from 'lodash-es'
31
32
  import copy from 'json-deep-copy'
@@ -56,40 +57,6 @@ function getReverseColor (hex) {
56
57
  return '#' + reverse.toString(16).padStart(6, '0')
57
58
  }
58
59
 
59
- function expandShorthandColor (color) {
60
- if (color.length === 4) {
61
- return '#' + color[1] + color[1] + color[2] + color[2] + color[3] + color[3]
62
- }
63
- if (color.length === 7) {
64
- return color
65
- }
66
- if (color.length < 7) {
67
- return expandShorthandColor(color + 'f')
68
- }
69
- if (color.length > 7) {
70
- return expandShorthandColor(color.slice(0, 7))
71
- }
72
- if (!/^#[A-Fa-f0-9]{6}$/.test(color)) {
73
- return '#141314'
74
- }
75
- }
76
-
77
- function isColorDark (_color) {
78
- let color = expandShorthandColor(_color)
79
- if (color.charAt(0) === '#') {
80
- color = color.slice(1) // Remove the '#' if present
81
- }
82
- const r = parseInt(color.substr(0, 2), 16)
83
- const g = parseInt(color.substr(2, 2), 16)
84
- const b = parseInt(color.substr(4, 2), 16)
85
-
86
- // Formula to determine brightness
87
- const brightness = (r * 299 + g * 587 + b * 114) / 1000
88
-
89
- // Decide based on brightness threshold
90
- return brightness < 128 // You can adjust this threshold as needed
91
- }
92
-
93
60
  class Store {
94
61
  constructor () {
95
62
  Object.assign(
@@ -123,7 +90,7 @@ class Store {
123
90
  const {
124
91
  currentTabId
125
92
  } = this
126
- const tabs = window.store.getTabs()
93
+ const { tabs } = window.store
127
94
  const tab = tabs.find(t => t.id === currentTabId)
128
95
  if (!tab) {
129
96
  return false
@@ -154,7 +121,7 @@ class Store {
154
121
  }
155
122
 
156
123
  get isTransporting () {
157
- return window.store.getTabs().some(t => t.isTransporting)
124
+ return window.store.tabs.some(t => t.isTransporting)
158
125
  }
159
126
 
160
127
  get settingSidebarList () {
@@ -190,7 +157,7 @@ class Store {
190
157
  }
191
158
 
192
159
  get tabTitles () {
193
- return window.store.getTabs().map(d => d.title).join('#')
160
+ return window.store.tabs.map(d => d.title).join('#')
194
161
  }
195
162
 
196
163
  get setting () {
@@ -275,7 +242,6 @@ const arrGetterProps = [
275
242
  'bookmarks',
276
243
  'bookmarkGroups',
277
244
  'profiles',
278
- 'tabs',
279
245
  'fileTransfers',
280
246
  'transferHistory',
281
247
  'quickCommands',
@@ -335,6 +301,6 @@ transferExtend(Store)
335
301
  addressBookmarkExtend(Store)
336
302
 
337
303
  export const StateStore = Store
338
- const store = manage(new Store(), 1)
304
+ const store = manage(new Store())
339
305
 
340
306
  export default store
@@ -46,7 +46,7 @@ export default () => {
46
46
  configLoaded: false,
47
47
  loadTime: 0,
48
48
  lastDataUpdateTime: 0,
49
- _tabs: '[]',
49
+ tabs: [],
50
50
  currentTabId: '',
51
51
  _history: '[]',
52
52
  _bookmarks: '[]',