feat(discover): enhance RSSHub recommendations with filters (#1481)
* feat: add language and categories switcher in discover page * docs: add changelog next * feat: only set zh-CN and en as language options * feat: redesign card Signed-off-by: Innei <tukon479@gmail.com> * feat: card new design Signed-off-by: Innei <tukon479@gmail.com> * feat: redesign discover Signed-off-by: Innei <tukon479@gmail.com> * fix: user guide rsshub Signed-off-by: Innei <tukon479@gmail.com> * fix: request loop Signed-off-by: Innei <tukon479@gmail.com> * fix: scroll to active tab Signed-off-by: Innei <tukon479@gmail.com> * fix: staleTime var name * chore: use useGeneralSettingKey to get locale lang * fix: zindex and flush sync Signed-off-by: Innei <tukon479@gmail.com> * fix: darken in dark mode Signed-off-by: Innei <tukon479@gmail.com> * fix: lottie import Signed-off-by: Innei <tukon479@gmail.com> * docs: change discover page changelog --------- Signed-off-by: Innei <tukon479@gmail.com> Co-authored-by: Innei <i@innei.in> Co-authored-by: Innei <tukon479@gmail.com>
This commit is contained in:
Vendored
+3
-2
@@ -9,8 +9,9 @@
|
||||
"tailwindCSS.experimental.classRegex": [
|
||||
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
|
||||
["cx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"],
|
||||
// ["tw\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"]
|
||||
["tw`([^`]*)`", "([^`]*)"]
|
||||
["tw`([^`]*)`", "([^`]*)"],
|
||||
["[a-zA-Z]+[cC]lass[nN]ame[\"'`]?:\\s*[\"'`]([^\"'`]*)[\"'`]", "([^\"'`]*)"],
|
||||
["[a-zA-Z]+[cC]lass[nN]ame\\s*=\\s*[\"'`]([^\"'`]*)[\"'`]", "([^\"'`]*)"]
|
||||
],
|
||||
// If you do not want to autofix some rules on save
|
||||
// You can put this in your user settings or workspace settings
|
||||
|
||||
@@ -14,7 +14,7 @@ export function LottieRenderContainer() {
|
||||
|
||||
return (
|
||||
<RootPortal>
|
||||
<div className="pointer-events-none fixed z-[999]" data-testid="lottie-render-container">
|
||||
<div className="pointer-events-none fixed z-[9999]" data-testid="lottie-render-container">
|
||||
{elements.map((element) => element)}
|
||||
</div>
|
||||
</RootPortal>
|
||||
|
||||
@@ -4,7 +4,15 @@ import type { FC, PropsWithChildren } from "react"
|
||||
import { useEffect } from "react"
|
||||
|
||||
import { modalStackAtom } from "./atom"
|
||||
import { useModalStack } from "./hooks"
|
||||
import { ModalInternal } from "./modal"
|
||||
import type { ModalProps } from "./types"
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
presentModal: (modal: ModalProps) => void
|
||||
}
|
||||
}
|
||||
|
||||
export const ModalStackProvider: FC<PropsWithChildren> = ({ children }) => (
|
||||
<>
|
||||
@@ -14,6 +22,9 @@ export const ModalStackProvider: FC<PropsWithChildren> = ({ children }) => (
|
||||
)
|
||||
|
||||
const ModalStack = () => {
|
||||
const { present } = useModalStack()
|
||||
window.presentModal = present
|
||||
|
||||
const stack = useAtomValue(modalStackAtom)
|
||||
|
||||
const topModalIndex = stack.findLastIndex((item) => item.modal)
|
||||
|
||||
@@ -6,12 +6,14 @@ import { FetchError } from "ofetch"
|
||||
|
||||
import { QUERY_PERSIST_KEY } from "../constants/app"
|
||||
|
||||
const defaultStaleTime = 600_000 // 10min
|
||||
const DO_NOT_RETRY_CODES = new Set([400, 401, 403, 404, 422])
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
refetchOnWindowFocus: false,
|
||||
retryDelay: 1000,
|
||||
staleTime: defaultStaleTime,
|
||||
retry(failureCount, error) {
|
||||
console.error(error)
|
||||
if (
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
export const RSSHubCategoryOptions: {
|
||||
name: string
|
||||
value: string
|
||||
}[] = [
|
||||
{
|
||||
name: "All",
|
||||
value: "all",
|
||||
},
|
||||
{
|
||||
name: "Social Media",
|
||||
value: "social-media",
|
||||
},
|
||||
{
|
||||
name: "New Media",
|
||||
value: "new-media",
|
||||
},
|
||||
{
|
||||
name: "News",
|
||||
value: "traditional-media",
|
||||
},
|
||||
{
|
||||
name: "BBS",
|
||||
value: "bbs",
|
||||
},
|
||||
{
|
||||
name: "Blog",
|
||||
value: "blog",
|
||||
},
|
||||
{
|
||||
name: "Programming",
|
||||
value: "programming",
|
||||
},
|
||||
{
|
||||
name: "Design",
|
||||
value: "design",
|
||||
},
|
||||
{
|
||||
name: "Live",
|
||||
value: "live",
|
||||
},
|
||||
{
|
||||
name: "Multimedia",
|
||||
value: "multimedia",
|
||||
},
|
||||
{
|
||||
name: "Picture",
|
||||
value: "picture",
|
||||
},
|
||||
{
|
||||
name: "ACG",
|
||||
value: "anime",
|
||||
},
|
||||
{
|
||||
name: "Application Updates",
|
||||
value: "program-update",
|
||||
},
|
||||
{
|
||||
name: "University",
|
||||
value: "university",
|
||||
},
|
||||
{
|
||||
name: "Forecast",
|
||||
value: "forecast",
|
||||
},
|
||||
{
|
||||
name: "Travel",
|
||||
value: "travel",
|
||||
},
|
||||
{
|
||||
name: "Shopping",
|
||||
value: "shopping",
|
||||
},
|
||||
{
|
||||
name: "Gaming",
|
||||
value: "game",
|
||||
},
|
||||
{
|
||||
name: "Reading",
|
||||
value: "reading",
|
||||
},
|
||||
{
|
||||
name: "Government",
|
||||
value: "government",
|
||||
},
|
||||
{
|
||||
name: "Study",
|
||||
value: "study",
|
||||
},
|
||||
{
|
||||
name: "Scientific Journal",
|
||||
value: "journal",
|
||||
},
|
||||
{
|
||||
name: "Finance",
|
||||
value: "finance",
|
||||
},
|
||||
]
|
||||
|
||||
export const RSSHubCategoryMap: Record<string, string> = Object.fromEntries(
|
||||
RSSHubCategoryOptions.map((item) => [item.value, item.name]),
|
||||
)
|
||||
@@ -1,58 +1,153 @@
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@follow/components/ui/card/index.jsx"
|
||||
import clsx from "clsx"
|
||||
import { upperFirst } from "lodash-es"
|
||||
import type { FC } from "react"
|
||||
import { memo } from "react"
|
||||
import { memo, useMemo } from "react"
|
||||
|
||||
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
|
||||
import { FeedIcon } from "~/modules/feed/feed-icon"
|
||||
|
||||
import { RSSHubCategoryMap } from "./constants"
|
||||
import { RecommendationContent } from "./recommendation-content"
|
||||
import styles from "./recommendations.module.css"
|
||||
import type { RSSHubRouteDeclaration } from "./types"
|
||||
|
||||
interface RecommendationCardProps {
|
||||
data: RSSHubRouteDeclaration
|
||||
routePrefix: string
|
||||
setCategory: (category: string) => void
|
||||
}
|
||||
export const RecommendationCard: FC<RecommendationCardProps> = memo(({ data, routePrefix }) => {
|
||||
const { present } = useModalStack()
|
||||
return (
|
||||
<Card className="shadow-none">
|
||||
<CardHeader className="p-5 pb-3">
|
||||
<CardTitle className="flex items-center text-base">
|
||||
<FeedIcon siteUrl={`https://${data.url}`} />
|
||||
{data.name}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="p-5 pt-0">
|
||||
<ul className="space-y-1 text-sm text-muted-foreground">
|
||||
{Object.keys(data.routes).map((route) => (
|
||||
<li
|
||||
key={route}
|
||||
className="group hover:text-theme-foreground-hover"
|
||||
onClick={(e) => {
|
||||
;(e.target as HTMLElement).querySelector("button")?.click()
|
||||
}}
|
||||
tabIndex={-1}
|
||||
export const RecommendationCard: FC<RecommendationCardProps> = memo(
|
||||
({ data, routePrefix, setCategory }) => {
|
||||
const { present } = useModalStack()
|
||||
|
||||
const { maintainers, categories } = useMemo(() => {
|
||||
const maintainers = new Set<string>()
|
||||
const categories = new Set<string>()
|
||||
for (const route in data.routes) {
|
||||
const routeData = data.routes[route]
|
||||
if (routeData.maintainers) {
|
||||
routeData.maintainers.forEach((m) => maintainers.add(m))
|
||||
}
|
||||
if (routeData.categories) {
|
||||
routeData.categories.forEach((c) => categories.add(c))
|
||||
}
|
||||
}
|
||||
categories.delete("popular")
|
||||
return {
|
||||
maintainers: Array.from(maintainers),
|
||||
categories: Array.from(categories),
|
||||
}
|
||||
}, [data])
|
||||
|
||||
return (
|
||||
<Card className={styles["recommendations-card"]}>
|
||||
<CardHeader className="relative p-5 pb-3 @container">
|
||||
<div className="absolute left-0 top-0 h-[50px] w-full overflow-hidden @[280px]:h-[80px] dark:brightness-75">
|
||||
<span className="opacity-50 blur-2xl">
|
||||
<FeedIcon
|
||||
disableFadeIn
|
||||
siteUrl={`https://${data.url}`}
|
||||
size={400}
|
||||
className="pointer-events-none size-[500px]"
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<CardTitle className="relative z-[1] flex items-center pt-[10px] text-base @[280px]:pt-10">
|
||||
<span className="center box-content flex aspect-square rounded-full bg-background p-1.5">
|
||||
<span className="overflow-hidden rounded-full">
|
||||
<FeedIcon size={28} className="mr-0" siteUrl={`https://${data.url}`} />
|
||||
</span>
|
||||
</span>
|
||||
<a
|
||||
href={`https://${data.url}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="ml-2 translate-y-1.5"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
className="-translate-x-1.5 rounded p-0.5 px-1.5 duration-200 group-hover:translate-x-0 group-hover:bg-muted"
|
||||
onClick={() => {
|
||||
present({
|
||||
id: `recommendation-content-${route}`,
|
||||
content: () => (
|
||||
<RecommendationContent routePrefix={routePrefix} route={data.routes[route]} />
|
||||
),
|
||||
icon: <FeedIcon className="size-4" size={16} siteUrl={`https://${data.url}`} />,
|
||||
title: `${data.name} - ${data.routes[route].name}`,
|
||||
})
|
||||
{data.name}
|
||||
</a>
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="flex grow flex-col p-5 pt-0">
|
||||
<ul className="grow columns-2 gap-2 space-y-1 text-sm text-foreground/90">
|
||||
{Object.keys(data.routes).map((route) => (
|
||||
<li
|
||||
key={route}
|
||||
className="group ml-1 hover:text-theme-foreground-hover"
|
||||
onClick={(e) => {
|
||||
;(e.target as HTMLElement).querySelector("button")?.click()
|
||||
}}
|
||||
tabIndex={-1}
|
||||
>
|
||||
{data.routes[route].name}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
})
|
||||
<button
|
||||
type="button"
|
||||
className="relative rounded p-0.5 px-1 duration-200 before:absolute before:inset-y-0 before:-left-2 before:my-auto before:size-1.5 before:rounded-full before:bg-accent before:content-[''] group-hover:bg-muted"
|
||||
onClick={() => {
|
||||
present({
|
||||
id: `recommendation-content-${route}`,
|
||||
content: () => (
|
||||
<RecommendationContent
|
||||
routePrefix={routePrefix}
|
||||
route={data.routes[route]}
|
||||
/>
|
||||
),
|
||||
icon: (
|
||||
<FeedIcon className="size-4" size={16} siteUrl={`https://${data.url}`} />
|
||||
),
|
||||
title: `${data.name} - ${data.routes[route].name}`,
|
||||
})
|
||||
}}
|
||||
>
|
||||
{data.routes[route].name}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
<div className="mt-4 flex flex-col gap-2 text-muted-foreground">
|
||||
<div className="flex flex-1 items-center text-sm">
|
||||
<i className="i-mingcute-hammer-line mr-1 shrink-0 translate-y-0.5 self-start" />
|
||||
|
||||
<span className="flex flex-wrap gap-1">
|
||||
{maintainers.map((m) => (
|
||||
<a
|
||||
key={m}
|
||||
href={`https://github.com/${m}`}
|
||||
className="follow-link--underline"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
@{m}
|
||||
</a>
|
||||
))}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-1 items-center text-sm">
|
||||
<i className="i-mingcute-tag-2-line mr-1 shrink-0 translate-y-1 self-start" />
|
||||
<span className="flex flex-wrap gap-1">
|
||||
{categories.map((c) => (
|
||||
<button
|
||||
onClick={() => {
|
||||
if (!RSSHubCategoryMap[c]) return
|
||||
setCategory(c)
|
||||
}}
|
||||
key={c}
|
||||
type="button"
|
||||
className={clsx(
|
||||
"cursor-pointer rounded bg-muted/50 px-1.5 duration-200 hover:bg-muted",
|
||||
!RSSHubCategoryMap[c] && "pointer-events-none opacity-50",
|
||||
)}
|
||||
>
|
||||
{RSSHubCategoryMap[c] || upperFirst(c)}
|
||||
</button>
|
||||
))}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
.recommendations-grid {
|
||||
--rows: 4;
|
||||
--max-item-width: 280px;
|
||||
--gap: 1em;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(
|
||||
auto-fill,
|
||||
minmax(
|
||||
max(var(--max-item-width), calc((100% - var(--gap) * (var(--rows) - 1)) / var(--rows))),
|
||||
1fr
|
||||
)
|
||||
);
|
||||
|
||||
gap: 1em;
|
||||
}
|
||||
|
||||
.recommendations-card {
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 1px 1px rgba(0, 0, 0, 0.06) inset;
|
||||
border: 0;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
@@ -1,59 +1,133 @@
|
||||
import { LoadingCircle } from "@follow/components/ui/loading/index.js"
|
||||
import { ScrollArea } from "@follow/components/ui/scroll-area/index.js"
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@follow/components/ui/select/index.jsx"
|
||||
import { Tabs, TabsList, TabsTrigger } from "@follow/components/ui/tabs/index.js"
|
||||
import { cn, isASCII } from "@follow/utils/utils"
|
||||
import { useMemo } from "react"
|
||||
import { keepPreviousData } from "@tanstack/react-query"
|
||||
import { useMemo, useRef, useState } from "react"
|
||||
import { flushSync } from "react-dom"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { useGeneralSettingKey } from "~/atoms/settings/general"
|
||||
import { useAuthQuery } from "~/hooks/common"
|
||||
import { Queries } from "~/queries"
|
||||
|
||||
import { RSSHubCategoryOptions } from "./constants"
|
||||
import styles from "./recommendations.module.css"
|
||||
import { RecommendationCard } from "./recommendations-card"
|
||||
|
||||
const LanguageOptions = [
|
||||
{
|
||||
name: "English",
|
||||
value: "en",
|
||||
},
|
||||
{
|
||||
name: "简体中文",
|
||||
value: "zh-CN",
|
||||
},
|
||||
] as const
|
||||
|
||||
type Language = (typeof LanguageOptions)[number]["value"]
|
||||
type DiscoverCategories = (typeof RSSHubCategoryOptions)[number]["value"]
|
||||
|
||||
const fetchRsshubPopular = (category: DiscoverCategories, lang: Language) => {
|
||||
return Queries.discover.rsshubCategory({
|
||||
category: "popular",
|
||||
categories: category === "all" ? "popular" : `popular,${category}`,
|
||||
lang,
|
||||
})
|
||||
}
|
||||
export function Recommendations({
|
||||
hideTitle,
|
||||
className,
|
||||
headerClassName,
|
||||
}: {
|
||||
hideTitle?: boolean
|
||||
className?: string
|
||||
headerClassName?: string
|
||||
}) {
|
||||
const rsshubPopular = useAuthQuery(
|
||||
Queries.discover.rsshubCategory({
|
||||
category: "popular",
|
||||
}),
|
||||
{
|
||||
meta: {
|
||||
persist: true,
|
||||
},
|
||||
},
|
||||
)
|
||||
const { t } = useTranslation()
|
||||
const lang = useGeneralSettingKey("language")
|
||||
|
||||
const { data } = rsshubPopular
|
||||
const defaultLang = ["zh-CN", "zh-HK", "zh-TW"].includes(lang ?? "") ? "zh-CN" : "en"
|
||||
const [category, setCategory] = useState<DiscoverCategories>("all")
|
||||
const [selectedLang, setSelectedLang] = useState<Language>(defaultLang)
|
||||
|
||||
const rsshubPopular = useAuthQuery(fetchRsshubPopular(category, selectedLang), {
|
||||
meta: {
|
||||
persist: true,
|
||||
},
|
||||
placeholderData: keepPreviousData,
|
||||
})
|
||||
|
||||
const { data, isLoading, isFetching } = rsshubPopular
|
||||
|
||||
const keys = useMemo(() => {
|
||||
if (data) {
|
||||
return Object.keys(data).sort((a, b) => {
|
||||
const aname = data[a].name
|
||||
const bname = data[b].name
|
||||
|
||||
const aRouteName = data[a].routes[Object.keys(data[a].routes)[0]].name
|
||||
const bRouteName = data[b].routes[Object.keys(data[b].routes)[0]].name
|
||||
|
||||
const ia = isASCII(aname) && isASCII(aRouteName)
|
||||
const ib = isASCII(bname) && isASCII(bRouteName)
|
||||
|
||||
if (ia && ib) {
|
||||
return aname.toLowerCase() < bname.toLowerCase() ? -1 : 1
|
||||
} else if (ia || ib) {
|
||||
return ia > ib ? -1 : 1
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (!data) {
|
||||
return []
|
||||
}
|
||||
return Object.keys(data).sort((a, b) => {
|
||||
const aname = data[a].name
|
||||
const bname = data[b].name
|
||||
|
||||
const aRouteName = data[a].routes[Object.keys(data[a].routes)[0]].name
|
||||
const bRouteName = data[b].routes[Object.keys(data[b].routes)[0]].name
|
||||
|
||||
const ia = isASCII(aname) && isASCII(aRouteName)
|
||||
const ib = isASCII(bname) && isASCII(bRouteName)
|
||||
|
||||
if (ia && ib) {
|
||||
return aname.toLowerCase() < bname.toLowerCase() ? -1 : 1
|
||||
} else if (ia || ib) {
|
||||
return ia > ib ? -1 : 1
|
||||
} else {
|
||||
return 0
|
||||
}
|
||||
})
|
||||
}, [data])
|
||||
|
||||
const { t } = useTranslation()
|
||||
if (rsshubPopular.isLoading) {
|
||||
const handleCategoryChange = (value: DiscoverCategories) => {
|
||||
flushSync(() => {
|
||||
setCategory(value)
|
||||
})
|
||||
rsshubPopular.refetch()
|
||||
}
|
||||
|
||||
const handleLangChange = (value: string) => {
|
||||
flushSync(() => {
|
||||
setSelectedLang(value as Language)
|
||||
})
|
||||
rsshubPopular.refetch()
|
||||
}
|
||||
|
||||
const tabRef = useRef<HTMLDivElement>(null)
|
||||
const handleChangeCategoryAndJumpTo = useEventCallback((category: DiscoverCategories) => {
|
||||
handleCategoryChange(category)
|
||||
|
||||
if (tabRef.current) {
|
||||
const tab = tabRef.current.querySelector(`[data-value="${category}"]`)
|
||||
if (tab) {
|
||||
const tabRect = tab.getBoundingClientRect()
|
||||
const containerRect = tabRef.current.getBoundingClientRect()
|
||||
const scrollLeft =
|
||||
tabRect.left -
|
||||
containerRect.left +
|
||||
tabRef.current.scrollLeft -
|
||||
(containerRect.width - tabRect.width) / 2
|
||||
|
||||
tabRef.current.scrollTo({ left: scrollLeft, behavior: "smooth" })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (isLoading) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -62,12 +136,71 @@ export function Recommendations({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={cn(!hideTitle && "mt-8")}>
|
||||
{!hideTitle && <div className="text-center text-lg font-bold">{t("discover.popular")}</div>}
|
||||
<div className={cn(!hideTitle && "mt-8 w-full max-w-[1200px] px-4")}>
|
||||
{!hideTitle && (
|
||||
<div className="relative text-center text-lg font-bold">
|
||||
<span>{t("discover.popular")}</span>
|
||||
|
||||
<div className={cn("mt-4 grid grid-cols-3 gap-4 px-3", className)}>
|
||||
{isFetching && (
|
||||
<div className="pointer-events-none absolute inset-x-0 top-0 flex items-center justify-center gap-8">
|
||||
<span className="opacity-0" aria-hidden>
|
||||
{t("discover.popular")}
|
||||
</span>
|
||||
<LoadingCircle size="small" className="center flex" />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div
|
||||
className={cn(
|
||||
"z-[9] my-3 flex w-full items-center gap-4 bg-theme-background",
|
||||
headerClassName,
|
||||
)}
|
||||
>
|
||||
<ScrollArea.ScrollArea
|
||||
ref={tabRef}
|
||||
orientation="horizontal"
|
||||
rootClassName="grow min-w-0 overflow-visible"
|
||||
scrollbarClassName="-mb-3 z-[100]"
|
||||
>
|
||||
<Tabs value={category} onValueChange={handleCategoryChange}>
|
||||
<TabsList>
|
||||
{RSSHubCategoryOptions.map((category) => (
|
||||
<TabsTrigger
|
||||
data-value={category.value}
|
||||
key={category.value}
|
||||
value={category.value}
|
||||
>
|
||||
{category.name}
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
</ScrollArea.ScrollArea>
|
||||
<Select value={selectedLang} onValueChange={handleLangChange}>
|
||||
<SelectTrigger size="sm" className="w-32">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
|
||||
<SelectContent className="z-[1]" position="item-aligned">
|
||||
{LanguageOptions.map((lang) => (
|
||||
<SelectItem key={lang.value} value={lang.value}>
|
||||
{lang.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className={cn(styles["recommendations-grid"], "mt-6", className)}>
|
||||
{keys.map((key) => (
|
||||
<RecommendationCard key={key} data={data[key]} routePrefix={key} />
|
||||
<RecommendationCard
|
||||
key={key}
|
||||
data={data[key]}
|
||||
routePrefix={key}
|
||||
setCategory={handleChangeCategoryAndJumpTo}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -73,6 +73,10 @@ type FeedIconFeed =
|
||||
| FeedOrListRespModel
|
||||
|
||||
type FeedIconEntry = Pick<CombinedEntryModel["entries"], "media" | "authorAvatar">
|
||||
const fadeInVariant = {
|
||||
initial: { opacity: 0 },
|
||||
animate: { opacity: 1 },
|
||||
}
|
||||
export function FeedIcon({
|
||||
feed,
|
||||
entry,
|
||||
@@ -82,6 +86,7 @@ export function FeedIcon({
|
||||
fallback = true,
|
||||
siteUrl,
|
||||
useMedia,
|
||||
disableFadeIn,
|
||||
}: {
|
||||
feed?: FeedIconFeed | null
|
||||
entry?: FeedIconEntry | null
|
||||
@@ -95,6 +100,7 @@ export function FeedIcon({
|
||||
fallback?: boolean
|
||||
|
||||
useMedia?: boolean
|
||||
disableFadeIn?: boolean
|
||||
}) {
|
||||
const image =
|
||||
(useMedia
|
||||
@@ -157,7 +163,7 @@ export function FeedIcon({
|
||||
|
||||
ImageElement = (
|
||||
<PlatformIcon url={siteUrl} style={sizeStyle} className={cn("center mr-2", className)}>
|
||||
<m.img style={sizeStyle} initial={{ opacity: 0 }} animate={{ opacity: 1 }} />
|
||||
<m.img style={sizeStyle} {...(disableFadeIn ? {} : fadeInVariant)} />
|
||||
</PlatformIcon>
|
||||
)
|
||||
break
|
||||
@@ -173,8 +179,7 @@ export function FeedIcon({
|
||||
<m.img
|
||||
className={cn("mr-2", className)}
|
||||
style={sizeStyle}
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
{...(disableFadeIn ? {} : fadeInVariant)}
|
||||
/>
|
||||
</PlatformIcon>
|
||||
)
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -6,10 +6,12 @@ import { useAuthQuery } from "~/hooks/common"
|
||||
import { Recommendations } from "~/modules/discover/recommendations"
|
||||
import { Queries } from "~/queries"
|
||||
|
||||
export function RSSHubGuide() {
|
||||
export function RSSHubGuide({ categories, lang }: { categories?: string; lang?: string }) {
|
||||
const rsshubPopular = useAuthQuery(
|
||||
Queries.discover.rsshubCategory({
|
||||
category: "popular",
|
||||
categories,
|
||||
lang,
|
||||
}),
|
||||
{
|
||||
meta: {
|
||||
@@ -30,9 +32,13 @@ export function RSSHubGuide() {
|
||||
|
||||
return (
|
||||
<AppErrorBoundary errorType={ErrorComponentType.RSSHubDiscoverError}>
|
||||
<ScrollArea.ScrollArea viewportClassName="h-[450px]">
|
||||
<ScrollArea.ScrollArea
|
||||
viewportClassName="h-[450px]"
|
||||
scrollbarClassName="-mr-4"
|
||||
rootClassName="overflow-visible"
|
||||
>
|
||||
<div className="space-y-3">
|
||||
<Recommendations hideTitle className="grid-cols-4" />
|
||||
<Recommendations hideTitle headerClassName="sticky top-0" />
|
||||
</div>
|
||||
</ScrollArea.ScrollArea>
|
||||
</AppErrorBoundary>
|
||||
|
||||
@@ -76,7 +76,7 @@ export function Component() {
|
||||
})
|
||||
|
||||
return (
|
||||
<div className="flex flex-col items-center gap-8">
|
||||
<div className="relative flex w-full flex-col items-center gap-8">
|
||||
<div className="pt-12 text-2xl font-bold">{t("words.discover")}</div>
|
||||
<Tabs
|
||||
value={search.get("type") || "search"}
|
||||
|
||||
@@ -30,13 +30,14 @@ import { ErrorComponentType } from "~/components/errors/enum"
|
||||
import { Kbd } from "~/components/ui/kbd/Kbd"
|
||||
import { PlainModal } from "~/components/ui/modal/stacked/custom-modal"
|
||||
import { DeclarativeModal } from "~/components/ui/modal/stacked/declarative-modal"
|
||||
import { HotKeyScopeMap } from "~/constants"
|
||||
import { HotKeyScopeMap, isDev } from "~/constants"
|
||||
import { shortcuts } from "~/constants/shortcuts"
|
||||
import { useDailyTask } from "~/hooks/biz/useDailyTask"
|
||||
import { useAuthQuery, useI18n } from "~/hooks/common"
|
||||
import { EnvironmentIndicator } from "~/modules/app/EnvironmentIndicator"
|
||||
import { NetworkStatusIndicator } from "~/modules/app/NetworkStatusIndicator"
|
||||
import { LoginModalContent } from "~/modules/auth/LoginModalContent"
|
||||
import { DebugRegistry } from "~/modules/debug/registry"
|
||||
import { FeedColumn } from "~/modules/feed-column"
|
||||
import { AutoUpdater } from "~/modules/feed-column/auto-updater"
|
||||
import { CornerPlayer } from "~/modules/feed-column/corner-player"
|
||||
@@ -356,3 +357,27 @@ const NotSupport = () => {
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (isDev) {
|
||||
DebugRegistry.add("New User Guide", () => {
|
||||
import("~/modules/new-user-guide/guide-modal-content").then((m) => {
|
||||
window.presentModal({
|
||||
title: "New User Guide",
|
||||
content: ({ dismiss }) => (
|
||||
<m.GuideModalContent
|
||||
onClose={() => {
|
||||
dismiss()
|
||||
}}
|
||||
/>
|
||||
),
|
||||
|
||||
CustomModalComponent: PlainModal,
|
||||
modalContainerClassName: "flex items-center justify-center",
|
||||
|
||||
canClose: false,
|
||||
clickOutsideToDismiss: false,
|
||||
overlay: true,
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ import { useEffect, useRef } from "react"
|
||||
import { useGeneralSettingKey } from "~/atoms/settings/general"
|
||||
import { appLog } from "~/lib/log"
|
||||
|
||||
const defaultSlateTime = 600_000 // 10min
|
||||
const maxSlateTime = 6 * 60 * (60 * 1000) // 6hr
|
||||
const defaultStaleTime = 600_000 // 10min
|
||||
const maxStaleTime = 6 * 60 * (60 * 1000) // 6hr
|
||||
|
||||
export class ElectronCloseEvent extends Event {
|
||||
static type = "electron-close"
|
||||
@@ -24,7 +24,7 @@ export class ElectronShowEvent extends Event {
|
||||
|
||||
const useSlateTime = () => {
|
||||
const reduceRefetch = useGeneralSettingKey("reduceRefetch")
|
||||
return reduceRefetch ? maxSlateTime : defaultSlateTime
|
||||
return reduceRefetch ? maxStaleTime : defaultStaleTime
|
||||
}
|
||||
/**
|
||||
* Add a event listener to invalidate all queries
|
||||
|
||||
@@ -2,11 +2,21 @@ import { apiClient } from "~/lib/api-fetch"
|
||||
import { defineQuery } from "~/lib/defineQuery"
|
||||
|
||||
export const discover = {
|
||||
rsshubCategory: ({ category }: { category: string }) =>
|
||||
defineQuery(["discover", "rsshub", "category", category], async () => {
|
||||
rsshubCategory: ({
|
||||
category,
|
||||
categories,
|
||||
lang,
|
||||
}: {
|
||||
category?: string
|
||||
categories?: string
|
||||
lang?: string
|
||||
}) =>
|
||||
defineQuery(["discover", "rsshub", "category", category, categories, lang], async () => {
|
||||
const res = await apiClient.discover.rsshub.$get({
|
||||
query: {
|
||||
category,
|
||||
categories,
|
||||
lang,
|
||||
},
|
||||
})
|
||||
return res.data
|
||||
|
||||
@@ -17,7 +17,11 @@ export const localStorage: PersistStorage<any> = {
|
||||
return null
|
||||
}
|
||||
|
||||
return JSON.parse(data)
|
||||
try {
|
||||
return JSON.parse(data)
|
||||
} catch {
|
||||
return data
|
||||
}
|
||||
},
|
||||
setItem: (name, value) => {
|
||||
window.localStorage.setItem(name, JSON.stringify(value))
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
- Now you can export the data from the local database.
|
||||
- App: In consideration of your hard drive, now it supports clearing cache and limiting the size of cache.
|
||||
- Added a new feature to allow minimizing to the system tray by enabling a switch in the settings.
|
||||
- Discover Page: Enhance RSSHub recommendations with filters
|
||||
- Quickly update views or categories at once by dragging and dropping.
|
||||
|
||||
## Improvements
|
||||
|
||||
@@ -127,6 +127,7 @@ export const ScrollArea = React.forwardRef<
|
||||
flex?: boolean
|
||||
mask?: boolean
|
||||
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void
|
||||
orientation?: "vertical" | "horizontal"
|
||||
}
|
||||
>(
|
||||
(
|
||||
@@ -138,6 +139,7 @@ export const ScrollArea = React.forwardRef<
|
||||
scrollbarClassName,
|
||||
mask = false,
|
||||
onScroll,
|
||||
orientation = "vertical",
|
||||
},
|
||||
ref,
|
||||
) => {
|
||||
@@ -156,7 +158,7 @@ export const ScrollArea = React.forwardRef<
|
||||
>
|
||||
{children}
|
||||
</Viewport>
|
||||
<Scrollbar className={scrollbarClassName} />
|
||||
<Scrollbar orientation={orientation} className={scrollbarClassName} />
|
||||
</Root>
|
||||
</ScrollElementContext.Provider>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user