Skip to content

Commit 8cecdf9

Browse files
committed
fix: add all change file
1 parent 97160b5 commit 8cecdf9

File tree

25 files changed

+224
-173
lines changed

25 files changed

+224
-173
lines changed

.env

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1+
# dev env
12
DEV_HOST=localhost
23
DEV_PORT=9000
34
WDS_PORT=9001
5+
PUBLIC_DEV_API_HOST=localhost:9000
6+
# prod env
47
PROD_PORT=5000
58
PROD_HOST=localhost
6-
PUBLIC_API_HOST=localhost:9000
9+
PUBLIC_PROD_API_HOST=localhost:5000
10+
# feature
711
CRYPTO_KEY=ad$cr3efW89ypg
812
SSR=true
913
MIDDLEWARE=false
1014
ANIMATE_ROUTER=false
15+
# entry
1116
SERVER_ENTRY=./src/server/entry.ts
1217
CLIENT_ENTRY=./src/client/entry.tsx

global.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ declare global {
3636
PROD_PORT: string;
3737
SSR: string;
3838
UI: "antd" | "material" | "chakra";
39-
PUBLIC_API_HOST: string;
39+
PUBLIC_DEV_API_HOST: string;
40+
PUBLIC_PROD_API_HOST: string;
4041
CRYPTO_KEY: string;
4142
SERVER_ENTRY: string;
4243
CLIENT_ENTRY: string;

script/start-prod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const withPromise = async () => {
2323
} catch (e) {
2424
console.error(e.message);
2525
}
26-
console.log("compiler done. before start this app, pls set PUBLIC_API_HOST in the env file!");
2726
};
2827

2928
withPromise();

src/client/chakraEntry.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
11
import { ChakraProvider, createCookieStorageManager } from "@chakra-ui/react";
2-
import { CacheProvider } from "@emotion/react";
32
import { StrictMode } from "react";
43
import { HelmetProvider } from "react-helmet-async";
54
import { Provider } from "react-redux";
65
import { BrowserRouter as Router } from "react-router-dom";
76

87
import { App } from "components/App";
9-
import { createEmotionCache } from "config/createEmotionCache";
108
import { theme } from "theme";
119

1210
import type { createUniversalStore } from "store";
1311

14-
const cache = createEmotionCache();
15-
1612
const Root = ({ store }: { store: ReturnType<typeof createUniversalStore> }) => {
1713
console.warn("you are using chakra UI component library!");
1814

1915
const cookieStore = createCookieStorageManager("chakra-ui-color-mode", store.getState().server.cookie.data);
2016

2117
return (
2218
<StrictMode>
23-
<CacheProvider value={cache}>
24-
<ChakraProvider resetCSS theme={theme} colorModeManager={cookieStore}>
25-
<Provider store={store}>
26-
<Router>
27-
<HelmetProvider>
28-
<App />
29-
</HelmetProvider>
30-
</Router>
31-
</Provider>
32-
</ChakraProvider>
33-
</CacheProvider>
19+
<ChakraProvider resetCSS theme={theme} colorModeManager={cookieStore}>
20+
<Provider store={store}>
21+
<Router>
22+
<HelmetProvider>
23+
<App />
24+
</HelmetProvider>
25+
</Router>
26+
</Provider>
27+
</ChakraProvider>
3428
</StrictMode>
3529
);
3630
};

src/client/entry.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
2-
import { loadableReady } from "@loadable/component";
32
import { createRoot, hydrateRoot } from "react-dom/client";
43

54
import { createUniversalStore } from "store";
@@ -34,13 +33,13 @@ if (__CSR__) {
3433
log("pure render by client", "warn");
3534
const { preLoadLang } = require("utils/preLoad");
3635
const root = createRoot(place);
37-
preLoadLang({ store, lang: window.__ENV__.LANG }).then(() => loadableReady(() => root.render(<Root store={store} />)));
36+
preLoadLang({ store, lang: window.__ENV__.LANG }).then(() => root.render(<Root store={store} />));
3837
} else {
3938
if (!window.__ENV__.isSSR || (window.__ENV__.isDEVELOPMENT && window.__ENV__.isMIDDLEWARE)) {
4039
log("not hydrate render on client", "warn");
4140
const root = createRoot(place);
42-
loadableReady(() => root.render(<Root store={store} />));
41+
root.render(<Root store={store} />);
4342
} else {
44-
loadableReady(() => hydrateRoot(place, <Root store={store} />));
43+
hydrateRoot(place, <Root store={store} />);
4544
}
4645
}

src/components/Layout.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1+
import { lazy, Suspense } from "react";
12
import { Outlet } from "react-router";
23

3-
import { Footer } from "./Footer";
44
import { Header } from "./Header";
55
import style from "./index.module.scss";
66

77
import type { PreLoadComponentType } from "types/components";
88

9+
const Footer = lazy(() => import("./Footer").then(({ Footer }) => ({ default: Footer })));
10+
911
export const Layout: PreLoadComponentType = () => {
1012
return (
1113
<div className={style.container}>
1214
<Header />
1315
<main className={style.content}>
14-
<Outlet />
16+
<Suspense>
17+
<Outlet />
18+
</Suspense>
1519
<hr />
1620
</main>
17-
<Footer />
21+
<Suspense>
22+
<Footer />
23+
</Suspense>
1824
</div>
1925
);
2026
};

src/components/RenderMatch.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AnimatePresence, motion } from "framer-motion";
2-
import React from "react";
2+
import React, { Suspense } from "react";
33
import { useRoutes } from "react-router";
44

55
import { allRoutes } from "router/routes";
@@ -35,11 +35,11 @@ export const RenderMatch = () => {
3535
stiffness: 50,
3636
}}
3737
>
38-
{all}
38+
<Suspense>{all}</Suspense>
3939
</motion.div>
4040
</React.Fragment>
4141
</AnimatePresence>
4242
) : (
43-
all
43+
<Suspense>{all}</Suspense>
4444
);
4545
};

src/components/WrapperLang/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { useEffect, useRef } from "react";
1+
import { useCallback, useEffect, useRef } from "react";
22
import { IntlProvider } from "react-intl";
33
import { useSelector } from "react-redux";
44

55
import { defaultLang } from "utils/i18n";
66

7-
import type { ReactChild } from "react";
7+
import type { ReactNode } from "react";
88
import type { StoreState } from "types/store";
99

10-
export const WrapperLang = ({ children }: { children: ReactChild }) => {
10+
export const WrapperLang = ({ children }: { children: ReactNode }) => {
1111
const htmlRef = useRef<HTMLHtmlElement | null>(null);
12-
const data = useSelector<StoreState, StoreState["server"]["lang"]["data"]>((state) => state.server.lang.data);
13-
const lang = useSelector<StoreState, StoreState["client"]["currentLang"]["data"]>((state) => state.client.currentLang.data);
12+
const data = useSelector<StoreState, StoreState["server"]["lang"]["data"]>(useCallback((state) => state.server.lang.data, []));
13+
const lang = useSelector<StoreState, StoreState["client"]["currentLang"]["data"]>(useCallback((state) => state.client.currentLang.data, []));
1414

1515
useEffect(() => {
1616
if (!htmlRef.current) {

src/components/style.module.scss

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/config/createEmotionCache.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)