2026-08-03 11:04:49 +08:00
|
|
|
|
import { ConfigProvider, theme } from "antd";
|
|
|
|
|
|
import zhTW from "antd/locale/zh_TW";
|
|
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
|
|
import "dayjs/locale/zh-tw";
|
|
|
|
|
|
import React from "react";
|
|
|
|
|
|
import ReactDOM from "react-dom/client";
|
|
|
|
|
|
|
2026-08-03 11:30:24 +08:00
|
|
|
|
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
2026-08-03 11:04:49 +08:00
|
|
|
|
import { BaseEnumerator } from "./Engine/CatanEngine/CoroutineV2/Core/BaseEnumerator";
|
|
|
|
|
|
|
|
|
|
|
|
import { GameItemsProvider } from "@/context/GameItemsContext";
|
|
|
|
|
|
import Lobby from "./UI/Lobby";
|
|
|
|
|
|
import Login from "./UI/Login";
|
|
|
|
|
|
import { ModalProvider } from "./UIControl/ModalContext";
|
|
|
|
|
|
|
|
|
|
|
|
// utils
|
|
|
|
|
|
import "@/FormTableExt/TableExt/CSSettingsV3Ext";
|
|
|
|
|
|
import "@/utils/ArrayExtension";
|
|
|
|
|
|
import "@/utils/catan";
|
|
|
|
|
|
import "@/utils/NumberExtension";
|
|
|
|
|
|
import "@/utils/String";
|
|
|
|
|
|
import "./index.css";
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化 BaseEnumerator
|
|
|
|
|
|
BaseEnumerator.Init();
|
|
|
|
|
|
|
|
|
|
|
|
// 設定 dayjs 語言
|
|
|
|
|
|
dayjs.locale("zh-tw");
|
|
|
|
|
|
|
2026-08-03 11:30:24 +08:00
|
|
|
|
// 依目前網址推導部署子路徑(專案不一定放在網站根目錄,例如 /Line_Project_Bot/)
|
|
|
|
|
|
function getBasename(): string {
|
|
|
|
|
|
let path: string = location.pathname.replace(/index\.html$/, "");
|
|
|
|
|
|
// 去除已知路由字尾,避免在 /lobby 重新整理時把路由誤當成資料夾
|
|
|
|
|
|
path = path.replace(/lobby\/?$/, "");
|
|
|
|
|
|
if (!path.endsWith("/")) {
|
|
|
|
|
|
path += "/";
|
|
|
|
|
|
}
|
|
|
|
|
|
return path;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-08-03 11:04:49 +08:00
|
|
|
|
// 路由設定
|
2026-08-03 11:30:24 +08:00
|
|
|
|
const router = createBrowserRouter([
|
2026-08-03 11:04:49 +08:00
|
|
|
|
{ path: "/", element: <Login /> },
|
|
|
|
|
|
{ path: "/lobby", element: <Lobby /> },
|
2026-08-03 11:30:24 +08:00
|
|
|
|
], { basename: getBasename() });
|
2026-08-03 11:04:49 +08:00
|
|
|
|
|
|
|
|
|
|
// Render
|
|
|
|
|
|
// 注意:不能用 React.StrictMode — 開發模式雙重掛載會讓 NetManagerSD 等靜態單例的連線互相覆蓋
|
|
|
|
|
|
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
|
|
|
|
|
<>
|
|
|
|
|
|
<ConfigProvider
|
|
|
|
|
|
locale={zhTW}
|
|
|
|
|
|
theme={{
|
|
|
|
|
|
algorithm: theme.darkAlgorithm,
|
|
|
|
|
|
token: {
|
|
|
|
|
|
colorPrimary: "#ffb020",
|
|
|
|
|
|
colorBgBase: "#0a0d12",
|
|
|
|
|
|
colorBgContainer: "#10151d",
|
|
|
|
|
|
colorBorder: "#232d3d",
|
|
|
|
|
|
colorText: "#dbe4f0",
|
|
|
|
|
|
colorTextSecondary: "#6b7a8f",
|
|
|
|
|
|
borderRadius: 8,
|
|
|
|
|
|
fontFamily: "\"Noto Sans TC\", sans-serif",
|
|
|
|
|
|
},
|
|
|
|
|
|
components: {
|
|
|
|
|
|
Button: { fontFamily: "\"Chakra Petch\", \"Noto Sans TC\", sans-serif" },
|
|
|
|
|
|
Modal: { contentBg: "#10151d", headerBg: "#10151d" },
|
|
|
|
|
|
},
|
|
|
|
|
|
}}
|
|
|
|
|
|
>
|
|
|
|
|
|
<ModalProvider>
|
|
|
|
|
|
<GameItemsProvider>
|
|
|
|
|
|
<RouterProvider router={router} />
|
|
|
|
|
|
</GameItemsProvider>
|
|
|
|
|
|
</ModalProvider>
|
|
|
|
|
|
</ConfigProvider>
|
|
|
|
|
|
</>
|
|
|
|
|
|
);
|