_app.tsx 1.7 KB
Newer Older
1 2
import {Router, appWithTranslation} from '~/utils/i18n';

P
Peter Pan 已提交
3
import App from 'next/app';
4
import {GlobalStyle} from '~/utils/style';
5
import Head from 'next/head';
6
import Layout from '~/components/Layout';
7
import NProgress from 'nprogress';
8
import React from 'react';
9 10 11 12 13 14 15
import {SWRConfig} from 'swr';
import {fetcher} from '~/utils/fetch';

Router.events.on('routeChangeStart', () => NProgress.start());
Router.events.on('routeChangeComplete', () => NProgress.done());
Router.events.on('routeChangeError', () => NProgress.done());

16
class VDLApp extends App {
17 18 19 20 21 22 23
    render() {
        const {Component, pageProps} = this.props;

        return (
            <>
                <Head>
                    <title>{process.env.title}</title>
P
Peter Pan 已提交
24
                    <link rel="shortcut icon" href={`${process.env.PUBLIC_PATH}/favicon.ico`} />
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
                    <meta
                        name="viewport"
                        content="width=device-width,minimum-scale=1,maximum-scale=1,initial-scale=1,user-scalable=no,shrink-to-fit=no"
                    />
                    <meta name="description" content={process.env.description} />
                    <meta name="keywords" content={process.env.keywords} />
                    <meta name="author" content={process.env.author} />
                </Head>
                <GlobalStyle />
                <SWRConfig
                    value={{
                        fetcher,
                        revalidateOnFocus: false,
                        revalidateOnReconnect: false
                    }}
                >
                    <Layout>
                        <Component {...pageProps} />
                    </Layout>
                </SWRConfig>
            </>
        );
    }
}

50
export default appWithTranslation(VDLApp);