From a5439d861b1339f9fa5c4ac36e45affdfb3c97ba Mon Sep 17 00:00:00 2001 From: Innei Date: Mon, 7 Jul 2025 19:56:45 +0800 Subject: [PATCH] feat(download): enhance mobile download experience with platform detection and redirection Signed-off-by: Innei --- .../renderer/src/modules/download/index.tsx | 40 +++++++++++++++++-- packages/internal/constants/src/app.ts | 6 +++ packages/internal/utils/src/utils.ts | 12 ++++++ 3 files changed, 54 insertions(+), 4 deletions(-) diff --git a/apps/desktop/layer/renderer/src/modules/download/index.tsx b/apps/desktop/layer/renderer/src/modules/download/index.tsx index b6328a85b..c072fd59c 100644 --- a/apps/desktop/layer/renderer/src/modules/download/index.tsx +++ b/apps/desktop/layer/renderer/src/modules/download/index.tsx @@ -1,12 +1,32 @@ import { Folo } from "@follow/components/icons/folo.jsx" import { Logo } from "@follow/components/icons/logo.jsx" import { Button } from "@follow/components/ui/button/index.js" +import { APP_STORE_URLS } from "@follow/constants" +import { getMobilePlatform, isMobileDevice } from "@follow/utils" +import { useEffect } from "react" export function DownloadPage() { const openDownloadPage = () => { window.open("https://folo.is/download", "_blank", "noopener,noreferrer") } + const mobilePlatform = getMobilePlatform() + const isMobile = isMobileDevice() + + useEffect(() => { + if (isMobile && mobilePlatform && APP_STORE_URLS[mobilePlatform]) { + window.location.href = APP_STORE_URLS[mobilePlatform] + } + }, [isMobile, mobilePlatform]) + + const handleMobileDownload = () => { + if (mobilePlatform && APP_STORE_URLS[mobilePlatform]) { + window.location.href = APP_STORE_URLS[mobilePlatform] + } else { + openDownloadPage() + } + } + return (
{/* Logo Section */} @@ -22,18 +42,30 @@ export function DownloadPage() {

Download Folo

-

Get the mobile app for the best experience

+

+ {isMobile + ? mobilePlatform + ? `Get the ${mobilePlatform} app for the best experience` + : "Get the mobile app for the best experience" + : "Get the mobile app for the best experience"} +

{/* Download Button */} - {/* Hint */}

- Available for iOS, Android, Windows, macOS & Linux + {isMobile + ? mobilePlatform + ? `Redirecting to ${mobilePlatform === "iOS" ? "App Store" : "Google Play"}...` + : "Available for iOS, Android, Windows, macOS & Linux" + : "Available for iOS, Android, Windows, macOS & Linux"}

diff --git a/packages/internal/constants/src/app.ts b/packages/internal/constants/src/app.ts index 7d1e37ead..f049921e9 100644 --- a/packages/internal/constants/src/app.ts +++ b/packages/internal/constants/src/app.ts @@ -1 +1,7 @@ export const APPLE_APP_STORE_ID = "6739802604" +export const GOOGLE_PLAY_PACKAGE_ID = "is.follow" + +export const APP_STORE_URLS = { + iOS: `https://apps.apple.com/us/app/folo-follow-everything/id${APPLE_APP_STORE_ID}`, + Android: `https://play.google.com/store/apps/details?id=${GOOGLE_PLAY_PACKAGE_ID}`, +} as const diff --git a/packages/internal/utils/src/utils.ts b/packages/internal/utils/src/utils.ts index 49901ac07..6a396f2df 100644 --- a/packages/internal/utils/src/utils.ts +++ b/packages/internal/utils/src/utils.ts @@ -476,3 +476,15 @@ export function formatNumber(num: number): string { return `${isNegative ? "-" : ""}${absNum}` } + +export type MobilePlatform = "iOS" | "Android" | null + +export const getMobilePlatform = once((): MobilePlatform => { + const os = getOS() + + return ["iOS", "Android"].includes(os) ? (os as MobilePlatform) : null +}) + +export const isMobileDevice = once((): boolean => { + return getMobilePlatform() !== null +})