Skip to content

Commit

Permalink
feat: recommendation modal
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jun 24, 2024
1 parent 48d141a commit 1f21877
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/renderer/src/models/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,5 @@ export type FeedListModel = {
export type SupportedLanguages = Parameters<
typeof apiClient.ai.translation.$get
>[0]["query"]["language"]

export type RecommendationItem = ExtractBizResponse<typeof apiClient.discover.rsshub.$get>["data"][string]
12 changes: 12 additions & 0 deletions src/renderer/src/modules/discover/recommendation-content.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { RecommendationItem } from "@renderer/models"

export const RecommendationContent = ({
route,
}: {
route: RecommendationItem["routes"][string]
}) => (
<>
rsshub:/
{route.path}
</>
)
25 changes: 24 additions & 1 deletion src/renderer/src/modules/discover/recommendations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@ import {
CardHeader,
CardTitle,
} from "@renderer/components/ui/card"
import { useModalStack } from "@renderer/components/ui/modal/stacked/hooks"
import { useBizQuery } from "@renderer/hooks"
import { Queries } from "@renderer/queries"

import { RecommendationContent } from "./recommendation-content"

export function Recommendations() {
const rsshubPopular = useBizQuery(Queries.discover.rsshubCategory({
category: "popular",
}))
const { present } = useModalStack()

return (
<div className="mt-8">
Expand All @@ -33,7 +37,26 @@ export function Recommendations() {
<CardDescription>
<ul className="space-y-1">
{Object.keys(rsshubPopular.data[key].routes).map((route) => (
<li key={route} className="transition-colors hover:font-medium hover:text-zinc-800">{rsshubPopular.data[key].routes[route].name}</li>
<li
key={route}
className="transition-colors hover:font-medium hover:text-zinc-800"
onClick={() => {
present({
content: () => <RecommendationContent route={rsshubPopular.data[key].routes[route]} />,
title: (
<div className="flex items-center">
<SiteIcon
url={`https://${rsshubPopular.data[key].url}`}
/>
{`${rsshubPopular.data[key].name} - ${rsshubPopular.data[key].routes[route].name}`}
</div>
),
clickOutsideToDismiss: true,
})
}}
>
{rsshubPopular.data[key].routes[route].name}
</li>
))}
</ul>
</CardDescription>
Expand Down

0 comments on commit 1f21877

Please sign in to comment.