|
@@ -28,6 +28,7 @@ import { Header } from "@/components/layout/Header";
|
|
|
import { Footer } from "@/components/layout/Footer";
|
|
import { Footer } from "@/components/layout/Footer";
|
|
|
import { FadeIn, FadeInStagger, FadeInItem } from "@/components/ui/fade-in";
|
|
import { FadeIn, FadeInStagger, FadeInItem } from "@/components/ui/fade-in";
|
|
|
import { websiteConfig } from "@/lib/website-config";
|
|
import { websiteConfig } from "@/lib/website-config";
|
|
|
|
|
+import { getOrCreateVisitorId } from "@/lib/visitor-id";
|
|
|
import { stats } from "@/lib/stats-config";
|
|
import { stats } from "@/lib/stats-config";
|
|
|
import type { I18nKey } from "@/lib/i18n/dict";
|
|
import type { I18nKey } from "@/lib/i18n/dict";
|
|
|
import { useI18n } from "@/lib/i18n/provider";
|
|
import { useI18n } from "@/lib/i18n/provider";
|
|
@@ -149,15 +150,20 @@ export function HomePageClient() {
|
|
|
const [activeScreenshot, setActiveScreenshot] = useState(0);
|
|
const [activeScreenshot, setActiveScreenshot] = useState(0);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- let stored = window.localStorage.getItem("visitor_id");
|
|
|
|
|
- if (!stored) {
|
|
|
|
|
- stored = `${Date.now()}${Math.floor(Math.random() * 100000)}`;
|
|
|
|
|
- window.localStorage.setItem("visitor_id", stored);
|
|
|
|
|
- }
|
|
|
|
|
- const parsed = Number.parseInt(stored, 10);
|
|
|
|
|
- setVisitorId(Number.isNaN(parsed) ? null : parsed);
|
|
|
|
|
|
|
+ setVisitorId(getOrCreateVisitorId());
|
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ const params = new URLSearchParams(window.location.search);
|
|
|
|
|
+ if (params.get("openChat") === "1") {
|
|
|
|
|
+ handleOpenChat();
|
|
|
|
|
+ params.delete("openChat");
|
|
|
|
|
+ const next = `${window.location.pathname}${params.toString() ? `?${params}` : ""}`;
|
|
|
|
|
+ window.history.replaceState(null, "", next);
|
|
|
|
|
+ }
|
|
|
|
|
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- 仅响应 URL 参数
|
|
|
|
|
+ }, [visitorId]);
|
|
|
|
|
+
|
|
|
const handleToggleChat = () => setIsChatOpen((prev) => !prev);
|
|
const handleToggleChat = () => setIsChatOpen((prev) => !prev);
|
|
|
|
|
|
|
|
const handleOpenChat = () => {
|
|
const handleOpenChat = () => {
|
|
@@ -469,7 +475,7 @@ export function HomePageClient() {
|
|
|
</div>
|
|
</div>
|
|
|
</section>
|
|
</section>
|
|
|
|
|
|
|
|
- <Footer />
|
|
|
|
|
|
|
+ <Footer onOpenChat={handleOpenChat} />
|
|
|
|
|
|
|
|
{visitorId !== null && (
|
|
{visitorId !== null && (
|
|
|
<>
|
|
<>
|