fix(seo): 修复页面标题公司名重复与品牌名繁简体不一致问题
- 新增 COMPANY_INFO.displayName 属性用于页面标题和SEO元数据 - 统一所有页面 metadata 使用 displayName(简体"睿新致远") - 视觉展示元素保留 shortName(繁体"睿新致遠"配合青柳隷書字体) - 修复关于/联系/团队页面标题中公司名重复出现的问题 - 修复新闻ID从数字改为SEO友好slug - 更新结构化数据使用完整公司名 - 修复ESLint报错:引号转义、组件displayName、any类型替换
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect, useCallback } from 'react';
|
||||
import { useState, useEffect, useCallback, useRef } from 'react';
|
||||
import {
|
||||
updateConsentDetailed,
|
||||
trackButtonClick,
|
||||
@@ -13,19 +13,37 @@ import { motion, AnimatePresence } from 'framer-motion';
|
||||
|
||||
const LEGACY_CONSENT_KEY = 'ga_consent';
|
||||
|
||||
let hasConsentBeenHandled = false;
|
||||
|
||||
function getInitialShowConsent(): boolean {
|
||||
if (typeof window === 'undefined') {return false;}
|
||||
if (hasConsentBeenHandled) {return false;}
|
||||
const stored = getStoredPreferences();
|
||||
if (stored) {return false;}
|
||||
const legacyConsent = localStorage.getItem(LEGACY_CONSENT_KEY);
|
||||
if (legacyConsent) {return false;}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function CookieConsent() {
|
||||
const [showConsent, setShowConsent] = useState(false);
|
||||
const [showConsent, setShowConsent] = useState(getInitialShowConsent);
|
||||
const [showSettings, setShowSettings] = useState(false);
|
||||
const [isAnimating, setIsAnimating] = useState(false);
|
||||
const [preferences, setPreferences] = useState<CookiePreferences>(getDefaultPreferences());
|
||||
const consentCheckedRef = useRef(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (consentCheckedRef.current) {return;}
|
||||
consentCheckedRef.current = true;
|
||||
|
||||
const stored = getStoredPreferences();
|
||||
if (stored) {
|
||||
hasConsentBeenHandled = true;
|
||||
updateConsentDetailed(stored);
|
||||
} else {
|
||||
const legacyConsent = localStorage.getItem(LEGACY_CONSENT_KEY);
|
||||
if (legacyConsent) {
|
||||
hasConsentBeenHandled = true;
|
||||
const migratedPrefs: CookiePreferences = {
|
||||
necessary: true,
|
||||
analytics: legacyConsent === 'granted',
|
||||
@@ -45,8 +63,18 @@ export function CookieConsent() {
|
||||
return undefined;
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const handleOpenSettings = () => {
|
||||
setShowSettings(true);
|
||||
setShowConsent(true);
|
||||
};
|
||||
window.addEventListener('open-cookie-settings', handleOpenSettings);
|
||||
return () => window.removeEventListener('open-cookie-settings', handleOpenSettings);
|
||||
}, []);
|
||||
|
||||
const handleSavePreferences = useCallback((prefs: CookiePreferences) => {
|
||||
setIsAnimating(true);
|
||||
hasConsentBeenHandled = true;
|
||||
const finalPrefs = { ...prefs, timestamp: Date.now() };
|
||||
storePreferences(finalPrefs);
|
||||
updateConsentDetailed(finalPrefs);
|
||||
|
||||
Reference in New Issue
Block a user