refactor: build/runtime/client configs

This commit is contained in:
Yidadaa
2023-04-11 01:21:34 +08:00
parent 7aee53ea05
commit 9b61cb1335
14 changed files with 154 additions and 91 deletions

View File

@@ -1,12 +1,29 @@
import { Analytics } from "@vercel/analytics/react";
import { Home } from "./components/home";
import { getServerSideConfig } from "./config/server";
import { RUNTIME_CONFIG_DOM } from "./constant";
const serverConfig = getServerSideConfig();
// Danger! Don not write any secret value here!
// 警告!不要在这里写入任何敏感信息!
const DANGER_CONFIG = {
needCode: serverConfig?.needCode,
};
declare global {
type DangerConfig = typeof DANGER_CONFIG;
}
export default function App() {
return (
<>
<div style={{ display: "none" }} id={RUNTIME_CONFIG_DOM}>
{JSON.stringify(DANGER_CONFIG)}
</div>
<Home />
<Analytics />
{serverConfig?.isVercel && <Analytics />}
</>
);
}