Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
"ok": "确定",
|
||||
"cancel": "取消",
|
||||
"error": "错误",
|
||||
"notice": "提示",
|
||||
"openLinkError": "无法打开链接",
|
||||
"back": "返回"
|
||||
},
|
||||
|
||||
@@ -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> {
|
||||
|
||||
Reference in New Issue
Block a user