From e14cda3b869e604169390a3e57c0e2a682c1b875 Mon Sep 17 00:00:00 2001 From: Innei Date: Sat, 17 May 2025 16:41:41 +0800 Subject: [PATCH 01/76] fix: footer mark read alignment Signed-off-by: Innei --- apps/desktop/configs/vite.render.config.ts | 1 + .../components/FooterMarkItem.tsx | 26 +++++++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/apps/desktop/configs/vite.render.config.ts b/apps/desktop/configs/vite.render.config.ts index 4178ee333..4fa8bff20 100644 --- a/apps/desktop/configs/vite.render.config.ts +++ b/apps/desktop/configs/vite.render.config.ts @@ -51,6 +51,7 @@ export const viteRenderBaseConfig = { codeInspectorPlugin({ bundler: "vite", + hotKeys: ["altKey"], editor: "cursor", }), sentryVitePlugin({ diff --git a/apps/desktop/layer/renderer/src/modules/entry-column/components/FooterMarkItem.tsx b/apps/desktop/layer/renderer/src/modules/entry-column/components/FooterMarkItem.tsx index 50a513777..c0eeba799 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-column/components/FooterMarkItem.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-column/components/FooterMarkItem.tsx @@ -13,22 +13,26 @@ export const FooterMarkItem = ({ view }: { view: FeedViewType }) => { const SocialMediaFooterMarkItem = () => { return ( - +
+ +
) } const GridFooterMarkItem = () => { return ( - +
+ +
) } From c8d11b58e999ccda7d5baf9e19de3e7f2c7e3372 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sun, 18 May 2025 13:33:02 +0800 Subject: [PATCH 02/76] feat: update transformVideoUrl --- packages/internal/utils/src/url-for-video.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/internal/utils/src/url-for-video.ts b/packages/internal/utils/src/url-for-video.ts index c5650b443..ae83a39d8 100644 --- a/packages/internal/utils/src/url-for-video.ts +++ b/packages/internal/utils/src/url-for-video.ts @@ -38,6 +38,18 @@ export const transformVideoUrl = ({ ).toString()}` } + if (url?.match(/\/\/www.pornhub.com\/view_video.php\?viewkey=\w+/)) { + if (mini) { + return null + } else { + return `https://www.pornhub.com/embed/${url.match(/\/\/www.pornhub.com\/view_video.php\?viewkey=(\w+)/)?.[1]}?${new URLSearchParams( + { + autoplay: "1", + }, + ).toString()}` + } + } + if (attachments) { return attachments.find((attachment) => attachment.mime_type === "text/html")?.url ?? null } From 2234b4b1a681890357fcc19a190637fd735a68ae Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sun, 18 May 2025 13:59:58 +0800 Subject: [PATCH 03/76] feat: display video duration --- .../modules/entry-column/Items/video-item.tsx | 18 +++++++- .../entry-list/templates/EntryVideoItem.tsx | 45 +++++++++++++------ packages/internal/utils/exports.ts | 1 + packages/internal/utils/src/duration.ts | 19 ++++++++ 4 files changed, 68 insertions(+), 15 deletions(-) create mode 100644 packages/internal/utils/src/duration.ts diff --git a/apps/desktop/layer/renderer/src/modules/entry-column/Items/video-item.tsx b/apps/desktop/layer/renderer/src/modules/entry-column/Items/video-item.tsx index 94ae61a14..00ce06383 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-column/Items/video-item.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-column/Items/video-item.tsx @@ -2,6 +2,7 @@ import { isMobile } from "@follow/components/hooks/useMobile.js" import { Skeleton } from "@follow/components/ui/skeleton/index.jsx" import { IN_ELECTRON } from "@follow/shared/constants" import { stopPropagation } from "@follow/utils/dom" +import { formatDuration } from "@follow/utils/duration" import { transformVideoUrl } from "@follow/utils/url-for-video" import { cn } from "@follow/utils/utils" import { useHover } from "@use-gesture/react" @@ -77,6 +78,16 @@ export function VideoItem({ entryId, entryPreview, translation }: UniversalItemP } }, [hovered]) + const duration = useMemo(() => { + const seconds = entry?.entries.attachments?.find( + (attachment) => attachment.duration_in_seconds, + )?.duration_in_seconds + if (seconds) { + return formatDuration(Number.parseInt(seconds.toString())) + } + return 0 + }, [entry?.entries.attachments]) + if (!entry) return null return ( @@ -107,7 +118,7 @@ export function VideoItem({ entryId, entryPreview, translation }: UniversalItemP } }} > -
+
{miniIframeSrc && showPreview ? ( )} + {!!duration && ( +
+ {duration} +
+ )}
diff --git a/apps/mobile/src/modules/entry-list/templates/EntryVideoItem.tsx b/apps/mobile/src/modules/entry-list/templates/EntryVideoItem.tsx index ecd524482..51541a60e 100644 --- a/apps/mobile/src/modules/entry-list/templates/EntryVideoItem.tsx +++ b/apps/mobile/src/modules/entry-list/templates/EntryVideoItem.tsx @@ -1,7 +1,7 @@ import { FeedViewType } from "@follow/constants" import { tracker } from "@follow/tracker" -import { transformVideoUrl } from "@follow/utils" -import { memo } from "react" +import { formatDuration, transformVideoUrl } from "@follow/utils" +import { memo, useMemo } from "react" import { Linking, Text, View } from "react-native" import { getGeneralSettings } from "@/src/atoms/settings/general" @@ -19,6 +19,16 @@ import { EntryGridFooter } from "../../entry-content/EntryGridFooter" export const EntryVideoItem = memo(({ id }: { id: string }) => { const item = useEntry(id) + const duration = useMemo(() => { + const seconds = item?.attachments?.find( + (attachment) => attachment.duration_in_seconds, + )?.duration_in_seconds + if (seconds) { + return formatDuration(Number.parseInt(seconds.toString())) + } + return 0 + }, [item?.attachments]) + if (!item) { return null } @@ -44,18 +54,25 @@ export const EntryVideoItem = memo(({ id }: { id: string }) => { openVideo(item.url) }} > - {imageUrl ? ( - - ) : ( - - )} + + {imageUrl ? ( + + ) : ( + + )} + {!!duration && ( + + {duration} + + )} + diff --git a/packages/internal/utils/exports.ts b/packages/internal/utils/exports.ts index 01c742ad0..e60320ce7 100644 --- a/packages/internal/utils/exports.ts +++ b/packages/internal/utils/exports.ts @@ -1,6 +1,7 @@ export * from "./src/cjk" export * from "./src/color" export * from "./src/dom" +export * from "./src/duration" export * from "./src/jotai" export * from "./src/path-parser" export * from "./src/url-for-video" diff --git a/packages/internal/utils/src/duration.ts b/packages/internal/utils/src/duration.ts new file mode 100644 index 000000000..ecdf53a16 --- /dev/null +++ b/packages/internal/utils/src/duration.ts @@ -0,0 +1,19 @@ +/** + * format seconds to "MM:SS" or "HH:MM:SS" + * @param {number} totalSeconds - 3661 + * @returns {string} - "01:01:01" + */ +export function formatDuration(totalSeconds: number) { + const hours = Math.floor(totalSeconds / 3600) + const minutes = Math.floor((totalSeconds % 3600) / 60) + const seconds = Math.floor(totalSeconds % 60) + + const mm = minutes.toString().padStart(2, "0") + const ss = seconds.toString().padStart(2, "0") + + if (hours === 0) { + return `${mm}:${ss}` // "MM:SS" + } + const hh = hours.toString().padStart(2, "0") + return `${hh}:${mm}:${ss}` // "HH:MM:SS" +} From 7702d8a4592ac0f80c19dc05034cecef86652c08 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Mon, 19 May 2025 11:14:36 +0800 Subject: [PATCH 04/76] feat(mobile): discoverLanguage ui setting --- apps/mobile/src/atoms/settings/ui.ts | 7 +- apps/mobile/src/modules/discover/Category.tsx | 77 ++++++++++++++++ .../src/modules/discover/DiscoverContent.tsx | 92 +------------------ .../src/modules/discover/Recommendations.tsx | 12 ++- apps/mobile/src/modules/discover/Trending.tsx | 86 ++++++++++------- 5 files changed, 149 insertions(+), 125 deletions(-) create mode 100644 apps/mobile/src/modules/discover/Category.tsx diff --git a/apps/mobile/src/atoms/settings/ui.ts b/apps/mobile/src/atoms/settings/ui.ts index ecd498739..d7b248eba 100644 --- a/apps/mobile/src/atoms/settings/ui.ts +++ b/apps/mobile/src/atoms/settings/ui.ts @@ -1,9 +1,14 @@ import { defaultUISettings } from "@follow/shared/src/settings/defaults" import type { UISettings } from "@follow/shared/src/settings/interface" +import { getDeviceLanguage } from "@/src/lib/i18n" + import { createSettingAtom } from "./internal/helper" -export const createDefaultSettings = (): UISettings => defaultUISettings +export const createDefaultSettings = (): UISettings => ({ + ...defaultUISettings, + discoverLanguage: getDeviceLanguage().startsWith("zh") ? "all" : "eng", +}) export const { useSettingKey: useUISettingKey, diff --git a/apps/mobile/src/modules/discover/Category.tsx b/apps/mobile/src/modules/discover/Category.tsx new file mode 100644 index 000000000..9c494d682 --- /dev/null +++ b/apps/mobile/src/modules/discover/Category.tsx @@ -0,0 +1,77 @@ +import type { RSSHubCategory } from "@follow/constants" +import { CategoryMap, RSSHubCategories } from "@follow/constants" +import { LinearGradient } from "expo-linear-gradient" +import { memo } from "react" +import { useTranslation } from "react-i18next" +import { Pressable, StyleSheet, Text, View } from "react-native" + +import { Grid } from "@/src/components/ui/grid" +import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable" +import { FilterCuteReIcon } from "@/src/icons/filter_cute_re" +import { Grid2CuteReIcon } from "@/src/icons/grid_2_cute_re" +import { useNavigation } from "@/src/lib/navigation/hooks" +import { Recommendations } from "@/src/modules/discover/Recommendations" +import { RecommendationCategoryScreen } from "@/src/screens/(stack)/recommendation/RecommendationCategoryScreen" + +export const Category = () => { + return ( + <> + + + + Categories + + + + + + + + {RSSHubCategories.map((category) => ( + + ))} + + + ) +} + +const CategoryItem = memo(({ category }: { category: RSSHubCategory }) => { + const { t } = useTranslation("common") + const name = t(`discover.category.${category}`) + const navigation = useNavigation() + + return ( + { + if (category === "all") { + navigation.pushControllerView(Recommendations) + } else { + navigation.pushControllerView(RecommendationCategoryScreen, { + category, + }) + } + }} + > + + + {CategoryMap[category].emoji} + {name} + + + + ) +}) + +const styles = StyleSheet.create({ + cardItem: { + aspectRatio: 16 / 9, + }, +}) diff --git a/apps/mobile/src/modules/discover/DiscoverContent.tsx b/apps/mobile/src/modules/discover/DiscoverContent.tsx index 8dfdd47fd..b0422979f 100644 --- a/apps/mobile/src/modules/discover/DiscoverContent.tsx +++ b/apps/mobile/src/modules/discover/DiscoverContent.tsx @@ -1,97 +1,13 @@ -import type { RSSHubCategory } from "@follow/constants" -import { CategoryMap, RSSHubCategories } from "@follow/constants" -import { LinearGradient } from "expo-linear-gradient" -import { memo } from "react" -import { useTranslation } from "react-i18next" -import { Pressable, StyleSheet, Text, View } from "react-native" +import { View } from "react-native" -import { Grid } from "@/src/components/ui/grid" -// import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable" -// import { FilterCuteReIcon } from "@/src/icons/filter_cute_re" -import { Grid2CuteReIcon } from "@/src/icons/grid_2_cute_re" -import { TrendingUpCuteReIcon } from "@/src/icons/trending_up_cute_re" -import { useNavigation } from "@/src/lib/navigation/hooks" -import { Recommendations } from "@/src/modules/discover/Recommendations" +import { Category } from "@/src/modules/discover/Category" import { Trending } from "@/src/modules/discover/Trending" -import { RecommendationCategoryScreen } from "@/src/screens/(stack)/recommendation/RecommendationCategoryScreen" export function DiscoverContent() { return ( - - - - Trending - - {/* - - */} - - - - - - - - Categories - - {/* - - */} - - - + + ) } - -const DiscoverGrid = () => { - return ( - - {RSSHubCategories.map((category) => ( - - ))} - - ) -} - -const CategoryItem = memo(({ category }: { category: RSSHubCategory }) => { - const { t } = useTranslation("common") - const name = t(`discover.category.${category}`) - const navigation = useNavigation() - - return ( - { - if (category === "all") { - navigation.pushControllerView(Recommendations) - } else { - navigation.pushControllerView(RecommendationCategoryScreen, { - category, - }) - } - }} - > - - - {CategoryMap[category].emoji} - {name} - - - - ) -}) - -const styles = StyleSheet.create({ - cardItem: { - aspectRatio: 16 / 9, - }, -}) diff --git a/apps/mobile/src/modules/discover/Recommendations.tsx b/apps/mobile/src/modules/discover/Recommendations.tsx index 8cd8b0566..42d95b3f8 100644 --- a/apps/mobile/src/modules/discover/Recommendations.tsx +++ b/apps/mobile/src/modules/discover/Recommendations.tsx @@ -22,6 +22,7 @@ import type { SharedValue } from "react-native-reanimated" import { useSharedValue } from "react-native-reanimated" import { useSafeAreaInsets } from "react-native-safe-area-context" +import { useUISettingKey } from "@/src/atoms/settings/ui" import { AnimatedScrollView } from "@/src/components/common/AnimatedComponents" import { BlurEffect } from "@/src/components/common/BlurEffect" import { UINavigationHeaderActionButton } from "@/src/components/layouts/header/NavigationHeader" @@ -117,6 +118,12 @@ export const Recommendations = () => { ) } +const LanguageMap = { + all: "all", + eng: "en", + cmn: "zh-CN", +} as const + export const RecommendationTab: TabComponent<{ contentContainerStyle?: ContentStyle insets?: { top?: number; bottom?: number } @@ -129,9 +136,12 @@ export const RecommendationTab: TabComponent<{ insets: customInsets, ...rest }) => { + const discoverLanguage = useUISettingKey("discoverLanguage") + const { data, isLoading } = useQuery({ queryKey: ["rsshub-popular", "cache", tab.value], - queryFn: () => fetchRsshubPopular(tab.value, "all").then((res) => res.data), + queryFn: () => + fetchRsshubPopular(tab.value, LanguageMap[discoverLanguage]).then((res) => res.data), }) const keys = useMemo(() => { if (!data) { diff --git a/apps/mobile/src/modules/discover/Trending.tsx b/apps/mobile/src/modules/discover/Trending.tsx index 27a449f53..2b04044c8 100644 --- a/apps/mobile/src/modules/discover/Trending.tsx +++ b/apps/mobile/src/modules/discover/Trending.tsx @@ -1,9 +1,13 @@ import { cn } from "@follow/utils" import { useQuery } from "@tanstack/react-query" -import { useTranslation } from "react-i18next" import { Text, View } from "react-native" +import { useUISettingKey } from "@/src/atoms/settings/ui" import { PlatformActivityIndicator } from "@/src/components/ui/loading/PlatformActivityIndicator" +import { ItemPressableStyle } from "@/src/components/ui/pressable/enum" +import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable" +import { FilterCuteReIcon } from "@/src/icons/filter_cute_re" +import { TrendingUpCuteReIcon } from "@/src/icons/trending_up_cute_re" import { fetchFeedTrending } from "./api" import { FeedSummary } from "./FeedSummary" @@ -15,51 +19,63 @@ export const Trending = ({ className?: string itemClassName?: string }) => { - const { i18n } = useTranslation() + const discoverLanguage = useUISettingKey("discoverLanguage") const { data, isLoading } = useQuery({ queryKey: ["trending", "feeds"], queryFn: () => fetchFeedTrending({ - lang: i18n.language.startsWith("zh") ? undefined : "eng", + lang: discoverLanguage === "all" ? undefined : discoverLanguage, limit: 20, }).then((res) => res.data), }) return ( - {isLoading ? ( - - + + + + Trending - ) : ( - data?.map((item, index) => ( - - - {index + 1} - - - } - /> - )) - )} + + + + + + + {isLoading ? ( + + + + ) : ( + data?.map((item, index) => ( + + + {index + 1} + + + } + /> + )) + )} + ) } From 0fc79c43a3c6dd0c3570f94af8dee73da9e686f6 Mon Sep 17 00:00:00 2001 From: Konv Suu <2583695112@qq.com> Date: Mon, 19 May 2025 15:50:39 +0800 Subject: [PATCH 05/76] fix(desktop): add overflow-scroll for content visibility (#3758) * fix(desktop): add overflow-scroll for content visibility * fix(discover): no scroll in transform form Signed-off-by: Innei --------- Signed-off-by: Innei Co-authored-by: Innei --- .../renderer/src/modules/discover/DiscoverFeedForm.tsx | 8 +++++++- .../renderer/src/modules/discover/DiscoverTransform.tsx | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/desktop/layer/renderer/src/modules/discover/DiscoverFeedForm.tsx b/apps/desktop/layer/renderer/src/modules/discover/DiscoverFeedForm.tsx index f3a3d4545..b3e2c2fac 100644 --- a/apps/desktop/layer/renderer/src/modules/discover/DiscoverFeedForm.tsx +++ b/apps/desktop/layer/renderer/src/modules/discover/DiscoverFeedForm.tsx @@ -90,12 +90,14 @@ export const DiscoverFeedForm = ({ noDescription, routeParams, viewportClassName, + rootClassName, }: { route: RSSHubRoute routePrefix: string noDescription?: boolean routeParams?: RouteParams viewportClassName?: string + rootClassName?: string }) => { const { t } = useTranslation() const keys = useMemo( @@ -227,7 +229,11 @@ export const DiscoverFeedForm = ({
diff --git a/apps/desktop/layer/renderer/src/modules/discover/DiscoverTransform.tsx b/apps/desktop/layer/renderer/src/modules/discover/DiscoverTransform.tsx index a65c15883..c75382760 100644 --- a/apps/desktop/layer/renderer/src/modules/discover/DiscoverTransform.tsx +++ b/apps/desktop/layer/renderer/src/modules/discover/DiscoverTransform.tsx @@ -70,6 +70,7 @@ export function DiscoverTransform() { {data?.rsshub!.routes && (
Date: Mon, 19 May 2025 17:07:03 +0800 Subject: [PATCH 06/76] feat(mobile): discover language settings --- apps/mobile/src/modules/discover/Category.tsx | 10 ++++- apps/mobile/src/modules/discover/Trending.tsx | 13 +++++- .../(modal)/DiscoverSettingsScreen.tsx | 45 +++++++++++++++++++ locales/settings/en.json | 3 ++ 4 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 apps/mobile/src/screens/(modal)/DiscoverSettingsScreen.tsx diff --git a/apps/mobile/src/modules/discover/Category.tsx b/apps/mobile/src/modules/discover/Category.tsx index 9c494d682..147e9096a 100644 --- a/apps/mobile/src/modules/discover/Category.tsx +++ b/apps/mobile/src/modules/discover/Category.tsx @@ -11,9 +11,12 @@ import { FilterCuteReIcon } from "@/src/icons/filter_cute_re" import { Grid2CuteReIcon } from "@/src/icons/grid_2_cute_re" import { useNavigation } from "@/src/lib/navigation/hooks" import { Recommendations } from "@/src/modules/discover/Recommendations" +import { DiscoverSettingsScreen } from "@/src/screens/(modal)/DiscoverSettingsScreen" import { RecommendationCategoryScreen } from "@/src/screens/(stack)/recommendation/RecommendationCategoryScreen" export const Category = () => { + const navigation = useNavigation() + return ( <> @@ -21,7 +24,12 @@ export const Category = () => { Categories - + { + navigation.presentControllerView(DiscoverSettingsScreen) + }} + > diff --git a/apps/mobile/src/modules/discover/Trending.tsx b/apps/mobile/src/modules/discover/Trending.tsx index 2b04044c8..c363c4c00 100644 --- a/apps/mobile/src/modules/discover/Trending.tsx +++ b/apps/mobile/src/modules/discover/Trending.tsx @@ -8,6 +8,8 @@ import { ItemPressableStyle } from "@/src/components/ui/pressable/enum" import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable" import { FilterCuteReIcon } from "@/src/icons/filter_cute_re" import { TrendingUpCuteReIcon } from "@/src/icons/trending_up_cute_re" +import { useNavigation } from "@/src/lib/navigation/hooks" +import { DiscoverSettingsScreen } from "@/src/screens/(modal)/DiscoverSettingsScreen" import { fetchFeedTrending } from "./api" import { FeedSummary } from "./FeedSummary" @@ -21,13 +23,14 @@ export const Trending = ({ }) => { const discoverLanguage = useUISettingKey("discoverLanguage") const { data, isLoading } = useQuery({ - queryKey: ["trending", "feeds"], + queryKey: ["trending", "feeds", discoverLanguage], queryFn: () => fetchFeedTrending({ lang: discoverLanguage === "all" ? undefined : discoverLanguage, limit: 20, }).then((res) => res.data), }) + const navigation = useNavigation() return ( @@ -36,7 +39,13 @@ export const Trending = ({ Trending - + { + navigation.presentControllerView(DiscoverSettingsScreen) + }} + > diff --git a/apps/mobile/src/screens/(modal)/DiscoverSettingsScreen.tsx b/apps/mobile/src/screens/(modal)/DiscoverSettingsScreen.tsx new file mode 100644 index 000000000..b23677efd --- /dev/null +++ b/apps/mobile/src/screens/(modal)/DiscoverSettingsScreen.tsx @@ -0,0 +1,45 @@ +import { useTranslation } from "react-i18next" +import { View } from "react-native" + +import { setUISetting, useUISettingKey } from "@/src/atoms/settings/ui" +import { + NavigationBlurEffectHeaderView, + SafeNavigationScrollView, +} from "@/src/components/layouts/views/SafeNavigationScrollView" +import { Select } from "@/src/components/ui/form/Select" +import { + GroupedInsetListCard, + GroupedInsetListCell, + GroupedInsetListSectionHeader, +} from "@/src/components/ui/grouped/GroupedList" + +export const DiscoverSettingsScreen = () => { + const { t } = useTranslation("settings") + const discoverLanguage = useUISettingKey("discoverLanguage") + + return ( + } + > + + + + +