index.tsx 1.8 KB
Newer Older
P
Peter Pan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/**
 * Copyright 2020 Baidu Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

17 18 19 20 21
import '~/utils/i18n';

import App from './App';
import BodyLoading from '~/components/BodyLoading';
import {GlobalStyle} from '~/utils/style';
P
Peter Pan 已提交
22
import {Provider} from 'react-redux';
23 24
import React from 'react';
import ReactDOM from 'react-dom';
P
Peter Pan 已提交
25
import store from '~/store';
26 27 28

const TELEMETRY_ID: string = import.meta.env.SNOWPACK_PUBLIC_TELEMETRY_ID;

P
Peter Pan 已提交
29
window._hmt = window._hmt || [];
30 31 32 33 34 35 36 37 38 39 40 41 42
if (import.meta.env.MODE === 'production' && TELEMETRY_ID) {
    (function () {
        const hm = document.createElement('script');
        hm.src = `https://hm.baidu.com/hm.js?${TELEMETRY_ID}`;
        const s = document.getElementsByTagName('script')[0];
        s.parentNode?.insertBefore(hm, s);
    })();
}

ReactDOM.render(
    <React.StrictMode>
        <GlobalStyle />
        <React.Suspense fallback={<BodyLoading />}>
P
Peter Pan 已提交
43
            <Provider store={store}>
44
                <App />
P
Peter Pan 已提交
45
            </Provider>
46 47 48 49 50 51 52 53 54 55
        </React.Suspense>
    </React.StrictMode>,
    document.getElementById('root')
);

// Hot Module Replacement (HMR) - Remove this snippet to remove HMR.
// Learn more: https://www.snowpack.dev/#hot-module-replacement
if (import.meta.hot) {
    import.meta.hot.accept();
}