import { useTranslation } from 'react-i18next' import { ShieldAlert, ExternalLink } from 'lucide-react' import { Button } from '@/components/ui/button' const LICENSE_KEY = 'mediacrawler_license_accepted' // 检查是否已经接受协议 export function isLicenseAccepted(): boolean { return localStorage.getItem(LICENSE_KEY) === 'true' } // 清除协议接受状态 export function clearLicenseAccepted(): void { localStorage.removeItem(LICENSE_KEY) } interface LicenseDisclaimerProps { onAccept: () => void } export function LicenseDisclaimer({ onAccept }: LicenseDisclaimerProps) { const { t } = useTranslation('license') const handleConfirm = () => { localStorage.setItem(LICENSE_KEY, 'true') onAccept() } const handleDecline = () => { // 尝试关闭当前标签页(不会关闭整个浏览器,只关闭当前tab) try { // 方式1: 直接关闭当前标签页 window.close() // 方式2: 将当前标签页导航到空白页 setTimeout(() => { window.location.href = 'about:blank' }, 100) } catch { // 忽略错误 } // 如果无法关闭(浏览器安全限制),显示拒绝访问页面 setTimeout(() => { document.body.innerHTML = `