From 33988c395e58eb5138609db54a3a46e8787792c2 Mon Sep 17 00:00:00 2001 From: pseudoyu Date: Thu, 14 Nov 2024 18:05:47 +0800 Subject: [PATCH] feat: add all language filter in discover --- apps/renderer/src/modules/discover/recommendations.tsx | 8 ++++++-- apps/renderer/src/queries/discover.ts | 2 +- changelog/next.md | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/renderer/src/modules/discover/recommendations.tsx b/apps/renderer/src/modules/discover/recommendations.tsx index 7a117abaaf..770036bdf1 100644 --- a/apps/renderer/src/modules/discover/recommendations.tsx +++ b/apps/renderer/src/modules/discover/recommendations.tsx @@ -24,12 +24,16 @@ import styles from "./recommendations.module.css" import { RecommendationCard } from "./recommendations-card" const LanguageOptions = [ + { + name: "All", + value: "all", + }, { name: "English", value: "en", }, { - name: "简体中文", + name: "中文", value: "zh-CN", }, ] as const @@ -56,7 +60,7 @@ export function Recommendations({ const { t } = useTranslation() const lang = useGeneralSettingKey("language") - const defaultLang = ["zh-CN", "zh-HK", "zh-TW"].includes(lang ?? "") ? "zh-CN" : "en" + const defaultLang = !lang || ["zh-CN", "zh-HK", "zh-TW"].includes(lang) ? "all" : "en" const [category, setCategory] = useState("all") const [selectedLang, setSelectedLang] = useState(defaultLang) diff --git a/apps/renderer/src/queries/discover.ts b/apps/renderer/src/queries/discover.ts index e39c6d51b8..36ee8afd70 100644 --- a/apps/renderer/src/queries/discover.ts +++ b/apps/renderer/src/queries/discover.ts @@ -16,7 +16,7 @@ export const discover = { query: { category, categories, - lang, + ...(lang !== "all" && { lang }), }, }) return res.data diff --git a/changelog/next.md b/changelog/next.md index 690568f72b..43b2d0d4e1 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -6,6 +6,7 @@ - Set `Show Unread Only` as the default option. - Merged the redirect page with the login page. - Introduced entry conditions for actions. +- Added `all` language filter in dicover page. ## Improvements