Files
omniai-web/src/components/CookieConsentBanner.tsx
T
stringadmin 0fc180637c feat: 电商页面 KeepAlive 保活机制,切换页面不再丢失生成状态
通过 display:none 模式实现轻量 KeepAlive,电商页面首次访问后保持挂载,
切换到其他页面再切回时所有右侧面板状态(上传图片、生成进度、结果)完整保留。
同时清理项目中的临时文件和本地冗余图片。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-03 23:20:57 +08:00

32 lines
1011 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { useEffect, useState } from "react";
const COOKIE_CONSENT_KEY = "omniai:cookie-consent:v1";
export default function CookieConsentBanner() {
const [visible, setVisible] = useState(false);
useEffect(() => {
setVisible(localStorage.getItem(COOKIE_CONSENT_KEY) !== "accepted");
}, []);
const accept = () => {
localStorage.setItem(COOKIE_CONSENT_KEY, "accepted");
setVisible(false);
};
if (!visible) return null;
return (
<section className="cookie-consent" role="dialog" aria-live="polite" aria-label="Cookie 使用提示">
<div>
<strong>Cookie </strong>
<p>使 Cookie 稿</p>
</div>
<div className="cookie-consent__actions">
<a href="#/privacyPolicy"></a>
<button type="button" onClick={accept}></button>
</div>
</section>
);
}