diff --git a/.vscode/settings.json b/.vscode/settings.json index 67e7943f2..523111761 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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 diff --git a/apps/renderer/src/components/ui/lottie-container/index.tsx b/apps/renderer/src/components/ui/lottie-container/index.tsx index b4fd31cf4..a5b855fa6 100644 --- a/apps/renderer/src/components/ui/lottie-container/index.tsx +++ b/apps/renderer/src/components/ui/lottie-container/index.tsx @@ -14,7 +14,7 @@ export function LottieRenderContainer() { return ( -
+
{elements.map((element) => element)}
diff --git a/apps/renderer/src/components/ui/modal/stacked/provider.tsx b/apps/renderer/src/components/ui/modal/stacked/provider.tsx index 68d49b30f..ecbcdfce5 100644 --- a/apps/renderer/src/components/ui/modal/stacked/provider.tsx +++ b/apps/renderer/src/components/ui/modal/stacked/provider.tsx @@ -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 = ({ children }) => ( <> @@ -14,6 +22,9 @@ export const ModalStackProvider: FC = ({ children }) => ( ) const ModalStack = () => { + const { present } = useModalStack() + window.presentModal = present + const stack = useAtomValue(modalStackAtom) const topModalIndex = stack.findLastIndex((item) => item.modal) diff --git a/apps/renderer/src/lib/query-client.ts b/apps/renderer/src/lib/query-client.ts index 38fa34f8d..23ac59129 100644 --- a/apps/renderer/src/lib/query-client.ts +++ b/apps/renderer/src/lib/query-client.ts @@ -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 ( diff --git a/apps/renderer/src/modules/discover/constants.ts b/apps/renderer/src/modules/discover/constants.ts new file mode 100644 index 000000000..7e87e410d --- /dev/null +++ b/apps/renderer/src/modules/discover/constants.ts @@ -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 = Object.fromEntries( + RSSHubCategoryOptions.map((item) => [item.value, item.name]), +) diff --git a/apps/renderer/src/modules/discover/recommendations-card.tsx b/apps/renderer/src/modules/discover/recommendations-card.tsx index 583acfbc1..3b33056a2 100644 --- a/apps/renderer/src/modules/discover/recommendations-card.tsx +++ b/apps/renderer/src/modules/discover/recommendations-card.tsx @@ -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 = memo(({ data, routePrefix }) => { - const { present } = useModalStack() - return ( - - - - - {data.name} - - - -
    - {Object.keys(data.routes).map((route) => ( -
  • { - ;(e.target as HTMLElement).querySelector("button")?.click() - }} - tabIndex={-1} +export const RecommendationCard: FC = memo( + ({ data, routePrefix, setCategory }) => { + const { present } = useModalStack() + + const { maintainers, categories } = useMemo(() => { + const maintainers = new Set() + const categories = new Set() + 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 ( + + +
    + + + +
    + + + + + + + + - -
  • - ))} -
-
-
- ) -}) + + + ))} + + +
+
+ + + + {maintainers.map((m) => ( + + @{m} + + ))} + +
+
+ + + {categories.map((c) => ( + + ))} + +
+
+ + + ) + }, +) diff --git a/apps/renderer/src/modules/discover/recommendations.module.css b/apps/renderer/src/modules/discover/recommendations.module.css new file mode 100644 index 000000000..9701f20fe --- /dev/null +++ b/apps/renderer/src/modules/discover/recommendations.module.css @@ -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; +} diff --git a/apps/renderer/src/modules/discover/recommendations.tsx b/apps/renderer/src/modules/discover/recommendations.tsx index b0e447204..cef38ed25 100644 --- a/apps/renderer/src/modules/discover/recommendations.tsx +++ b/apps/renderer/src/modules/discover/recommendations.tsx @@ -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("all") + const [selectedLang, setSelectedLang] = useState(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(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 ( -
- {!hideTitle &&
{t("discover.popular")}
} +
+ {!hideTitle && ( +
+ {t("discover.popular")} -
+ {isFetching && ( +
+ + {t("discover.popular")} + + +
+ )} +
+ )} + +
+ + + + {RSSHubCategoryOptions.map((category) => ( + + {category.name} + + ))} + + + + +
+ +
{keys.map((key) => ( - + ))}
diff --git a/apps/renderer/src/modules/feed/feed-icon.tsx b/apps/renderer/src/modules/feed/feed-icon.tsx index 77b62635f..b4abb75c0 100644 --- a/apps/renderer/src/modules/feed/feed-icon.tsx +++ b/apps/renderer/src/modules/feed/feed-icon.tsx @@ -73,6 +73,10 @@ type FeedIconFeed = | FeedOrListRespModel type FeedIconEntry = Pick +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 = ( - + ) break @@ -173,8 +179,7 @@ export function FeedIcon({ ) diff --git a/apps/renderer/src/modules/new-user-guide/guide-modal-content.tsx b/apps/renderer/src/modules/new-user-guide/guide-modal-content.tsx index 5e3d5b5f0..5ac67d8af 100644 --- a/apps/renderer/src/modules/new-user-guide/guide-modal-content.tsx +++ b/apps/renderer/src/modules/new-user-guide/guide-modal-content.tsx @@ -6,7 +6,7 @@ import type { ComponentProps, FunctionComponentElement } from "react" import { createElement, useCallback, useMemo, useState } from "react" import { Trans, useTranslation } from "react-i18next" -import RSSHubIcon from "~/assets/rsshub-icon.png" +import { useGeneralSettingKey } from "~/atoms/settings/general" import { Kbd } from "~/components/ui/kbd/Kbd" import { mountLottie } from "~/components/ui/lottie-container" import { Markdown } from "~/components/ui/markdown/Markdown" @@ -23,6 +23,7 @@ import { LanguageSelector } from "../settings/tabs/general" import { BehaviorGuide } from "./steps/behavior" import { RSSHubGuide } from "./steps/rsshub" +const RSSHubIcon = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAABCCAYAAADjVADoAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAQqADAAQAAAABAAAAQgAAAADorYEXAAAUX0lEQVR4AbWcXYxd11XH97lzZ8bO+DNuWjm1TVI3RGkjp3YMSYqMPBUFhCw/tHHEEy+kKoS+ViDlgfIQKSFvKAJBUx4AqVIjeCgWUsXHuFhpncaxiUP6kdZtYpvmy47jr/F83Xv4/9Ze69x9r+/M+HPL56y11/daZ+999jlzrqt0la3+1rdGEK0ee6wDrF/9h4m0MLerm9JkVVU7xdkq8oZUVbcJtgQRyy1wI3GqJQ50mYbvfbSWoqWqK9VpCZ2Rp+N1XR9utaqpdGnmYPXAH1xCva493irHC22pVngeLiYnVTrwFyPV5NcWkKgP/+2Obmo9LsU9CmTzkgFHMigGbh45FcVoaIVcn44JQMmtsSV64HCq1klZ3a+r8Hx1zxePQKqnptpp9+6OLpZYi7cBD/2CjIJmBLzy9W11p35KV0IFUMsBkI2ujnUqh9lIBBiwpyMV6+hUFKOPX4QV+gGRo+V+LZgPRiGWjW76+6uR9GT1iUePIc4IqZYYHSgPbfXU19pRhM5Lf/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const containerWidth = 600 const variants = { enter: (direction: number) => { @@ -68,10 +69,13 @@ function Outtro() { ) } const absoluteConfettiUrl = new URL(confettiUrl, import.meta.url).href + export function GuideModalContent({ onClose }: { onClose: () => void }) { const t = useI18n() const [step, setStep] = useState(0) const [direction, setDirection] = useState(1) + const lang = useGeneralSettingKey("language") + const defaultLang = ["zh-CN", "zh-HK", "zh-TW"].includes(lang ?? "") ? "zh-CN" : "en" const guideSteps = useMemo( () => @@ -106,7 +110,10 @@ export function GuideModalContent({ onClose }: { onClose: () => void }) { { title: t.app("new_user_guide.step.rsshub.title"), description: t.app("new_user_guide.step.rsshub.info"), - content: createElement(RSSHubGuide), + content: createElement(RSSHubGuide, { + categories: "popular", + lang: defaultLang, + }), icon: , }, { @@ -132,7 +139,7 @@ export function GuideModalContent({ onClose }: { onClose: () => void }) { content: FunctionComponentElement description?: string }[], - [t], + [t, defaultLang], ) const totalSteps = useMemo(() => guideSteps.length, [guideSteps]) @@ -170,7 +177,7 @@ export function GuideModalContent({ onClose }: { onClose: () => void }) { x: { type: "spring", stiffness: 300, damping: 30 }, opacity: { duration: 0.1 }, }} - className="mt-12 px-20 pb-24" + className="mt-12 min-w-0 px-20 pb-24" > {!!title && (
diff --git a/apps/renderer/src/modules/new-user-guide/steps/rsshub.tsx b/apps/renderer/src/modules/new-user-guide/steps/rsshub.tsx index b48920b1b..f96ce2e87 100644 --- a/apps/renderer/src/modules/new-user-guide/steps/rsshub.tsx +++ b/apps/renderer/src/modules/new-user-guide/steps/rsshub.tsx @@ -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 ( - +
- +
diff --git a/apps/renderer/src/pages/(main)/(layer)/(subview)/discover/index.tsx b/apps/renderer/src/pages/(main)/(layer)/(subview)/discover/index.tsx index 2ae212c67..05483cde4 100644 --- a/apps/renderer/src/pages/(main)/(layer)/(subview)/discover/index.tsx +++ b/apps/renderer/src/pages/(main)/(layer)/(subview)/discover/index.tsx @@ -76,7 +76,7 @@ export function Component() { }) return ( -
+
{t("words.discover")}
{
) } + +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 }) => ( + { + dismiss() + }} + /> + ), + + CustomModalComponent: PlainModal, + modalContainerClassName: "flex items-center justify-center", + + canClose: false, + clickOutsideToDismiss: false, + overlay: true, + }) + }) + }) +} diff --git a/apps/renderer/src/providers/invalidate-query-provider.tsx b/apps/renderer/src/providers/invalidate-query-provider.tsx index 7ce0ff998..e385d313a 100644 --- a/apps/renderer/src/providers/invalidate-query-provider.tsx +++ b/apps/renderer/src/providers/invalidate-query-provider.tsx @@ -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 diff --git a/apps/renderer/src/queries/discover.ts b/apps/renderer/src/queries/discover.ts index 8b57f0041..e39c6d51b 100644 --- a/apps/renderer/src/queries/discover.ts +++ b/apps/renderer/src/queries/discover.ts @@ -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 diff --git a/apps/renderer/src/store/utils/helper.ts b/apps/renderer/src/store/utils/helper.ts index 988972457..d34be28cd 100644 --- a/apps/renderer/src/store/utils/helper.ts +++ b/apps/renderer/src/store/utils/helper.ts @@ -17,7 +17,11 @@ export const localStorage: PersistStorage = { return null } - return JSON.parse(data) + try { + return JSON.parse(data) + } catch { + return data + } }, setItem: (name, value) => { window.localStorage.setItem(name, JSON.stringify(value)) diff --git a/changelog/next.md b/changelog/next.md index 1103d6615..ec6e53b2c 100644 --- a/changelog/next.md +++ b/changelog/next.md @@ -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 diff --git a/packages/components/src/ui/scroll-area/ScrollArea.tsx b/packages/components/src/ui/scroll-area/ScrollArea.tsx index 5217ca54f..d2264efcb 100644 --- a/packages/components/src/ui/scroll-area/ScrollArea.tsx +++ b/packages/components/src/ui/scroll-area/ScrollArea.tsx @@ -127,6 +127,7 @@ export const ScrollArea = React.forwardRef< flex?: boolean mask?: boolean onScroll?: (e: React.UIEvent) => 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} - + )