@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.
- package/client/common/default-setting.js +1 -1
- package/client/common/download-mirrors.js +0 -4
- package/client/components/ai/ai-config.jsx +2 -2
- package/client/components/setting-panel/setting-modal.jsx +1 -0
- package/client/components/sidebar/bookmark-select.jsx +3 -1
- package/client/components/terminal/terminal.jsx +0 -1
- package/client/components/tree-list/tree-list.jsx +32 -44
- package/client/store/init-state.js +1 -0
- package/client/store/load-data.js +5 -0
- package/client/store/watch.js +5 -0
- package/package.json +1 -1
|
@@ -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
|
|
22
|
+
value: 'Terminal expert, provide commands for different OS, explain usage briefly, use markdown format'
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
value: '
|
|
25
|
+
value: '终端专家,提供不同系统下命令,简要解释用法,用markdown格式'
|
|
26
26
|
}
|
|
27
27
|
]
|
|
28
28
|
|
|
@@ -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,
|
|
@@ -17,13 +17,12 @@ import {
|
|
|
17
17
|
settingMap
|
|
18
18
|
} from '../../common/constants'
|
|
19
19
|
import findParentBySel from '../../common/find-parent'
|
|
20
|
-
import 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
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
this.onExpand(
|
|
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
|
|
112
|
-
|
|
91
|
+
const {
|
|
92
|
+
expandedKeys
|
|
93
|
+
} = window.store
|
|
94
|
+
const index = expandedKeys.findIndex(
|
|
95
|
+
d => d === group.id
|
|
113
96
|
)
|
|
114
|
-
|
|
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 = (
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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)
|
|
@@ -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
|
})
|
package/client/store/watch.js
CHANGED
|
@@ -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()
|