Add category filter to monthly stats query and UI
This commit is contained in:
@@ -119,8 +119,8 @@ export async function getOverview(params = {}) {
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export async function getMonthly(months = 12) {
|
||||
const res = await api.get("/stats/monthly", { params: { months } });
|
||||
export async function getMonthly(months = 12, categories) {
|
||||
const params = { months }; if (categories && categories.length > 0) params.categories = categories.join(","); const res = await api.get("/stats/monthly", { params });
|
||||
return res.data;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,13 @@ export default function Dashboard() {
|
||||
loadData();
|
||||
}, []);
|
||||
|
||||
// 勾选变化 → 重新拉月度数据
|
||||
useEffect(() => {
|
||||
if (!raw) return;
|
||||
const cats = [...checked];
|
||||
getMonthly(12, cats).then(setMonthly).catch(console.error);
|
||||
}, [checked, raw]);
|
||||
|
||||
async function loadData() {
|
||||
setLoading(true);
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user