Commit 50af1962 authored by Andy-bubu's avatar Andy-bubu

tab切换交互优化

parent 1c7d55ea
......@@ -86,10 +86,9 @@ function buildCategoryTabItems(groups = []) {
}
function mergeCategoryTabItems(currentTabs = DEFAULT_CATEGORY_TABS, groups = [], activeCategory) {
const mergedTabs = buildCategoryTabItems(groups);
const mergedKeys = new Set(mergedTabs.map((item) => item.key));
currentTabs.forEach((item) => {
const mergedTabs = [];
const mergedKeys = new Set();
const appendTab = (item) => {
if (item?.key && !mergedKeys.has(item.key)) {
mergedKeys.add(item.key);
mergedTabs.push({
......@@ -97,14 +96,18 @@ function mergeCategoryTabItems(currentTabs = DEFAULT_CATEGORY_TABS, groups = [],
label: item.label || item.key,
});
}
});
};
DEFAULT_CATEGORY_TABS.forEach(appendTab);
currentTabs.forEach(appendTab);
buildCategoryTabItems(groups).forEach(appendTab);
if (
activeCategory &&
activeCategory !== ALL_CATEGORY_KEY &&
!mergedKeys.has(activeCategory)
) {
mergedTabs.push({
appendTab({
key: activeCategory,
label: activeCategory,
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment