| 1 | import React, { lazy, Suspense } from "react"; |
| 2 | import { createRoot } from "react-dom/client"; |
| 3 | import { installDiagnostics } from "./diagnostics.mjs"; |
| 4 | import { DiagnosticBoundary } from "./diagnostics.jsx"; |
| 5 | import { ClientRoot } from "./remote-hosts"; |
| 6 | import { native } from "./api"; |
| 7 | import "./style.css"; |
| 8 | |
| 9 | const Workbench = lazy(() => import("./main.jsx")); |
| 10 | |
| 11 | installDiagnostics(); |
| 12 | |
| 13 | window.cageNativeAction = (command) => { |
| 14 | if (window.cageWorkbenchAction) return window.cageWorkbenchAction(command); |
| 15 | if (command === "quit") return native("quitNow"); |
| 16 | }; |
| 17 | createRoot(document.getElementById("root")).render( |
| 18 | <DiagnosticBoundary> |
| 19 | <ClientRoot> |
| 20 | <Suspense |
| 21 | fallback={ |
| 22 | <div className="client-loading" role="status"> |
| 23 | 正在打开工作台… |
| 24 | </div> |
| 25 | } |
| 26 | > |
| 27 | <Workbench /> |
| 28 | </Suspense> |
| 29 | </ClientRoot> |
| 30 | </DiagnosticBoundary>, |
| 31 | ); |
| 32 | |
| 33 | window.addEventListener("hashchange", () => { |
| 34 | if (location.hash) location.reload(); |
| 35 | }); |