Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add fanyi add top tip #5470

Merged
merged 13 commits into from
Sep 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions app/components/auth.tsx
Original file line number Diff line number Diff line change
@@ -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();
@@ -112,20 +113,21 @@ export function AuthPage() {
function TopBanner() {
const [isHovered, setIsHovered] = useState(false);
const [isVisible, setIsVisible] = useState(true);
const storage = safeLocalStorage();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

放外面


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]);
Copy link
Member

@Dogtiti Dogtiti Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不需要作为组件内部的依赖项初始化storage,只需要初始化一次 不需要每次render都要初始化


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

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

if (!isVisible) {
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename?

This file was deleted.