|
@@ -3,7 +3,8 @@ import styles from './index.module.scss'
|
|
|
import MenuSider from '@/components/MenuSider'
|
|
import MenuSider from '@/components/MenuSider'
|
|
|
import { baseOssUrl } from '@/utils/http'
|
|
import { baseOssUrl } from '@/utils/http'
|
|
|
|
|
|
|
|
-const LOADING_MS = 20_000
|
|
|
|
|
|
|
+const FIRST_LOADING_MS = 20_000
|
|
|
|
|
+const NEXT_LOADING_MS = 2_000
|
|
|
const EXIT_MS = 600
|
|
const EXIT_MS = 600
|
|
|
|
|
|
|
|
type LoadingVideoProps = {
|
|
type LoadingVideoProps = {
|
|
@@ -27,6 +28,13 @@ function LoadingVideo({ videoSrc }: LoadingVideoProps) {
|
|
|
setIsLoadingExiting(false)
|
|
setIsLoadingExiting(false)
|
|
|
setLoadingProgress(0)
|
|
setLoadingProgress(0)
|
|
|
|
|
|
|
|
|
|
+ const loadingSeenKey = `loading-video-seen:${videoUrl}`
|
|
|
|
|
+ const hasSeenLoading = localStorage.getItem(loadingSeenKey) === '1'
|
|
|
|
|
+ const loadingMs = hasSeenLoading ? NEXT_LOADING_MS : FIRST_LOADING_MS
|
|
|
|
|
+ if (!hasSeenLoading) {
|
|
|
|
|
+ localStorage.setItem(loadingSeenKey, '1')
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
let finished = false
|
|
let finished = false
|
|
|
let timer: ReturnType<typeof setTimeout> | undefined
|
|
let timer: ReturnType<typeof setTimeout> | undefined
|
|
|
const t0 = performance.now()
|
|
const t0 = performance.now()
|
|
@@ -50,7 +58,7 @@ function LoadingVideo({ videoSrc }: LoadingVideoProps) {
|
|
|
if (finished) return
|
|
if (finished) return
|
|
|
const v = videoRef.current
|
|
const v = videoRef.current
|
|
|
const elapsed = performance.now() - t0
|
|
const elapsed = performance.now() - t0
|
|
|
- const timePct = Math.min(95, Math.floor((elapsed / LOADING_MS) * 95))
|
|
|
|
|
|
|
+ const timePct = Math.min(95, Math.floor((elapsed / loadingMs) * 95))
|
|
|
let bufPct = 0
|
|
let bufPct = 0
|
|
|
if (v && v.duration && isFinite(v.duration) && v.buffered.length > 0) {
|
|
if (v && v.duration && isFinite(v.duration) && v.buffered.length > 0) {
|
|
|
bufPct = Math.floor((v.buffered.end(v.buffered.length - 1) / v.duration) * 100)
|
|
bufPct = Math.floor((v.buffered.end(v.buffered.length - 1) / v.duration) * 100)
|
|
@@ -66,14 +74,14 @@ function LoadingVideo({ videoSrc }: LoadingVideoProps) {
|
|
|
const raf = requestAnimationFrame(() => {
|
|
const raf = requestAnimationFrame(() => {
|
|
|
const v = videoRef.current
|
|
const v = videoRef.current
|
|
|
if (!v) {
|
|
if (!v) {
|
|
|
- timer = setTimeout(reveal, LOADING_MS)
|
|
|
|
|
|
|
+ timer = setTimeout(reveal, loadingMs)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
v.addEventListener('progress', tick)
|
|
v.addEventListener('progress', tick)
|
|
|
v.addEventListener('loadedmetadata', tick)
|
|
v.addEventListener('loadedmetadata', tick)
|
|
|
v.addEventListener('canplay', tick)
|
|
v.addEventListener('canplay', tick)
|
|
|
|
|
|
|
|
- timer = setTimeout(reveal, LOADING_MS)
|
|
|
|
|
|
|
+ timer = setTimeout(reveal, loadingMs)
|
|
|
|
|
|
|
|
removeListeners = () => {
|
|
removeListeners = () => {
|
|
|
v.removeEventListener('progress', tick)
|
|
v.removeEventListener('progress', tick)
|