add to display simple error
This commit is contained in:
parent
05814d8a31
commit
47ffe6e80f
24
app.ts
24
app.ts
@ -2,7 +2,7 @@ import { app, BrowserWindow } from "electron";
|
|||||||
import { get_setting } from "./src/setting";
|
import { get_setting } from "./src/setting";
|
||||||
import { create_server, start_server } from "./src/server";
|
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>
|
<html lang="ko"><head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>react-sample</title>
|
<title>react-sample</title>
|
||||||
@ -28,8 +28,8 @@ h1 {
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<body>
|
<body>
|
||||||
<h1>Loading</h1>
|
<h1>${content || "Loading..."}</h1>
|
||||||
<div id="loading"></div>
|
${content === undefined ? '<div id="loading"></div>' : ""}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`;
|
`;
|
||||||
@ -45,10 +45,20 @@ if (!setting.cli) {
|
|||||||
center: true,
|
center: true,
|
||||||
useContentSize: 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'));
|
||||||
const server = await create_server();
|
try{
|
||||||
start_server(server);
|
const server = await create_server();
|
||||||
await window.loadURL(`http://localhost:${setting.port}`);
|
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.on("closed", () => {
|
||||||
window = null;
|
window = null;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user