Merge branch 'main' into damer

This commit is contained in:
吕新雨
2026-02-02 18:37:44 +08:00
29 changed files with 320 additions and 106 deletions

View File

@@ -105,6 +105,7 @@ export async function setReaction(contentId: string, reaction: Reaction): Promis
}
export type FavoriteItem = {
favId: string; // 唯一标识,支持重复点赞同一文案
id: string;
date: string;
themeMode: ThemeMode;
@@ -117,15 +118,15 @@ export async function getFavorites(): Promise<FavoriteItem[]> {
export async function addFavorite(item: FavoriteItem): Promise<void> {
const list = await getFavorites();
if (list.some(i => i.id === item.id)) return;
// 允许重复点赞,不再根据 id 去重
const newList = [item, ...list];
console.log('Adding to favorites, new list size:', newList.length);
await setJson(KEY_FAVORITES_ITEMS, newList);
}
export async function removeFavorite(contentId: string): Promise<void> {
export async function removeFavorite(favId: string): Promise<void> {
const list = await getFavorites();
const next = list.filter(item => item.id !== contentId);
const next = list.filter(item => item.favId !== favId);
await setJson(KEY_FAVORITES_ITEMS, next);
}