Skip to content

Commit

Permalink
add top tip
Browse files Browse the repository at this point in the history
  • Loading branch information
mayfwl committed Sep 19, 2024
1 parent 62efab9 commit 9858d1f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 24 deletions.
12 changes: 7 additions & 5 deletions app/components/auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { useNavigate } from "react-router-dom";
import { Path, SAAS_CHAT_URL } from "../constant";
import { useAccessStore } from "../store";
import Locale from "../locales";
import Delete from "../icons/www-delete.svg";
import Delete from "../icons/close.svg";
import Arrow from "../icons/arrow.svg";
import Logo from "../icons/logo.svg";
import BotIcon from "../icons/bot.svg";
import { getClientConfig } from "../config/client";
import LeftIcon from "@/app/icons/left.svg";
import { safeLocalStorage } from "@/app/utils";

export function AuthPage() {
const navigate = useNavigate();
Expand Down Expand Up @@ -112,20 +113,21 @@ export function AuthPage() {
function TopBanner() {
const [isHovered, setIsHovered] = useState(false);
const [isVisible, setIsVisible] = useState(true);
const storage = safeLocalStorage();

useEffect(() => {
// 检查 localStorage 中是否有标记
const bannerDismissed = localStorage.getItem("bannerDismissed");
const bannerDismissed = storage.getItem("bannerDismissed");

// 如果标记不存在,存储默认值并显示横幅
if (!bannerDismissed) {
localStorage.setItem("bannerDismissed", "false");
storage.setItem("bannerDismissed", "false");
setIsVisible(true); // 显示横幅
} else if (bannerDismissed === "true") {
// 如果标记为 "true",则隐藏横幅
setIsVisible(false);
}
}, []);
}, [storage]);

const handleMouseEnter = () => {
setIsHovered(true);
Expand All @@ -137,7 +139,7 @@ function TopBanner() {

const handleClose = () => {
setIsVisible(false);
localStorage.setItem("bannerDismissed", "true");
storage.setItem("bannerDismissed", "true");
};

if (!isVisible) {
Expand Down
36 changes: 18 additions & 18 deletions app/icons/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion app/icons/www-delete.svg

This file was deleted.

0 comments on commit 9858d1f

Please sign in to comment.