Merge remote-tracking branch 'origin/main'

This commit is contained in:
吕新雨
2026-02-02 11:27:00 +08:00
55 changed files with 2148 additions and 884 deletions

View File

@@ -3,6 +3,7 @@
"ok": "确定",
"cancel": "取消",
"error": "错误",
"notice": "提示",
"openLinkError": "无法打开链接",
"back": "返回"
},

View File

@@ -69,14 +69,29 @@ export async function setReaction(contentId: string, reaction: Reaction): Promis
await setJson(KEY_CONTENT_REACTIONS, next);
}
export async function getFavorites(): Promise<string[]> {
return await getJson<string[]>(KEY_FAVORITES_ITEMS, []);
export type FavoriteItem = {
id: string;
date: string;
themeMode: ThemeMode;
background: string; // 颜色值或图片路径
};
export async function getFavorites(): Promise<FavoriteItem[]> {
return await getJson<FavoriteItem[]>(KEY_FAVORITES_ITEMS, []);
}
export async function addFavorite(contentId: string): Promise<void> {
export async function addFavorite(item: FavoriteItem): Promise<void> {
const list = await getFavorites();
if (list.includes(contentId)) return;
await setJson(KEY_FAVORITES_ITEMS, [...list, contentId]);
if (list.some(i => i.id === item.id)) return;
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> {
const list = await getFavorites();
const next = list.filter(item => item.id !== contentId);
await setJson(KEY_FAVORITES_ITEMS, next);
}
export async function getConsentAccepted(): Promise<boolean> {