Merge pull request #8419 from igrowp/fix-search-sort

fix: editor组件面板排序问题
This commit is contained in:
hsm-lv 2023-10-18 16:33:41 +08:00 committed by GitHub
commit 421cdb9169
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 23 deletions

View File

@ -126,7 +126,7 @@ div.ae-editor-FormulaControl {
background: #007bff;
color: #fff;
padding: 1px 5px;
border-radius: 4px 0 0 4px;
border-radius: 4px;
height: 26px;
flex: none;
> div,

View File

@ -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);
}
}
});
}

View File

@ -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;

View File

@ -2713,7 +2713,7 @@ extendLocale('en-US', {
'3bce1a6217990c8dc087d254f1fe754a': 'Automatic fill',
'f01553e415ca33cc89d0bca84023f4b5':
'Automatically fill the value in a field of the currently-selected option into a form item in the form. The data mapping is supportive.',
'04d815a5d4b803d6bb956d2da5a82688': 'Required?',
'04d815a5d4b803d6bb956d2da5a82688': 'Required',
'a1b6281dc554ac84a3e6062f812fe50d':
'Light text description below the form item control',
'85541bd9f7f39a6e6d9d26cbe09cbdd4': 'Read-only',