fix: tag stats

This commit is contained in:
Steven
2025-01-08 22:35:34 +08:00
parent d9d6f73330
commit 012ca1d780

View File

@@ -59,12 +59,17 @@ export const useMemoTagList = () => {
const memos = Object.values(memoStore.getState().dataMapByName); const memos = Object.values(memoStore.getState().dataMapByName);
const tagAmounts: Record<string, number> = {}; const tagAmounts: Record<string, number> = {};
memos.forEach((memo) => { memos.forEach((memo) => {
memo.tags.forEach((tag) => { const tagSet = new Set<string>();
if (tagAmounts[tag]) { for (const tag of memo.tags) {
tagAmounts[tag] += 1; const parts = tag.split("/");
} else { let currentTag = "";
tagAmounts[tag] = 1; for (const part of parts) {
currentTag = currentTag ? `${currentTag}/${part}` : part;
tagSet.add(currentTag);
} }
}
Array.from(tagSet).forEach((tag) => {
tagAmounts[tag] = tagAmounts[tag] ? tagAmounts[tag] + 1 : 1;
}); });
}); });
return tagAmounts; return tagAmounts;