优化预加载策略
This commit is contained in:
+3
-3
@@ -896,7 +896,7 @@ function HomeClient() {
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
{musicEnabled && (
|
{musicEnabled && (
|
||||||
<Link href='/music'>
|
<Link href='/music' prefetch={false}>
|
||||||
<button
|
<button
|
||||||
className='p-1.5 rounded-lg text-green-500 hover:text-green-600 transition-colors'
|
className='p-1.5 rounded-lg text-green-500 hover:text-green-600 transition-colors'
|
||||||
title='音乐视听'
|
title='音乐视听'
|
||||||
@@ -907,7 +907,7 @@ function HomeClient() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{mangaEnabled && (
|
{mangaEnabled && (
|
||||||
<Link href='/manga'>
|
<Link href='/manga' prefetch={false}>
|
||||||
<button
|
<button
|
||||||
className='p-1.5 rounded-lg text-emerald-500 hover:text-emerald-600 transition-colors'
|
className='p-1.5 rounded-lg text-emerald-500 hover:text-emerald-600 transition-colors'
|
||||||
title='漫画展馆'
|
title='漫画展馆'
|
||||||
@@ -918,7 +918,7 @@ function HomeClient() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{booksEnabled && (
|
{booksEnabled && (
|
||||||
<Link href='/books'>
|
<Link href='/books' prefetch={false}>
|
||||||
<button
|
<button
|
||||||
className='p-1.5 rounded-lg text-amber-500 hover:text-amber-600 transition-colors'
|
className='p-1.5 rounded-lg text-amber-500 hover:text-amber-600 transition-colors'
|
||||||
title='电子书馆'
|
title='电子书馆'
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ const MobileHeader = ({ showBackButton = false }: MobileHeaderProps) => {
|
|||||||
<div className='flex items-center gap-2'>
|
<div className='flex items-center gap-2'>
|
||||||
<Link
|
<Link
|
||||||
href='/search'
|
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'
|
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
|
<svg
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
|
import { useRouter } from 'next/navigation';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { BackButton } from './BackButton';
|
import { BackButton } from './BackButton';
|
||||||
@@ -18,9 +19,15 @@ interface PageLayoutProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const PageLayout = ({ children, activePath = '/', hideNavigation = false }: PageLayoutProps) => {
|
const PageLayout = ({ children, activePath = '/', hideNavigation = false }: PageLayoutProps) => {
|
||||||
|
const router = useRouter();
|
||||||
const [backgroundImage, setBackgroundImage] = useState('');
|
const [backgroundImage, setBackgroundImage] = useState('');
|
||||||
const shouldShowSharedBackground = !hideNavigation && activePath !== '/play';
|
const shouldShowSharedBackground = !hideNavigation && activePath !== '/play';
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
router.prefetch('/search');
|
||||||
|
router.prefetch('/play');
|
||||||
|
}, [router]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (typeof window === 'undefined' || !shouldShowSharedBackground) {
|
if (typeof window === 'undefined' || !shouldShowSharedBackground) {
|
||||||
setBackgroundImage('');
|
setBackgroundImage('');
|
||||||
|
|||||||
Reference in New Issue
Block a user