@electerm/electerm-react 1.60.50 → 1.60.56

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.
@@ -61,6 +61,6 @@ export default {
61
61
  dataSyncSelected: 'all',
62
62
  baseURLAI: 'https://api.deepseek.com',
63
63
  modelAI: 'deepseek-chat',
64
- roleAI: '终端专家,提供不同系统下安全命令,解释用法及风险,用markdown格式',
64
+ roleAI: '终端专家,提供不同系统下命令,简要解释用法,用markdown格式',
65
65
  apiPathAI: '/chat/completions'
66
66
  }
@@ -6,9 +6,5 @@ export default [
6
6
  {
7
7
  name: 'github',
8
8
  url: 'https://github.com/electerm/electerm/releases'
9
- },
10
- {
11
- name: 'sourceforge',
12
- url: 'https://sourceforge.net/projects/electerm.mirror/files/'
13
9
  }
14
10
  ]
@@ -19,10 +19,10 @@ import providers from './providers'
19
19
  const e = window.translate
20
20
  const defaultRoles = [
21
21
  {
22
- value: 'Terminal expert, provide safe commands for different OS, explain usage and risks, use markdown format'
22
+ value: 'Terminal expert, provide commands for different OS, explain usage briefly, use markdown format'
23
23
  },
24
24
  {
25
- value: '终端专家,提供不同系统下安全命令,解释用法及风险,用markdown格式'
25
+ value: '终端专家,提供不同系统下命令,简要解释用法,用markdown格式'
26
26
  }
27
27
  ]
28
28
 
@@ -57,6 +57,7 @@ export default auto(function SettingModalWrap (props) {
57
57
  ...props0,
58
58
  bookmarkSelectMode,
59
59
  bookmarkGroups,
60
+ bookmarksMap: store.bookmarksMap,
60
61
  bookmarks,
61
62
  ...pick(store, [
62
63
  'currentBookmarkGroupId',
@@ -12,7 +12,8 @@ export default auto(function BookmarkSelect (props) {
12
12
  openedSideBar,
13
13
  leftSidebarWidth,
14
14
  expandedKeys,
15
- bookmarks
15
+ bookmarks,
16
+ bookmarksMap
16
17
  } = store
17
18
  if (from === 'sidebar' && openedSideBar !== 'bookmarks') {
18
19
  return null
@@ -33,6 +34,7 @@ export default auto(function BookmarkSelect (props) {
33
34
  const propsTree = {
34
35
  ...base,
35
36
  shouldConfirmDel: true,
37
+ bookmarksMap,
36
38
  bookmarkGroups: store.getBookmarkGroupsTotal(),
37
39
  expandedKeys,
38
40
  leftSidebarWidth,
@@ -1105,7 +1105,6 @@ clear\r`
1105
1105
  }, 200)
1106
1106
 
1107
1107
  onerrorSocket = err => {
1108
- this.setStatus(statusMap.error)
1109
1108
  log.error('onerrorSocket', err)
1110
1109
  }
1111
1110
 
@@ -17,13 +17,12 @@ import {
17
17
  settingMap
18
18
  } from '../../common/constants'
19
19
  import findParentBySel from '../../common/find-parent'
20
- import copy, { deepCopy } from 'json-deep-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 nkeys = [
104
- ...this.state.expandedKeys,
105
- group.id
106
- ]
107
- this.onExpand(nkeys)
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 nkeys = this.state.expandedKeys.filter(
112
- d => d !== group.id
91
+ const {
92
+ expandedKeys
93
+ } = window.store
94
+ const index = expandedKeys.findIndex(
95
+ d => d === group.id
113
96
  )
114
- this.onExpand(nkeys)
97
+ if (index < 0) {
98
+ return
99
+ }
100
+ expandedKeys.splice(index, 1)
101
+ this.onExpand(expandedKeys)
115
102
  }
116
103
 
117
104
  handleChange = keyword => {
@@ -280,12 +267,8 @@ export default class ItemListTree extends Component {
280
267
  })
281
268
  }
282
269
 
283
- onExpand = (expandedKeys) => {
284
- this.setState({
285
- expandedKeys
286
- })
270
+ onExpand = () => {
287
271
  this.closeNewGroupForm()
288
- window.store.expandedKeys = deepCopy(expandedKeys)
289
272
  }
290
273
 
291
274
  onSelect = (
@@ -342,13 +325,10 @@ export default class ItemListTree extends Component {
342
325
  return {
343
326
  showNewBookmarkGroupForm: true,
344
327
  parentId: item.id,
345
- bookmarkGroupTitle: '',
346
- expandedKeys: uniq([
347
- ...old.expandedKeys,
348
- item.id
349
- ])
328
+ bookmarkGroupTitle: ''
350
329
  }
351
330
  })
331
+ window.store.expandedKeys.push(item.id)
352
332
  }
353
333
 
354
334
  openAll = (item) => {
@@ -745,7 +725,7 @@ export default class ItemListTree extends Component {
745
725
  level,
746
726
  group,
747
727
  keyword: this.state.keyword,
748
- expandedKeys: this.state.expandedKeys,
728
+ expandedKeys: this.props.expandedKeys,
749
729
  onExpand: this.onExpandKey,
750
730
  onUnExpand: this.onUnExpandKey
751
731
  }
@@ -766,7 +746,7 @@ export default class ItemListTree extends Component {
766
746
  bookmarkGroupIds = [],
767
747
  id
768
748
  } = group
769
- const shouldRender = this.state.keyword || this.state.expandedKeys.includes(id)
749
+ const shouldRender = this.state.keyword || this.props.expandedKeys.includes(id)
770
750
  if (!shouldRender) {
771
751
  return null
772
752
  }
@@ -786,8 +766,16 @@ export default class ItemListTree extends Component {
786
766
  }
787
767
 
788
768
  renderChilds = (bookmarkIds, pid) => {
769
+ const tree = this.props.bookmarksMap
770
+ const { keyword } = this.state
789
771
  const bookmarks = bookmarkIds.map(id => {
790
- return this.getBookmarkTree()[id]
772
+ const item = tree.get(id)
773
+ if (!item) {
774
+ return null
775
+ }
776
+ return createName(item).toLowerCase().includes(keyword.toLowerCase())
777
+ ? item
778
+ : null
791
779
  }).filter(d => d)
792
780
  return bookmarks.map((node) => {
793
781
  return this.renderItemTitle(node, false, pid)
@@ -52,6 +52,7 @@ export default () => {
52
52
  history: ls.getItemJSON('history', []),
53
53
  sshConfigs: [],
54
54
  bookmarks: [],
55
+ bookmarksMap: new Map(),
55
56
  sidebarPanelTab: 'bookmarks',
56
57
  profiles: [],
57
58
  bookmarkGroups: getDefaultBookmarkGroups([]),
@@ -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
  })
@@ -58,6 +58,11 @@ export default store => {
58
58
  (n || []).map(d => d.id)
59
59
  )
60
60
  refsStatic.add('oldState-' + name, deepCopy(n) || [])
61
+ if (name === 'bookmarks') {
62
+ store.bookmarksMap = new Map(
63
+ n.map(d => [d.id, d])
64
+ )
65
+ }
61
66
  await store.updateLastDataUpdateTime()
62
67
  if (store.config.autoSync) {
63
68
  await store.uploadSettingAll()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "1.60.50",
3
+ "version": "1.60.56",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",