2 Commits

Author SHA1 Message Date
6e69f09842 fix: 移除重复的"全部"按钮,只更新样式
- HTML中已有"全部"按钮,不需要重复添加
- renderSubcategoryFilters只渲染子类别按钮
- 同时更新"全部"按钮的选中/未选中样式
- 选中时蓝色背景白色文字,未选中时白色背景灰色文字
2026-04-29 22:51:16 +08:00
2dd45854c1 fix: 后台管理子类别筛选按钮显示选中状态
- 添加"全部"按钮,点击可清除筛选
- 选中状态:蓝色背景白色文字
- 未选中状态:白色背景灰色文字+边框
- 用户点击后能看到明显的视觉变化
- 根据当前筛选值动态更新按钮样式
2026-04-29 22:38:50 +08:00

View File

@@ -534,11 +534,31 @@
container.innerHTML = '';
return;
}
// 获取当前筛选值
let currentFilter = '';
if (categoryId === 'ai-models') currentFilter = modelSubcategoryFilter;
else if (categoryId === 'gpus') currentFilter = gpuSubcategoryFilter;
else if (categoryId === 'cpus') currentFilter = cpuSubcategoryFilter;
else if (categoryId === dynamicCategoryId) currentFilter = dynamicSubcategoryFilter;
// 只渲染子类别按钮,不渲染"全部"按钮HTML里已有
container.innerHTML = cat.subcategories.map(sub => `
<button onclick="${filterFunction}('${sub.id}')" class="px-3 py-1 rounded text-sm bg-white border text-gray-600 hover:bg-gray-100">
<i class="${sub.icon} mr-1"></i>${sub.name}
<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}
</button>
`).join('');
// 更新"全部"按钮的样式
const parent = container.parentElement;
if (parent) {
const allBtn = parent.querySelector('button:first-of-type');
if (allBtn && currentFilter === '') {
allBtn.className = 'px-3 py-1 rounded text-sm bg-indigo-600 text-white';
} else if (allBtn) {
allBtn.className = 'px-3 py-1 rounded text-sm bg-white border text-gray-600 hover:bg-gray-100';
}
}
}
const colorMap = {