32 lines
1011 B
TypeScript
32 lines
1011 B
TypeScript
|
|
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>
|
|||
|
|
);
|
|||
|
|
}
|