fix createApp() fn doesn't require config, fix admin controller main entry

This commit is contained in:
dswbx
2024-12-10 08:44:50 +01:00
parent 86a7bee3d9
commit 847b08b505
2 changed files with 12 additions and 4 deletions

View File

@@ -132,7 +132,7 @@ export class App<DB = any> {
} }
} }
export function createApp(config: CreateAppConfig) { export function createApp(config: CreateAppConfig = {}) {
let connection: Connection | undefined = undefined; let connection: Connection | undefined = undefined;
try { try {

View File

@@ -14,7 +14,7 @@ const htmlBkndContextReplace = "<!-- BKND_CONTEXT -->";
export type AdminControllerOptions = { export type AdminControllerOptions = {
basepath?: string; basepath?: string;
html?: string; html?: string;
forceDev?: boolean; forceDev?: boolean | { mainPath: string };
}; };
export class AdminController implements ClassController { export class AdminController implements ClassController {
@@ -108,7 +108,10 @@ export class AdminController implements ClassController {
if (this.options.html) { if (this.options.html) {
if (this.options.html.includes(htmlBkndContextReplace)) { if (this.options.html.includes(htmlBkndContextReplace)) {
return this.options.html.replace(htmlBkndContextReplace, bknd_context); return this.options.html.replace(
htmlBkndContextReplace,
"<script>" + bknd_context + "</script>"
);
} }
console.warn( console.warn(
@@ -119,6 +122,10 @@ export class AdminController implements ClassController {
const configs = this.app.modules.configs(); const configs = this.app.modules.configs();
const isProd = !isDebug() && !this.options.forceDev; const isProd = !isDebug() && !this.options.forceDev;
const mainPath =
typeof this.options.forceDev === "object" && "mainPath" in this.options.forceDev
? this.options.forceDev.mainPath
: "/src/ui/main.tsx";
const assets = { const assets = {
js: "main.js", js: "main.js",
@@ -172,13 +179,14 @@ export class AdminController implements ClassController {
)} )}
</head> </head>
<body> <body>
<div id="root" />
<div id="app" /> <div id="app" />
<script <script
dangerouslySetInnerHTML={{ dangerouslySetInnerHTML={{
__html: bknd_context __html: bknd_context
}} }}
/> />
{!isProd && <script type="module" src="/src/ui/main.tsx" />} {!isProd && <script type="module" src={mainPath} />}
</body> </body>
</html> </html>
</Fragment> </Fragment>