From 7429e965212b5617875ae114749b229b0ec24134 Mon Sep 17 00:00:00 2001
From: zhuba-Ahhh <3477826311@qq.com>
Date: Sat, 24 Aug 2024 16:11:25 +0800
Subject: [PATCH] fix: :bug: lighthouse
---
next.config.mjs | 6 +++++-
src/app/about/page.tsx | 4 ++--
src/app/blog/[id]/ShareButtons.tsx | 16 ++++++++++------
src/app/contact/page.tsx | 8 ++++++++
src/app/privacy/page.tsx | 8 ++++++++
src/app/terms/page.tsx | 8 ++++++++
src/components/CopyButton.tsx | 4 ++--
src/components/Footer.tsx | 22 ++++++++++++----------
src/components/ThemeToggle.tsx | 4 ++--
src/hooks/index.ts | 1 +
src/hooks/useThemeType.ts | 10 ++++++++++
11 files changed, 68 insertions(+), 23 deletions(-)
create mode 100644 src/app/contact/page.tsx
create mode 100644 src/app/privacy/page.tsx
create mode 100644 src/app/terms/page.tsx
create mode 100644 src/hooks/index.ts
create mode 100644 src/hooks/useThemeType.ts
diff --git a/next.config.mjs b/next.config.mjs
index d730e0c..b253027 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -12,12 +12,16 @@ const nextConfig = {
images: {
unoptimized: true,
},
+ productionBrowserSourceMaps: true,
pageExtensions: ["js", "jsx", "md", "mdx", "ts", "tsx"],
- webpack: (config, { isServer }) => {
+ webpack: (config, { dev, isServer }) => {
if (!isServer) {
config.externals = {
// 添加其他需要从 CDN 加载的依赖
};
+ if (!dev && !isServer) {
+ config.optimization.usedExports = true;
+ }
}
return config;
},
diff --git a/src/app/about/page.tsx b/src/app/about/page.tsx
index 3077f41..408460d 100644
--- a/src/app/about/page.tsx
+++ b/src/app/about/page.tsx
@@ -1,10 +1,10 @@
"use client";
import Image from "next/image";
-import { useTheme } from "next-themes";
+import { useThemeType } from "@/hooks";
export default function About() {
- const { theme } = useTheme();
+ const { theme } = useThemeType();
return (
);
}
diff --git a/src/app/contact/page.tsx b/src/app/contact/page.tsx
new file mode 100644
index 0000000..e393614
--- /dev/null
+++ b/src/app/contact/page.tsx
@@ -0,0 +1,8 @@
+export default function PrivacyPage() {
+ return (
+
+
隐私政策
+
这里是您的隐私政策内容...
+
+ );
+}
\ No newline at end of file
diff --git a/src/app/privacy/page.tsx b/src/app/privacy/page.tsx
new file mode 100644
index 0000000..ce26ba4
--- /dev/null
+++ b/src/app/privacy/page.tsx
@@ -0,0 +1,8 @@
+export default function PrivacyPage() {
+ return (
+
+
隐私政策
+
这里是您的隐私政策内容...
+
+ );
+}
diff --git a/src/app/terms/page.tsx b/src/app/terms/page.tsx
new file mode 100644
index 0000000..ce26ba4
--- /dev/null
+++ b/src/app/terms/page.tsx
@@ -0,0 +1,8 @@
+export default function PrivacyPage() {
+ return (
+
+
隐私政策
+
这里是您的隐私政策内容...
+
+ );
+}
diff --git a/src/components/CopyButton.tsx b/src/components/CopyButton.tsx
index 8bfc51e..6a24d15 100644
--- a/src/components/CopyButton.tsx
+++ b/src/components/CopyButton.tsx
@@ -3,7 +3,7 @@
import React, { useState, useCallback, useMemo } from "react";
import Image from "next/image";
import { throttle } from "lodash-es";
-import { useTheme } from "next-themes";
+import { useThemeType } from "@/hooks";
interface CopyButtonProps {
text: string;
@@ -13,7 +13,7 @@ interface CopyButtonProps {
const CopyButton: React.FC = ({ text, language }) => {
const [state, setState] = useState<"idle" | "copy" | "copied">("idle");
const [isHovered, setIsHovered] = useState(false);
- const { theme } = useTheme();
+ const { theme } = useThemeType();
const throttledCopy = useMemo(
() =>
diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx
index 2ca3427..52b6562 100644
--- a/src/components/Footer.tsx
+++ b/src/components/Footer.tsx
@@ -2,6 +2,12 @@ import Link from "next/link";
import { Badge } from "@/components/ui/badge";
export default function Footer() {
+ const links = [
+ { href: "/privacy", label: "隐私政策" },
+ { href: "/terms", label: "使用条款" },
+ { href: "/contact", label: "联系我们" },
+ ];
+
return (
);
-}
+}
\ No newline at end of file
diff --git a/src/components/ThemeToggle.tsx b/src/components/ThemeToggle.tsx
index b2e4948..13661b2 100644
--- a/src/components/ThemeToggle.tsx
+++ b/src/components/ThemeToggle.tsx
@@ -1,6 +1,6 @@
"use client";
import { useState, useEffect } from "react";
-import { useTheme } from "next-themes";
+import { useThemeType } from "@/hooks";
const MoonIcon = () => (