mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-17 14:27:02 +08:00
feat(core): prefetch onboarding video (#6736)

This commit is contained in:
@@ -67,6 +67,25 @@ const getPlayList = (t: Translate): Array<PlayListItem> => [
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
let prefetched = false;
|
||||||
|
function prefetchVideos() {
|
||||||
|
if (prefetched) return;
|
||||||
|
const videos = [
|
||||||
|
'/onboarding/ai-onboarding.general.1.mp4',
|
||||||
|
'/onboarding/ai-onboarding.general.2.mp4',
|
||||||
|
'/onboarding/ai-onboarding.general.3.mp4',
|
||||||
|
'/onboarding/ai-onboarding.general.4.mp4',
|
||||||
|
'/onboarding/ai-onboarding.general.5.mp4',
|
||||||
|
];
|
||||||
|
videos.forEach(video => {
|
||||||
|
const prefetchLink = document.createElement('link');
|
||||||
|
prefetchLink.href = video;
|
||||||
|
prefetchLink.rel = 'prefetch';
|
||||||
|
document.head.append(prefetchLink);
|
||||||
|
});
|
||||||
|
prefetched = true;
|
||||||
|
}
|
||||||
|
|
||||||
export const AIOnboardingGeneral = ({
|
export const AIOnboardingGeneral = ({
|
||||||
onDismiss,
|
onDismiss,
|
||||||
}: BaseAIOnboardingDialogProps) => {
|
}: BaseAIOnboardingDialogProps) => {
|
||||||
@@ -116,6 +135,10 @@ export const AIOnboardingGeneral = ({
|
|||||||
subscriptionService.subscription.revalidate();
|
subscriptionService.subscription.revalidate();
|
||||||
}, [subscriptionService]);
|
}, [subscriptionService]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
prefetchVideos();
|
||||||
|
}, []);
|
||||||
|
|
||||||
const videoRenderer = useCallback(
|
const videoRenderer = useCallback(
|
||||||
({ video }: PlayListItem, index: number) => (
|
({ video }: PlayListItem, index: number) => (
|
||||||
<div className={styles.videoWrapper}>
|
<div className={styles.videoWrapper}>
|
||||||
|
|||||||
Reference in New Issue
Block a user