11import styles from "./auth.module.scss" ;
22import { IconButton } from "./button" ;
3-
3+ import { useState , useEffect } from "react" ;
44import { useNavigate } from "react-router-dom" ;
5- import { Path } from "../constant" ;
5+ import { Path , SAAS_CHAT_URL } from "../constant" ;
66import { useAccessStore } from "../store" ;
77import Locale from "../locales" ;
8-
8+ import Delete from "../icons/close.svg" ;
9+ import Arrow from "../icons/arrow.svg" ;
10+ import Logo from "../icons/logo.svg" ;
11+ import { useMobileScreen } from "@/app/utils" ;
912import BotIcon from "../icons/bot.svg" ;
10- import { useEffect } from "react" ;
1113import { getClientConfig } from "../config/client" ;
14+ import LeftIcon from "@/app/icons/left.svg" ;
15+ import { safeLocalStorage } from "@/app/utils" ;
16+ import {
17+ trackSettingsPageGuideToCPaymentClick ,
18+ trackAuthorizationPageButtonToCPaymentClick ,
19+ } from "../utils/auth-settings-events" ;
20+ const storage = safeLocalStorage ( ) ;
1221
1322export function AuthPage ( ) {
1423 const navigate = useNavigate ( ) ;
1524 const accessStore = useAccessStore ( ) ;
16-
1725 const goHome = ( ) => navigate ( Path . Home ) ;
1826 const goChat = ( ) => navigate ( Path . Chat ) ;
27+ const goSaas = ( ) => {
28+ trackAuthorizationPageButtonToCPaymentClick ( ) ;
29+ window . location . href = SAAS_CHAT_URL ;
30+ } ;
31+
1932 const resetAccessCode = ( ) => {
2033 accessStore . update ( ( access ) => {
2134 access . openaiApiKey = "" ;
@@ -32,6 +45,14 @@ export function AuthPage() {
3245
3346 return (
3447 < div className = { styles [ "auth-page" ] } >
48+ < TopBanner > </ TopBanner >
49+ < div className = { styles [ "auth-header" ] } >
50+ < IconButton
51+ icon = { < LeftIcon /> }
52+ text = { Locale . Auth . Return }
53+ onClick = { ( ) => navigate ( Path . Home ) }
54+ > </ IconButton >
55+ </ div >
3556 < div className = { `no-dark ${ styles [ "auth-logo" ] } ` } >
3657 < BotIcon />
3758 </ div >
@@ -65,7 +86,7 @@ export function AuthPage() {
6586 } }
6687 />
6788 < input
68- className = { styles [ "auth-input" ] }
89+ className = { styles [ "auth-input-second " ] }
6990 type = "password"
7091 placeholder = { Locale . Settings . Access . Google . ApiKey . Placeholder }
7192 value = { accessStore . googleApiKey }
@@ -85,13 +106,74 @@ export function AuthPage() {
85106 onClick = { goChat }
86107 />
87108 < IconButton
88- text = { Locale . Auth . Later }
109+ text = { Locale . Auth . SaasTips }
89110 onClick = { ( ) => {
90- resetAccessCode ( ) ;
91- goHome ( ) ;
111+ goSaas ( ) ;
92112 } }
93113 />
94114 </ div >
95115 </ div >
96116 ) ;
97117}
118+
119+ function TopBanner ( ) {
120+ const [ isHovered , setIsHovered ] = useState ( false ) ;
121+ const [ isVisible , setIsVisible ] = useState ( true ) ;
122+ const isMobile = useMobileScreen ( ) ;
123+ useEffect ( ( ) => {
124+ // 检查 localStorage 中是否有标记
125+ const bannerDismissed = storage . getItem ( "bannerDismissed" ) ;
126+ // 如果标记不存在,存储默认值并显示横幅
127+ if ( ! bannerDismissed ) {
128+ storage . setItem ( "bannerDismissed" , "false" ) ;
129+ setIsVisible ( true ) ; // 显示横幅
130+ } else if ( bannerDismissed === "true" ) {
131+ // 如果标记为 "true",则隐藏横幅
132+ setIsVisible ( false ) ;
133+ }
134+ } , [ ] ) ;
135+
136+ const handleMouseEnter = ( ) => {
137+ setIsHovered ( true ) ;
138+ } ;
139+
140+ const handleMouseLeave = ( ) => {
141+ setIsHovered ( false ) ;
142+ } ;
143+
144+ const handleClose = ( ) => {
145+ setIsVisible ( false ) ;
146+ storage . setItem ( "bannerDismissed" , "true" ) ;
147+ } ;
148+
149+ if ( ! isVisible ) {
150+ return null ;
151+ }
152+ return (
153+ < div
154+ className = { styles [ "top-banner" ] }
155+ onMouseEnter = { handleMouseEnter }
156+ onMouseLeave = { handleMouseLeave }
157+ >
158+ < div className = { `${ styles [ "top-banner-inner" ] } no-dark` } >
159+ < Logo className = { styles [ "top-banner-logo" ] } > </ Logo >
160+ < span >
161+ { Locale . Auth . TopTips }
162+ < a
163+ href = { SAAS_CHAT_URL }
164+ rel = "stylesheet"
165+ onClick = { ( ) => {
166+ trackSettingsPageGuideToCPaymentClick ( ) ;
167+ } }
168+ >
169+ { Locale . Settings . Access . SaasStart . ChatNow }
170+ < Arrow style = { { marginLeft : "4px" } } />
171+ </ a >
172+ </ span >
173+ </ div >
174+ { ( isHovered || isMobile ) && (
175+ < Delete className = { styles [ "top-banner-close" ] } onClick = { handleClose } />
176+ ) }
177+ </ div >
178+ ) ;
179+ }
0 commit comments