change title name

This commit is contained in:
monoid 2021-01-12 03:35:29 +09:00
parent 190e669322
commit 42a1483225
3 changed files with 47 additions and 48 deletions

61
app.ts
View File

@ -3,52 +3,19 @@ import { get_setting } from "./src/setting";
import { create_server, start_server } from "./src/server"; import { create_server, start_server } from "./src/server";
import { getAdminAccessTokenValue,getAdminRefreshTokenValue, accessTokenName, refreshTokenName } from "./src/login"; import { getAdminAccessTokenValue,getAdminRefreshTokenValue, accessTokenName, refreshTokenName } from "./src/login";
const get_loading_html = (message?:string)=> `<!DOCTYPE html>
<html lang="ko"><head>
<meta charset="UTF-8">
<title>react-sample</title>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'
fonts.googleapis.com; font-src 'self' fonts.gstatic.com">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<style>
body { margin-top: 100px; background-color: #3f51b5; color: #fff; text-align:center; }
h1 {
font: 2em 'Roboto', sans-serif;
margin-bottom: 40px;
}
#loading {
display: inline-block;
width: 50px;
height: 50px;
border: 3px solid rgba(255,255,255,.3);
border-radius: 50%;
border-top-color: #fff;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg);}
}
</style>
<body>
<h1>${message || "Loading..."}</h1>
${message === undefined ? '<div id="loading"></div>' : ""}
</body>
</html>
`;
const setting = get_setting(); const setting = get_setting();
if (!setting.cli) { if (!setting.cli) {
let window: BrowserWindow | null = null; let wnd: BrowserWindow | null = null;
const createWindow = async () => { const createWindow = async () => {
window = new BrowserWindow({ wnd = new BrowserWindow({
width: 800, width: 800,
height: 600, height: 600,
center: true, center: true,
useContentSize: 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({ await session.defaultSession.cookies.set({
url:`http://localhost:${setting.port}`, url:`http://localhost:${setting.port}`,
name:accessTokenName, name:accessTokenName,
@ -68,18 +35,18 @@ if (!setting.cli) {
try{ try{
const server = await create_server(); const server = await create_server();
start_server(server); start_server(server);
await window.loadURL(`http://localhost:${setting.port}`); await wnd.loadURL(`http://localhost:${setting.port}`);
} }
catch(e){ catch(e){
if(e instanceof Error){ 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="<h1>${e.message}</h1>"`)
} }
else{ 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="<h1>${e}</h1>"`)
} }
} }
window.on("closed", () => { wnd.on("closed", () => {
window = null; wnd = null;
}); });
}; };
@ -89,11 +56,11 @@ if (!setting.cli) {
app.exit(); app.exit();
} }
app.on("second-instance", () => { app.on("second-instance", () => {
if (window != null) { if (wnd != null) {
if (window.isMinimized()) { if (wnd.isMinimized()) {
window.restore(); wnd.restore();
} }
window.focus(); wnd.focus();
} }
}); });
app.on("ready", (event, info) => { 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 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 { } else {
(async () => { (async () => {

View File

@ -2,7 +2,7 @@
<html lang="ko"> <html lang="ko">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>react-sample</title> <title>Ionian</title>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' fonts.googleapis.com; <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' fonts.googleapis.com;
font-src 'self' fonts.gstatic.com"> font-src 'self' fonts.gstatic.com">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">

32
loading.html Normal file
View File

@ -0,0 +1,32 @@
<!DOCTYPE html>
<html lang="ko"><head>
<meta charset="UTF-8">
<title>loading</title>
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'
fonts.googleapis.com; font-src 'self' fonts.gstatic.com">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<style>
body { margin-top: 100px; background-color: #3f51b5; color: #fff; text-align:center; }
h1 {
font: 2em 'Roboto', sans-serif;
margin-bottom: 40px;
}
#loading {
display: inline-block;
width: 50px;
height: 50px;
border: 3px solid rgba(255,255,255,.3);
border-radius: 50%;
border-top-color: #fff;
animation: spin 1s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg);}
}
</style>
<body>
<h1>Loading...</h1>
<div id="loading"></div>
</body>
</html>