mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-02 03:58:07 +08:00
fix: editor组件面板排序问题
This commit is contained in:
parent
40915ed809
commit
6f242678ff
@ -201,21 +201,28 @@ export default class SearchPanel extends React.Component<
|
||||
curSearchResult.push(item);
|
||||
});
|
||||
} else {
|
||||
const searchMap = new Map<string, any>();
|
||||
matchSorter(allResult, keywords, {
|
||||
keys: ['name', 'description', 'scaffold.type', 'searchKeywords']
|
||||
}).forEach(item => {
|
||||
if (item[curTagKey]) {
|
||||
const tags = Array.isArray(item[curTagKey])
|
||||
? item[curTagKey].concat()
|
||||
: item[curTagKey]
|
||||
? [item[curTagKey]]
|
||||
: ['其他'];
|
||||
tags.forEach((tag: string) => {
|
||||
curSearchResultByTag[tag] = curSearchResultByTag[tag] || [];
|
||||
curSearchResultByTag[tag].push(item);
|
||||
});
|
||||
} else {
|
||||
curSearchResult.push(item);
|
||||
searchMap.set(item.id, item);
|
||||
});
|
||||
|
||||
allResult.forEach(item => {
|
||||
if (searchMap.has(item.id)) {
|
||||
if (item[curTagKey]) {
|
||||
const tags = Array.isArray(item[curTagKey])
|
||||
? item[curTagKey].concat()
|
||||
: item[curTagKey]
|
||||
? [item[curTagKey]]
|
||||
: ['其他'];
|
||||
tags.forEach((tag: string) => {
|
||||
curSearchResultByTag[tag] = curSearchResultByTag[tag] || [];
|
||||
curSearchResultByTag[tag].push(item);
|
||||
});
|
||||
} else {
|
||||
curSearchResult.push(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -692,19 +692,26 @@ export const MainStore = types
|
||||
[propName: string]: Array<SubRendererInfo>;
|
||||
} = {};
|
||||
|
||||
const searchMap = new Map<string, any>();
|
||||
matchSorter(subRenderers, keywords, {
|
||||
keys: ['name', 'description', 'scaffold.type', 'searchKeywords']
|
||||
}).forEach(item => {
|
||||
const tags = Array.isArray(item.tags)
|
||||
? item.tags.concat()
|
||||
: item.tags
|
||||
? [item.tags]
|
||||
: ['其他'];
|
||||
searchMap.set(item.id, item);
|
||||
});
|
||||
|
||||
tags.forEach(tag => {
|
||||
grouped[tag] = grouped[tag] || [];
|
||||
grouped[tag].push(item);
|
||||
});
|
||||
subRenderers.forEach(item => {
|
||||
if (searchMap.has(item.id)) {
|
||||
const tags = Array.isArray(item.tags)
|
||||
? item.tags.concat()
|
||||
: item.tags
|
||||
? [item.tags]
|
||||
: ['其他'];
|
||||
|
||||
tags.forEach(tag => {
|
||||
grouped[tag] = grouped[tag] || [];
|
||||
grouped[tag].push(item);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return grouped;
|
||||
|
Loading…
Reference in New Issue
Block a user