From 42a1483225de832691b4121bb161920b187d744c Mon Sep 17 00:00:00 2001 From: monoid Date: Tue, 12 Jan 2021 03:35:29 +0900 Subject: [PATCH] change title name --- app.ts | 61 ++++++++++++---------------------------------------- index.html | 2 +- loading.html | 32 +++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 48 deletions(-) create mode 100644 loading.html diff --git a/app.ts b/app.ts index c1701d7..88cb337 100644 --- a/app.ts +++ b/app.ts @@ -3,52 +3,19 @@ import { get_setting } from "./src/setting"; import { create_server, start_server } from "./src/server"; import { getAdminAccessTokenValue,getAdminRefreshTokenValue, accessTokenName, refreshTokenName } from "./src/login"; -const get_loading_html = (message?:string)=> ` - - -react-sample - - - - - -

${message || "Loading..."}

- ${message === undefined ? '
' : ""} - - -`; - const setting = get_setting(); if (!setting.cli) { - let window: BrowserWindow | null = null; + let wnd: BrowserWindow | null = null; const createWindow = async () => { - window = new BrowserWindow({ + wnd = new BrowserWindow({ width: 800, height: 600, center: true, useContentSize: true, }); - await window.loadURL(`data:text/html;base64,`+Buffer.from(get_loading_html()).toString('base64')); + //await window.loadURL(`data:text/html;base64,`+Buffer.from(get_loading_html()).toString('base64')); + await wnd.loadFile('../loading.html'); await session.defaultSession.cookies.set({ url:`http://localhost:${setting.port}`, name:accessTokenName, @@ -68,18 +35,18 @@ if (!setting.cli) { try{ const server = await create_server(); start_server(server); - await window.loadURL(`http://localhost:${setting.port}`); + await wnd.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')); + await wnd.webContents.executeJavaScript(`document.querySelector("body").innerHTML="

${e.message}

"`) } else{ - await window.loadURL(`data:text/html;base64,`+Buffer.from(get_loading_html("Error : "+e)).toString('base64')); + await wnd.webContents.executeJavaScript(`document.querySelector("body").innerHTML="

${e}

"`) } } - window.on("closed", () => { - window = null; + wnd.on("closed", () => { + wnd = null; }); }; @@ -89,11 +56,11 @@ if (!setting.cli) { app.exit(); } app.on("second-instance", () => { - if (window != null) { - if (window.isMinimized()) { - window.restore(); + if (wnd != null) { + if (wnd.isMinimized()) { + wnd.restore(); } - window.focus(); + wnd.focus(); } }); app.on("ready", (event, info) => { @@ -105,7 +72,7 @@ if (!setting.cli) { }); app.on("activate", () => { // re-recreate window when dock icon is clicked and no other windows open - if (window == null) createWindow(); + if (wnd == null) createWindow(); }); } else { (async () => { diff --git a/index.html b/index.html index 64cad55..ecbf047 100644 --- a/index.html +++ b/index.html @@ -2,7 +2,7 @@ - react-sample + Ionian diff --git a/loading.html b/loading.html new file mode 100644 index 0000000..e0ac6a5 --- /dev/null +++ b/loading.html @@ -0,0 +1,32 @@ + + + +loading + + + + + +

Loading...

+
+ + \ No newline at end of file