diff --git a/apps/mobile/src/modules/discover/DiscoverContent.tsx b/apps/mobile/src/modules/discover/DiscoverContent.tsx index 4aa014363..3b5e42508 100644 --- a/apps/mobile/src/modules/discover/DiscoverContent.tsx +++ b/apps/mobile/src/modules/discover/DiscoverContent.tsx @@ -1,3 +1,4 @@ +import type { RSSHubCategory } from "@follow/constants" import { CategoryMap, RSSHubCategories } from "@follow/constants" import { LinearGradient } from "expo-linear-gradient" import { memo } from "react" @@ -30,19 +31,17 @@ export function DiscoverContent() { const DiscoverGrid = () => { return ( - - - {RSSHubCategories.map((category) => ( - - ))} - - + + {RSSHubCategories.map((category) => ( + + ))} + ) } -const CategoryItem = memo(({ category }: { category: string }) => { +const CategoryItem = memo(({ category }: { category: RSSHubCategory }) => { const { t } = useTranslation("common") - const name = t(`discover.category.${category}` as any) + const name = t(`discover.category.${category}`) const navigation = useNavigation() return ( @@ -60,19 +59,14 @@ const CategoryItem = memo(({ category }: { category: string }) => { }} > - - {CategoryMap[category as keyof typeof CategoryMap].emoji} - + {CategoryMap[category].emoji} {name} diff --git a/packages/internal/constants/src/rsshub.ts b/packages/internal/constants/src/rsshub.ts index 9e0579370..302945e21 100644 --- a/packages/internal/constants/src/rsshub.ts +++ b/packages/internal/constants/src/rsshub.ts @@ -24,10 +24,9 @@ export const RSSHubCategories = [ "finance", ] as const -export const CategoryMap: Record< - (typeof RSSHubCategories)[number], - { color: string; emoji: string } -> = { +export type RSSHubCategory = (typeof RSSHubCategories)[number] + +export const CategoryMap: Record = { all: { color: "#FFCA28", emoji: "⭐️" }, "social-media": { color: "#42A5F5", emoji: "💬" }, "new-media": { color: "#FF7043", emoji: "📣" },