diff --git a/app/layout.tsx b/app/layout.tsx index 6159151..e6af49c 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -2,6 +2,7 @@ import type { Metadata } from "next"; import { Geist, Geist_Mono } from "next/font/google"; import { Toaster } from "sonner"; import { ThemeProvider } from "@/components/theme-provider"; +import { FaviconUpdater } from "@/components/favicon-updater"; import "./globals.css"; import { SessionProvider } from "next-auth/react"; @@ -10,6 +11,11 @@ import { getSiteSettings } from "@/lib/db/queries"; export async function generateMetadata(): Promise { const settings = await getSiteSettings(); + + // 处理 favicon URL,添加缓存破坏参数确保更新 + const faviconUrl = settings.favicon + ? `${settings.favicon}${settings.favicon.includes('?') ? '&' : '?'}v=${Date.now()}` + : "/favicon.ico"; return { title: { @@ -18,8 +24,12 @@ export async function generateMetadata(): Promise { }, description: settings.siteName, icons: { - icon: settings.favicon || "/favicon.ico", - apple: settings.favicon || "/favicon.ico", + icon: [ + { url: faviconUrl, sizes: "any" }, + { url: faviconUrl, type: "image/x-icon" }, + ], + apple: faviconUrl, + shortcut: faviconUrl, }, }; } @@ -145,6 +155,7 @@ export default function RootLayout({ /> + { + // 从 API 获取最新的 favicon 设置 + fetch("/api/site-settings") + .then((res) => res.json()) + .then((settings) => { + if (settings.favicon) { + const faviconUrl = settings.favicon; + const timestamp = Date.now(); + const urlWithCache = `${faviconUrl}${faviconUrl.includes("?") ? "&" : "?"}v=${timestamp}`; + + // 移除所有旧的 favicon link 标签 + const oldLinks = document.querySelectorAll('link[rel*="icon"]'); + oldLinks.forEach((link) => link.remove()); + + // 添加新的 favicon link 标签 + const link = document.createElement("link"); + link.rel = "icon"; + link.type = "image/x-icon"; + link.href = urlWithCache; + document.head.appendChild(link); + + // 添加 Apple touch icon + const appleLink = document.createElement("link"); + appleLink.rel = "apple-touch-icon"; + appleLink.href = urlWithCache; + document.head.appendChild(appleLink); + + // 添加 shortcut icon + const shortcutLink = document.createElement("link"); + shortcutLink.rel = "shortcut icon"; + shortcutLink.href = urlWithCache; + document.head.appendChild(shortcutLink); + } + }) + .catch((error) => { + console.error("[Favicon] Error updating favicon:", error); + }); + }, []); + + return null; +} + diff --git a/components/image-annotator.tsx b/components/image-annotator.tsx index 1662c91..3f4b9f9 100644 --- a/components/image-annotator.tsx +++ b/components/image-annotator.tsx @@ -1253,7 +1253,7 @@ export function ImageAnnotator({ imageUrl, onConfirm, onCancel }: ImageAnnotator /* 尺寸调整模式 - 左右对比布局 */ <> {/* 左侧:原图 */} -
+
原图
{image && ( @@ -1275,7 +1275,21 @@ export function ImageAnnotator({ imageUrl, onConfirm, onCancel }: ImageAnnotator {/* 右侧:尺寸调整预览画布 */}
-
调整尺寸
+
+ 调整尺寸 + {(processedImageUrl || processedImageBase64) && processType === "resize" && ( + + )} +