add to display simple error
This commit is contained in:
parent
05814d8a31
commit
47ffe6e80f
18
app.ts
18
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 = `<!DOCTYPE html>
|
||||
const get_loading_html = (content?:string)=> `<!DOCTYPE html>
|
||||
<html lang="ko"><head>
|
||||
<meta charset="UTF-8">
|
||||
<title>react-sample</title>
|
||||
@ -28,8 +28,8 @@ h1 {
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<h1>Loading</h1>
|
||||
<div id="loading"></div>
|
||||
<h1>${content || "Loading..."}</h1>
|
||||
${content === undefined ? '<div id="loading"></div>' : ""}
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
@ -45,10 +45,20 @@ if (!setting.cli) {
|
||||
center: true,
|
||||
useContentSize: true,
|
||||
});
|
||||
await window.loadURL(`data:text/html;base64,`+Buffer.from(loading_html).toString('base64'));
|
||||
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;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user