translate comment of frontend/components/web

This commit is contained in:
david_bai
2025-06-22 08:25:03 +08:00
parent 9eec4f14c2
commit 6bbc42f6ac
7 changed files with 47 additions and 47 deletions
@@ -1,4 +1,4 @@
//弹窗会在满足条件时自动弹出,并确保只弹出一次
// The pop-up dialog will appear automatically when conditions are met, and ensures it only appears once.
'use client';
import { useEffect, useState } from 'react';
@@ -11,13 +11,13 @@ import {
} from '@/components/ui/dialog';
interface AutoPopupDialogProps {
// 用于localStorage的唯一标识
// Unique identifier for localStorage
storageKey: string;
// 弹窗标题
// Dialog title
title: string;
// 弹窗描述内容
// Dialog description content
description: string;
// 触发弹窗的条件函数
// Condition function to trigger the dialog
condition?: () => boolean;
}
@@ -30,12 +30,12 @@ export function AutoPopupDialog({
const [open, setOpen] = useState(false);
useEffect(() => {
// 检查是否已经显示过
const hasShown = localStorage.getItem(storageKey);//localStorage 是一种 Web Storage 技术,允许浏览器在客户端本地存储数据。它可以存储键值对(key-value),并且这些数据在页面刷新、浏览器重启后仍然存在,直到手动删除或通过代码清除。
// Check if it has been shown before using localStorage
const hasShown = localStorage.getItem(storageKey);
if (!hasShown && condition()) {
setOpen(true);
// 标记为已显示
// Mark as shown
localStorage.setItem(storageKey, 'true');
}
}, [storageKey, condition]);