fix: 统计页面分类明细默认选中所有分类
- 添加 useEffect 在 categoryData 加载后自动选中所有分类 - 移除切换类型时清空选中的逻辑,新数据加载后自动全选 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
98aa39cb1c
commit
6c5e7dc811
@@ -141,9 +141,15 @@ export default function Stats() {
|
|||||||
setCurrentMonth(newDate);
|
setCurrentMonth(newDate);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 当分类数据加载后,默认选中所有分类
|
||||||
|
useEffect(() => {
|
||||||
|
if (categoryData.length > 0) {
|
||||||
|
setSelectedCategories(categoryData.map(cat => cat.category));
|
||||||
|
}
|
||||||
|
}, [categoryData]);
|
||||||
|
|
||||||
const handleCategoryTypeChange = (type) => {
|
const handleCategoryTypeChange = (type) => {
|
||||||
setCategoryType(type);
|
setCategoryType(type);
|
||||||
setSelectedCategories([]); // 切换类型时清空选中
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const toggleCategory = (categoryName) => {
|
const toggleCategory = (categoryName) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user