diff --git a/app.ts b/app.ts index 05a8116..adac428 100644 --- a/app.ts +++ b/app.ts @@ -2,7 +2,7 @@ import { app, BrowserWindow } from "electron"; import { get_setting } from "./src/setting"; import { create_server, start_server } from "./src/server"; -const loading_html = ` +const get_loading_html = (content?:string)=> ` react-sample @@ -28,8 +28,8 @@ h1 { } -

Loading

-
+

${content || "Loading..."}

+ ${content === undefined ? '
' : ""} `; @@ -45,10 +45,20 @@ if (!setting.cli) { center: true, useContentSize: true, }); - await window.loadURL(`data:text/html;base64,`+Buffer.from(loading_html).toString('base64')); - const server = await create_server(); - start_server(server); - await window.loadURL(`http://localhost:${setting.port}`); + await window.loadURL(`data:text/html;base64,`+Buffer.from(get_loading_html()).toString('base64')); + try{ + const server = await create_server(); + start_server(server); + await window.loadURL(`http://localhost:${setting.port}`); + } + catch(e){ + if(e instanceof Error){ + await window.loadURL(`data:text/html;base64,`+Buffer.from(get_loading_html("Error : "+e.message)).toString('base64')); + } + else{ + await window.loadURL(`data:text/html;base64,`+Buffer.from(get_loading_html("Error : "+e)).toString('base64')); + } + } window.on("closed", () => { window = null; });