Preloader.tsx 641 字节
Newer Older
P
Peter Pan 已提交
1
import React, {FunctionComponent} from 'react';
2

P
Peter Pan 已提交
3 4 5 6
import Head from 'next/head';

type PreloaderProps = {
    url: string;
7 8 9 10 11 12 13 14 15 16 17 18 19
    as?:
        | 'audio'
        | 'document'
        | 'embed'
        | 'fetch'
        | 'font'
        | 'image'
        | 'object'
        | 'script'
        | 'style'
        | 'track'
        | 'worker'
        | 'video';
P
Peter Pan 已提交
20 21
};

22 23 24 25 26 27
const Preloader: FunctionComponent<PreloaderProps> = ({url, as}) =>
    process.env.API_TOKEN_KEY ? null : (
        <Head>
            <link rel="preload" href={process.env.API_URL + url} crossOrigin="anonymous" as={as || 'fetch'} />
        </Head>
    );
P
Peter Pan 已提交
28 29

export default Preloader;