feat(client): i18n copy + reco lang refresh + home polish

This commit is contained in:
1
2026-02-02 20:11:09 +08:00
parent 64b8352ad3
commit 996999453a
19 changed files with 594 additions and 188 deletions

View File

@@ -22,6 +22,7 @@ import {
getFavorites,
setDailyReminderSettings,
removeFavorite,
getRecoFeedCache,
getUserProfile,
type DailyReminderSettings,
type FavoriteItem,
@@ -271,15 +272,21 @@ function FavoritesPage({ visible, page }: { visible: boolean; page: Page }) {
async function refreshFavorites() {
const storedFavs = await getFavorites();
const map = new Map(MOCK_CONTENT.map((c) => [c.id, c.text]));
const list = storedFavs
.map((fav) => ({
...fav,
text: map.get(fav.id) || ''
}))
.filter(item => item.text !== '');
const textMap = new Map<string, string>();
// 1) Mock 文案
MOCK_CONTENT.forEach((c) => textMap.set(String(c.id), t(c.textKey)));
// 2) 后端推荐缓存文案(避免收藏后 cache 覆盖就丢文案)
const cache = await getRecoFeedCache();
cache?.items?.forEach((c) => textMap.set(String(c.content_id), c.text));
// 3) 组装:优先使用收藏时写入的 text其次从 map 回填
const list = storedFavs.map((fav) => ({
...fav,
text: fav.text || textMap.get(String(fav.id)) || t('favorites.unknownText'),
}));
setFavorites(list);
}
@@ -390,7 +397,7 @@ function DailyReminderPage({ visible, onDone }: { visible: boolean; onDone: () =
if (settings.status === 'denied') {
Alert.alert(
t('common.notice'),
"系统权限已被拒绝,请前往手机设置开启通知。"
t('permissions.notificationsDenied')
);
setPushEnabled(false);
return;
@@ -607,12 +614,12 @@ function WidgetHowToPage() {
}
function LanguagePage() {
const { i18n } = useTranslation();
const { t, i18n } = useTranslation();
const currentLang = i18n.language;
const languages = [
{ id: 'zh-TW', label: '繁体' },
{ id: 'en', label: 'English' },
{ id: 'zh-TW', label: t('language.zhTW') },
{ id: 'en', label: t('language.en') },
];
return (