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

tab切换交互优化

parent 1c7d55ea
...@@ -86,10 +86,9 @@ function buildCategoryTabItems(groups = []) { ...@@ -86,10 +86,9 @@ function buildCategoryTabItems(groups = []) {
} }
function mergeCategoryTabItems(currentTabs = DEFAULT_CATEGORY_TABS, groups = [], activeCategory) { function mergeCategoryTabItems(currentTabs = DEFAULT_CATEGORY_TABS, groups = [], activeCategory) {
const mergedTabs = buildCategoryTabItems(groups); const mergedTabs = [];
const mergedKeys = new Set(mergedTabs.map((item) => item.key)); const mergedKeys = new Set();
const appendTab = (item) => {
currentTabs.forEach((item) => {
if (item?.key && !mergedKeys.has(item.key)) { if (item?.key && !mergedKeys.has(item.key)) {
mergedKeys.add(item.key); mergedKeys.add(item.key);
mergedTabs.push({ mergedTabs.push({
...@@ -97,14 +96,18 @@ function mergeCategoryTabItems(currentTabs = DEFAULT_CATEGORY_TABS, groups = [], ...@@ -97,14 +96,18 @@ function mergeCategoryTabItems(currentTabs = DEFAULT_CATEGORY_TABS, groups = [],
label: item.label || item.key, label: item.label || item.key,
}); });
} }
}); };
DEFAULT_CATEGORY_TABS.forEach(appendTab);
currentTabs.forEach(appendTab);
buildCategoryTabItems(groups).forEach(appendTab);
if ( if (
activeCategory && activeCategory &&
activeCategory !== ALL_CATEGORY_KEY && activeCategory !== ALL_CATEGORY_KEY &&
!mergedKeys.has(activeCategory) !mergedKeys.has(activeCategory)
) { ) {
mergedTabs.push({ appendTab({
key: activeCategory, key: activeCategory,
label: 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