|
|
@@ -1,21 +1,34 @@
|
|
|
import styles from "./auth.module.scss";
|
|
|
import { IconButton } from "./button";
|
|
|
-
|
|
|
+import { useState, useEffect } from "react";
|
|
|
import { useNavigate } from "react-router-dom";
|
|
|
-import { Path } from "../constant";
|
|
|
+import { Path, SAAS_CHAT_URL } from "../constant";
|
|
|
import { useAccessStore } from "../store";
|
|
|
import Locale from "../locales";
|
|
|
-
|
|
|
+import Delete from "../icons/close.svg";
|
|
|
+import Arrow from "../icons/arrow.svg";
|
|
|
+import Logo from "../icons/logo.svg";
|
|
|
+import { useMobileScreen } from "@/app/utils";
|
|
|
import BotIcon from "../icons/bot.svg";
|
|
|
-import { useEffect } from "react";
|
|
|
import { getClientConfig } from "../config/client";
|
|
|
+import LeftIcon from "@/app/icons/left.svg";
|
|
|
+import { safeLocalStorage } from "@/app/utils";
|
|
|
+import {
|
|
|
+ trackSettingsPageGuideToCPaymentClick,
|
|
|
+ trackAuthorizationPageButtonToCPaymentClick,
|
|
|
+} from "../utils/auth-settings-events";
|
|
|
+const storage = safeLocalStorage();
|
|
|
|
|
|
export function AuthPage() {
|
|
|
const navigate = useNavigate();
|
|
|
const accessStore = useAccessStore();
|
|
|
-
|
|
|
const goHome = () => navigate(Path.Home);
|
|
|
const goChat = () => navigate(Path.Chat);
|
|
|
+ const goSaas = () => {
|
|
|
+ trackAuthorizationPageButtonToCPaymentClick();
|
|
|
+ window.location.href = SAAS_CHAT_URL;
|
|
|
+ };
|
|
|
+
|
|
|
const resetAccessCode = () => {
|
|
|
accessStore.update((access) => {
|
|
|
access.openaiApiKey = "";
|
|
|
@@ -32,6 +45,14 @@ export function AuthPage() {
|
|
|
|
|
|
return (
|
|
|
<div className={styles["auth-page"]}>
|
|
|
+ <TopBanner></TopBanner>
|
|
|
+ <div className={styles["auth-header"]}>
|
|
|
+ <IconButton
|
|
|
+ icon={<LeftIcon />}
|
|
|
+ text={Locale.Auth.Return}
|
|
|
+ onClick={() => navigate(Path.Home)}
|
|
|
+ ></IconButton>
|
|
|
+ </div>
|
|
|
<div className={`no-dark ${styles["auth-logo"]}`}>
|
|
|
<BotIcon />
|
|
|
</div>
|
|
|
@@ -65,7 +86,7 @@ export function AuthPage() {
|
|
|
}}
|
|
|
/>
|
|
|
<input
|
|
|
- className={styles["auth-input"]}
|
|
|
+ className={styles["auth-input-second"]}
|
|
|
type="password"
|
|
|
placeholder={Locale.Settings.Access.Google.ApiKey.Placeholder}
|
|
|
value={accessStore.googleApiKey}
|
|
|
@@ -85,13 +106,74 @@ export function AuthPage() {
|
|
|
onClick={goChat}
|
|
|
/>
|
|
|
<IconButton
|
|
|
- text={Locale.Auth.Later}
|
|
|
+ text={Locale.Auth.SaasTips}
|
|
|
onClick={() => {
|
|
|
- resetAccessCode();
|
|
|
- goHome();
|
|
|
+ goSaas();
|
|
|
}}
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
);
|
|
|
}
|
|
|
+
|
|
|
+function TopBanner() {
|
|
|
+ const [isHovered, setIsHovered] = useState(false);
|
|
|
+ const [isVisible, setIsVisible] = useState(true);
|
|
|
+ const isMobile = useMobileScreen();
|
|
|
+ useEffect(() => {
|
|
|
+ // 检查 localStorage 中是否有标记
|
|
|
+ const bannerDismissed = storage.getItem("bannerDismissed");
|
|
|
+ // 如果标记不存在,存储默认值并显示横幅
|
|
|
+ if (!bannerDismissed) {
|
|
|
+ storage.setItem("bannerDismissed", "false");
|
|
|
+ setIsVisible(true); // 显示横幅
|
|
|
+ } else if (bannerDismissed === "true") {
|
|
|
+ // 如果标记为 "true",则隐藏横幅
|
|
|
+ setIsVisible(false);
|
|
|
+ }
|
|
|
+ }, []);
|
|
|
+
|
|
|
+ const handleMouseEnter = () => {
|
|
|
+ setIsHovered(true);
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleMouseLeave = () => {
|
|
|
+ setIsHovered(false);
|
|
|
+ };
|
|
|
+
|
|
|
+ const handleClose = () => {
|
|
|
+ setIsVisible(false);
|
|
|
+ storage.setItem("bannerDismissed", "true");
|
|
|
+ };
|
|
|
+
|
|
|
+ if (!isVisible) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ <div
|
|
|
+ className={styles["top-banner"]}
|
|
|
+ onMouseEnter={handleMouseEnter}
|
|
|
+ onMouseLeave={handleMouseLeave}
|
|
|
+ >
|
|
|
+ <div className={`${styles["top-banner-inner"]} no-dark`}>
|
|
|
+ <Logo className={styles["top-banner-logo"]}></Logo>
|
|
|
+ <span>
|
|
|
+ {Locale.Auth.TopTips}
|
|
|
+ <a
|
|
|
+ href={SAAS_CHAT_URL}
|
|
|
+ rel="stylesheet"
|
|
|
+ onClick={() => {
|
|
|
+ trackSettingsPageGuideToCPaymentClick();
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {Locale.Settings.Access.SaasStart.ChatNow}
|
|
|
+ <Arrow style={{ marginLeft: "4px" }} />
|
|
|
+ </a>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ {(isHovered || isMobile) && (
|
|
|
+ <Delete className={styles["top-banner-close"]} onClick={handleClose} />
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
+ );
|
|
|
+}
|