优化预加载策略

This commit is contained in:
mtvpls
2026-06-17 10:14:03 +08:00
parent 88c4c6a783
commit 84afb97f9f
3 changed files with 10 additions and 4 deletions
+3 -3
View File
@@ -896,7 +896,7 @@ function HomeClient() {
</button>
{musicEnabled && (
<Link href='/music'>
<Link href='/music' prefetch={false}>
<button
className='p-1.5 rounded-lg text-green-500 hover:text-green-600 transition-colors'
title='音乐视听'
@@ -907,7 +907,7 @@ function HomeClient() {
)}
{mangaEnabled && (
<Link href='/manga'>
<Link href='/manga' prefetch={false}>
<button
className='p-1.5 rounded-lg text-emerald-500 hover:text-emerald-600 transition-colors'
title='漫画展馆'
@@ -918,7 +918,7 @@ function HomeClient() {
)}
{booksEnabled && (
<Link href='/books'>
<Link href='/books' prefetch={false}>
<button
className='p-1.5 rounded-lg text-amber-500 hover:text-amber-600 transition-colors'
title='电子书馆'
-1
View File
@@ -21,7 +21,6 @@ const MobileHeader = ({ showBackButton = false }: MobileHeaderProps) => {
<div className='flex items-center gap-2'>
<Link
href='/search'
prefetch={false}
className='w-10 h-10 p-2 rounded-full flex items-center justify-center text-gray-600 hover:bg-gray-200/50 dark:text-gray-300 dark:hover:bg-gray-700/50 transition-colors'
>
<svg
+7
View File
@@ -1,5 +1,6 @@
'use client';
import { useRouter } from 'next/navigation';
import { useEffect, useState } from 'react';
import { BackButton } from './BackButton';
@@ -18,9 +19,15 @@ interface PageLayoutProps {
}
const PageLayout = ({ children, activePath = '/', hideNavigation = false }: PageLayoutProps) => {
const router = useRouter();
const [backgroundImage, setBackgroundImage] = useState('');
const shouldShowSharedBackground = !hideNavigation && activePath !== '/play';
useEffect(() => {
router.prefetch('/search');
router.prefetch('/play');
}, [router]);
useEffect(() => {
if (typeof window === 'undefined' || !shouldShowSharedBackground) {
setBackgroundImage('');