@electerm/electerm-react 1.60.48 → 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
 
@@ -1250,7 +1249,7 @@ clear\r`
1250
1249
  items: this.renderContextMenu(),
1251
1250
  onClick: this.onContextMenu
1252
1251
  },
1253
- trigger: ['contextMenu']
1252
+ trigger: this.props.config.pasteWhenContextMenu ? [] : ['contextMenu']
1254
1253
  }
1255
1254
  return (
1256
1255
  <Dropdown {...dropdownProps}>
@@ -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([]),
@@ -2,14 +2,13 @@
2
2
  * load data from db
3
3
  */
4
4
 
5
- import { dbNames, update, getData, fetchInitData, insert, remove } from '../common/db'
5
+ import { dbNames, getData, fetchInitData } from '../common/db'
6
6
  import parseInt10 from '../common/parse-int10'
7
7
  import { infoTabs, statusMap, defaultEnvLang } from '../common/constants'
8
8
  import fs from '../common/fs'
9
9
  import generate from '../common/id-with-stamp'
10
10
  import defaultSettings from '../common/default-setting'
11
11
  import encodes from '../components/bookmark-form/encodes'
12
- import runIdle from '../common/run-idle'
13
12
  import { initWsCommon } from '../common/fetch-from-server'
14
13
  import safeParse from '../common/parse-json-safe'
15
14
  import initWatch from './watch'
@@ -107,27 +106,6 @@ export async function addTabFromCommandLine (store, opts) {
107
106
  }
108
107
 
109
108
  export default (Store) => {
110
- Store.prototype.batchDbUpdate = async function (updates) {
111
- runIdle(() => {
112
- for (const u of updates) {
113
- update(u.id, u.update, u.db, u.upsert)
114
- }
115
- })
116
- }
117
- Store.prototype.batchDbAdd = async function (adds) {
118
- runIdle(() => {
119
- for (const u of adds) {
120
- insert(u.db, u.obj)
121
- }
122
- })
123
- }
124
- Store.prototype.batchDbDel = async function (dels) {
125
- runIdle(() => {
126
- for (const u of dels) {
127
- remove(u.db, u.id)
128
- }
129
- })
130
- }
131
109
  Store.prototype.openInitSessions = function () {
132
110
  const { store } = window
133
111
  const arr = store.config.onStartSessions || []
@@ -188,6 +166,11 @@ export default (Store) => {
188
166
  for (const { name, data } of arr) {
189
167
  const dt = JSON.parse(data || '[]')
190
168
  refsStatic.add('oldState-' + name, dt)
169
+ if (name === 'bookmarks') {
170
+ ext.bookmarksMap = new Map(
171
+ dt.map(d => [d.id, d])
172
+ )
173
+ }
191
174
  ext[name] = dt
192
175
  }
193
176
  })
@@ -7,7 +7,7 @@ import copy from 'json-deep-copy'
7
7
  import {
8
8
  settingMap, packInfo, syncTypes, syncDataMaps
9
9
  } from '../common/constants'
10
- import { remove, dbNames, insert, update, getData } from '../common/db'
10
+ import { dbNames, update, getData } from '../common/db'
11
11
  import fetch from '../common/fetch-from-server'
12
12
  import download from '../common/download'
13
13
  import { fixBookmarks } from '../common/db-fix'
@@ -259,7 +259,6 @@ export default (Store) => {
259
259
  token,
260
260
  store.getProxySetting()
261
261
  )
262
- const toInsert = []
263
262
  const { names, syncConfig } = store.getDataSyncNames()
264
263
  for (const n of names) {
265
264
  let str = get(gist, `files["${n}.json"].content`)
@@ -290,10 +289,6 @@ export default (Store) => {
290
289
  return ai - bi
291
290
  })
292
291
  }
293
- toInsert.push({
294
- name: n,
295
- value: arr
296
- })
297
292
  store.setItems(n, arr)
298
293
  }
299
294
  if (syncConfig) {
@@ -321,10 +316,6 @@ export default (Store) => {
321
316
  up[type + 'SyncPassword'] = pass
322
317
  }
323
318
  store.updateSyncSetting(up)
324
- for (const u of toInsert) {
325
- await remove(u.name)
326
- await insert(u.name, u.value)
327
- }
328
319
  store.isSyncingSetting = false
329
320
  store.isSyncDownload = false
330
321
  }
@@ -389,7 +380,6 @@ export default (Store) => {
389
380
  .readFile(file.path)
390
381
  const { store } = window
391
382
  const objs = JSON.parse(txt)
392
- const toInsert = []
393
383
  const { names } = store.getDataSyncNames(true)
394
384
  for (const n of names) {
395
385
  let arr = objs[n]
@@ -398,16 +388,8 @@ export default (Store) => {
398
388
  } else if (n === settingMap.bookmarks) {
399
389
  arr = fixBookmarks(arr)
400
390
  }
401
- toInsert.push({
402
- name: n,
403
- value: arr
404
- })
405
391
  store.setItems(n, objs[n])
406
392
  }
407
- for (const u of toInsert) {
408
- await remove(u.name)
409
- await insert(u.name, u.value)
410
- }
411
393
  store.updateConfig(objs.config)
412
394
  store.setTheme(objs.config.theme)
413
395
  }
@@ -4,7 +4,7 @@
4
4
 
5
5
  import createTitle from '../common/create-title'
6
6
  import { autoRun } from 'manate'
7
- import { update, remove, dbNamesForWatch } from '../common/db'
7
+ import { update, remove, insert, dbNamesForWatch } from '../common/db'
8
8
  import {
9
9
  sftpDefaultSortSettingKey,
10
10
  checkedKeysLsKey,
@@ -50,17 +50,19 @@ export default store => {
50
50
  for (const item of updated) {
51
51
  await update(item.id, item, name, false)
52
52
  }
53
- store.batchDbAdd(added.map(d => {
54
- return {
55
- db: name,
56
- obj: d
57
- }
58
- }))
53
+ for (const item of added) {
54
+ await insert(name, item)
55
+ }
59
56
  await update(
60
57
  `${name}:order`,
61
58
  (n || []).map(d => d.id)
62
59
  )
63
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
+ }
64
66
  await store.updateLastDataUpdateTime()
65
67
  if (store.config.autoSync) {
66
68
  await store.uploadSettingAll()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "1.60.48",
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",