From 7e9d7a4b5959cad5a2538ce5c784ddf698fc4b10 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Mon, 25 May 2026 01:33:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=90=BD=E5=9C=B0=E9=A1=B5=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E6=80=81=E6=84=9F=E7=9F=A5=EF=BC=9A=E5=B7=B2=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E9=9A=90=E8=97=8F=E7=99=BB=E5=BD=95/?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit InstitutionalLandingPage 挂载时检测 Supabase session, 用户已登录则仅显示"进入产品"直达 /terminal,未登录则保留完整按钮组。 Tested: npm run build 通过 --- .../landing/InstitutionalLandingPage.tsx | 69 ++++++++++++++----- 1 file changed, 50 insertions(+), 19 deletions(-) diff --git a/frontend/components/landing/InstitutionalLandingPage.tsx b/frontend/components/landing/InstitutionalLandingPage.tsx index 0ea546e7..8696a498 100644 --- a/frontend/components/landing/InstitutionalLandingPage.tsx +++ b/frontend/components/landing/InstitutionalLandingPage.tsx @@ -1,5 +1,6 @@ "use client"; +import { useEffect, useState } from "react"; import Link from "next/link"; import { Activity, @@ -16,6 +17,10 @@ import { TrendingUp, } from "lucide-react"; import { I18nProvider, useI18n } from "@/hooks/useI18n"; +import { + getSupabaseBrowserClient, + hasSupabasePublicEnv, +} from "@/lib/supabase/client"; const RAW_MARKET_ROWS_EN = [ ["New York", "91.8°F", "+2.4", "High", "Long Yes"], @@ -74,6 +79,20 @@ const PRO_FEATURES_ZH = [ function InstitutionalLandingScreen() { const { locale, toggleLocale } = useI18n(); const isEn = locale === "en-US"; + const [isAuthenticated, setIsAuthenticated] = useState(false); + const [authChecked, setAuthChecked] = useState(false); + + useEffect(() => { + if (!hasSupabasePublicEnv()) { + setAuthChecked(true); + return; + } + const supabase = getSupabaseBrowserClient(); + supabase.auth.getSession().then(({ data: { session } }) => { + setIsAuthenticated(!!session?.user); + setAuthChecked(true); + }); + }, []); const marketRows = isEn ? RAW_MARKET_ROWS_EN : RAW_MARKET_ROWS_ZH; const coverage = isEn ? COVERAGE_EN : COVERAGE_ZH; @@ -144,25 +163,37 @@ function InstitutionalLandingScreen() { 中文 EN - - {isEn ? "Log in" : "登录"} - - - {isEn ? "Sign Up" : "注册"} - - - {isEn ? "Enter Product" : "进入产品"} - - + {authChecked && isAuthenticated ? ( + + {isEn ? "Enter Product" : "进入产品"} + + + ) : ( + <> + + {isEn ? "Log in" : "登录"} + + + {isEn ? "Sign Up" : "注册"} + + + {isEn ? "Enter Product" : "进入产品"} + + + + )}