fix: reduce canvas request bursts
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled

This commit is contained in:
Your Name 2026-03-25 15:24:52 +08:00
parent 1269e5f562
commit b08b98102a
3 changed files with 28 additions and 6 deletions

View File

@ -14,7 +14,7 @@ export async function generateMetadata(): Promise<Metadata> {
"updatedAt" in settings && settings.updatedAt
? new Date(settings.updatedAt).getTime()
: Date.now();
const faviconUrl = `/api/favicon?v=${updatedAt}-${Date.now()}`;
const faviconUrl = `/api/favicon?v=${updatedAt}`;
const metadataBase = process.env.AUTH_URL
? new URL(process.env.AUTH_URL)
: undefined;

View File

@ -2244,10 +2244,19 @@ export function CanvasChatPanel({
// 从 API 加载历史消息
const { data: historyData } = useSWR<{
messages: ChatMessage[];
}>(rawChatId ? `/api/messages?chatId=${rawChatId}` : null, fetcher);
}>(rawChatId ? `/api/messages?chatId=${rawChatId}` : null, fetcher, {
revalidateOnFocus: false,
revalidateOnReconnect: false,
dedupingInterval: 10000,
});
const { data: messageVotes } = useSWR<MessageVote[]>(
voteSWRKey,
fetcher
fetcher,
{
revalidateOnFocus: false,
revalidateOnReconnect: false,
dedupingInterval: 60000,
}
);
// 获取选中的图片节点
@ -2745,7 +2754,12 @@ export function CanvasChatPanel({
tags?: CanvasSkillTag[];
}>(
"/api/canvas-skill-tags",
fetcher
fetcher,
{
revalidateOnFocus: false,
revalidateOnReconnect: false,
dedupingInterval: 60000,
}
);
const { data: membershipSummary } = useSWR<{
isHighVip?: boolean;
@ -2767,6 +2781,11 @@ export function CanvasChatPanel({
const response = await fetch(url, { cache: "no-store" });
if (!response.ok) return null;
return response.json();
},
{
revalidateOnFocus: false,
revalidateOnReconnect: false,
dedupingInterval: 60000,
}
);
const { data: agentPresetResponse } = useSWR<{ success?: boolean; data?: AgentPreset }>(

View File

@ -6,8 +6,11 @@ export function FaviconUpdater() {
useEffect(() => {
let isDisposed = false;
const timestamp = Date.now();
const urlWithCache = `/api/favicon?v=${timestamp}`;
const existingIcon =
document.querySelector<HTMLLinkElement>('link[rel="icon"]')?.href ||
document.querySelector<HTMLLinkElement>('link[rel="shortcut icon"]')?.href ||
document.querySelector<HTMLLinkElement>('link[rel="apple-touch-icon"]')?.href;
const urlWithCache = existingIcon || "/api/favicon";
Promise.resolve().then(() => {
if (isDisposed) {