Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ae23ec42ad | |||
| 080e00b6c6 | |||
| 6e69f09842 | |||
| 2dd45854c1 |
@@ -534,11 +534,30 @@
|
||||
container.innerHTML = '';
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取当前筛选值 - 根据容器ID判断
|
||||
let currentFilter = '';
|
||||
if (containerId === 'model-subcategory-filters') currentFilter = modelSubcategoryFilter;
|
||||
else if (containerId === 'gpu-subcategory-filters') currentFilter = gpuSubcategoryFilter;
|
||||
else if (containerId === 'cpu-subcategory-filters') currentFilter = cpuSubcategoryFilter;
|
||||
else if (containerId === 'dynamic-subcategory-filters') currentFilter = dynamicSubcategoryFilter;
|
||||
|
||||
// 渲染子类别按钮
|
||||
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 allBtn = container.previousElementSibling;
|
||||
if (allBtn && allBtn.tagName === 'BUTTON') {
|
||||
if (currentFilter === '') {
|
||||
allBtn.className = 'px-3 py-1 rounded text-sm bg-indigo-600 text-white';
|
||||
} else {
|
||||
allBtn.className = 'px-3 py-1 rounded text-sm bg-white border text-gray-600 hover:bg-gray-100';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const colorMap = {
|
||||
@@ -647,7 +666,7 @@
|
||||
} else {
|
||||
// 动态分类
|
||||
html += `
|
||||
<a href="#cat-${cat.id}" onclick="showDynamicCategory('${cat.id}')" class="sidebar-link flex items-center gap-2 px-3 py-2 rounded-lg text-gray-300" data-section="cat-${cat.id}">
|
||||
<a href="#cat-${cat.id}" onclick="dynamicSubcategoryFilter='';showDynamicCategory('${cat.id}')" class="sidebar-link flex items-center gap-2 px-3 py-2 rounded-lg text-gray-300" data-section="cat-${cat.id}">
|
||||
<i class="${cat.icon}"></i>
|
||||
<span>${cat.name}管理</span>
|
||||
</a>
|
||||
@@ -669,7 +688,8 @@
|
||||
// 显示动态分类数据
|
||||
async function showDynamicCategory(categoryId) {
|
||||
dynamicCategoryId = categoryId;
|
||||
dynamicSubcategoryFilter = '';
|
||||
// 不要每次都重置筛选值,除非是新切换的分类
|
||||
// dynamicSubcategoryFilter = ''; // 移除这行
|
||||
const cat = categories.find(c => c.id === categoryId);
|
||||
const fields = cat ? (cat.fields || []) : [];
|
||||
const fixedFields = ['id', 'created_at', 'updated_at', 'visible', 'raw_text', 'category_id', 'subcategory_id', 'is_pinned', 'images'];
|
||||
|
||||
Reference in New Issue
Block a user