Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 080e00b6c6 |
@@ -535,27 +535,26 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取当前筛选值
|
// 获取当前筛选值 - 根据容器ID判断
|
||||||
let currentFilter = '';
|
let currentFilter = '';
|
||||||
if (categoryId === 'ai-models') currentFilter = modelSubcategoryFilter;
|
if (containerId === 'model-subcategory-filters') currentFilter = modelSubcategoryFilter;
|
||||||
else if (categoryId === 'gpus') currentFilter = gpuSubcategoryFilter;
|
else if (containerId === 'gpu-subcategory-filters') currentFilter = gpuSubcategoryFilter;
|
||||||
else if (categoryId === 'cpus') currentFilter = cpuSubcategoryFilter;
|
else if (containerId === 'cpu-subcategory-filters') currentFilter = cpuSubcategoryFilter;
|
||||||
else if (categoryId === dynamicCategoryId) currentFilter = dynamicSubcategoryFilter;
|
else if (containerId === 'dynamic-subcategory-filters') currentFilter = dynamicSubcategoryFilter;
|
||||||
|
|
||||||
// 只渲染子类别按钮,不渲染"全部"按钮(HTML里已有)
|
// 渲染子类别按钮
|
||||||
container.innerHTML = cat.subcategories.map(sub => `
|
container.innerHTML = cat.subcategories.map(sub => `
|
||||||
<button onclick="${filterFunction}('${sub.id}')" class="px-3 py-1 rounded text-sm ${currentFilter === sub.id ? 'bg-indigo-600 text-white' : 'bg-white border text-gray-600 hover:bg-gray-100'}">
|
<button onclick="${filterFunction}('${sub.id}')" class="px-3 py-1 rounded text-sm ${currentFilter === sub.id ? 'bg-indigo-600 text-white' : 'bg-white border text-gray-600 hover:bg-gray-100'}">
|
||||||
<i class="${sub.icon || 'ri-folder-line'} mr-1"></i>${sub.name}
|
<i class="${sub.icon || 'ri-folder-line'} mr-1"></i>${sub.name}
|
||||||
</button>
|
</button>
|
||||||
`).join('');
|
`).join('');
|
||||||
|
|
||||||
// 更新"全部"按钮的样式
|
// 更新"全部"按钮的样式 - 它是容器前面的那个按钮
|
||||||
const parent = container.parentElement;
|
const allBtn = container.previousElementSibling;
|
||||||
if (parent) {
|
if (allBtn && allBtn.tagName === 'BUTTON') {
|
||||||
const allBtn = parent.querySelector('button:first-of-type');
|
if (currentFilter === '') {
|
||||||
if (allBtn && currentFilter === '') {
|
|
||||||
allBtn.className = 'px-3 py-1 rounded text-sm bg-indigo-600 text-white';
|
allBtn.className = 'px-3 py-1 rounded text-sm bg-indigo-600 text-white';
|
||||||
} else if (allBtn) {
|
} else {
|
||||||
allBtn.className = 'px-3 py-1 rounded text-sm bg-white border text-gray-600 hover:bg-gray-100';
|
allBtn.className = 'px-3 py-1 rounded text-sm bg-white border text-gray-600 hover:bg-gray-100';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user