preload in homepage
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
NekoVari 2025-04-18 07:53:47 +07:00
parent 9bf674edf5
commit 4744ee5909
2 changed files with 40 additions and 18 deletions

View file

@ -1,11 +1,34 @@
import { useState } from 'react'
import '../css/global.css'
import BlackButton from './components/customButton'
import { useEffect } from 'react';
import '../css/global.css';
import BlackButton from './components/customButton';
function HomePage() {
useEffect(() => {
const controller = new AbortController();
const fetchVideo = async () => {
try {
const res = await fetch(`${import.meta.env.VITE_ASSETS_URL}/hallway_FFF.mp4`, {
signal: controller.signal,
cache: 'force-cache', // Helps to ensure the response is stored
});
return(
// Read the response into memory (helps trigger caching)
await res.blob();
console.log('Video prefetched successfully.');
} catch (err) {
if (err.name !== 'AbortError') {
console.error('Video prefetch failed:', err);
}
}
};
fetchVideo();
return () => controller.abort();
}, []);
return (
<div style={{
display: 'flex',
justifyContent: 'center',
@ -15,11 +38,11 @@ function HomePage() {
}}>
<label className='title'>Fifty Shades <br /> of Bully</label>
<div style={{ height: '8vh' }}/>
<div style={{ height: '8vh' }} />
<BlackButton text="Start" to='/warn'/>
<BlackButton text="Start" to='/warn' />
</div>
)
);
}
export default HomePage
export default HomePage;

View file

@ -15,7 +15,6 @@ function IntroductionPageData(){
maxWidth:"100vw",
flexDirection: 'column',
}}>
{/* <PlayVideo src='hallway_FFF.mp4'/> */}
<div style={{
position: "fixed",