mirror of
https://github.com/NicolasConstant/sengi
synced 2025-01-31 10:44:55 +01:00
upgraded electron
This commit is contained in:
parent
6f0c949a91
commit
939c59655f
@ -44,4 +44,4 @@ before_script:
|
||||
- sleep 3
|
||||
|
||||
script:
|
||||
- npm run dist
|
||||
- npm run travis
|
@ -1,8 +1,8 @@
|
||||
const { app, Menu, server, BrowserWindow, shell } = require("electron");
|
||||
const path = require("path");
|
||||
const url = require("url");
|
||||
const http = require("http");
|
||||
const fs = require("fs");
|
||||
const { app, Menu, BrowserWindow, shell } = require("electron"); //server,
|
||||
// const path = require("path");
|
||||
// const url = require("url");
|
||||
// const http = require("http");
|
||||
// const fs = require("fs");
|
||||
|
||||
// Keep a global reference of the window object, if you don't, the window will
|
||||
// be closed automatically when the JavaScript object is garbage collected.
|
||||
@ -14,15 +14,23 @@ function createWindow() {
|
||||
width: 377,
|
||||
height: 800,
|
||||
title: "Sengi",
|
||||
backgroundColor: "#FFF",
|
||||
useContentSize: true
|
||||
backgroundColor: "#131925",
|
||||
useContentSize: true,
|
||||
webPreferences: {
|
||||
contextIsolation: true,
|
||||
nodeIntegration: false,
|
||||
nodeIntegrationInWorker: false
|
||||
}
|
||||
});
|
||||
|
||||
win.setAutoHideMenuBar(true);
|
||||
win.setMenuBarVisibility(false);
|
||||
|
||||
var server = http.createServer(requestHandler).listen(9527);
|
||||
const sengiUrl = "http://localhost:9527";
|
||||
//var server = http.createServer(requestHandler).listen(9527);
|
||||
//const sengiUrl = "http://localhost:9527";
|
||||
|
||||
const sengiUrl = "https://sengi.nicolas-constant.com";
|
||||
|
||||
win.loadURL(sengiUrl);
|
||||
|
||||
const template = [
|
||||
@ -157,39 +165,39 @@ function createWindow() {
|
||||
});
|
||||
}
|
||||
|
||||
function requestHandler(req, res) {
|
||||
var file = req.url == "/" ? "/index.html" : req.url,
|
||||
root = __dirname + "/dist",
|
||||
page404 = root + "/404.html";
|
||||
// function requestHandler(req, res) {
|
||||
// var file = req.url == "/" ? "/index.html" : req.url,
|
||||
// root = __dirname + "/dist",
|
||||
// page404 = root + "/404.html";
|
||||
|
||||
if (file.includes("register") || file.includes("home")) file = "/index.html";
|
||||
// if (file.includes("register") || file.includes("home")) file = "/index.html";
|
||||
|
||||
getFile(root + file, res, page404);
|
||||
}
|
||||
// getFile(root + file, res, page404);
|
||||
// }
|
||||
|
||||
function getFile(filePath, res, page404) {
|
||||
console.warn(`filePath: ${filePath}`);
|
||||
fs.exists(filePath, function (exists) {
|
||||
if (exists) {
|
||||
fs.readFile(filePath, function (err, contents) {
|
||||
if (!err) {
|
||||
res.end(contents);
|
||||
} else {
|
||||
console.dir(err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fs.readFile(page404, function (err, contents) {
|
||||
if (!err) {
|
||||
res.writeHead(404, { "Content-Type": "text/html" });
|
||||
res.end(contents);
|
||||
} else {
|
||||
console.dir(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// function getFile(filePath, res, page404) {
|
||||
// console.warn(`filePath: ${filePath}`);
|
||||
// fs.exists(filePath, function (exists) {
|
||||
// if (exists) {
|
||||
// fs.readFile(filePath, function (err, contents) {
|
||||
// if (!err) {
|
||||
// res.end(contents);
|
||||
// } else {
|
||||
// console.dir(err);
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// fs.readFile(page404, function (err, contents) {
|
||||
// if (!err) {
|
||||
// res.writeHead(404, { "Content-Type": "text/html" });
|
||||
// res.end(contents);
|
||||
// } else {
|
||||
// console.dir(err);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
app.commandLine.appendSwitch("force-color-profile", "srgb");
|
||||
|
||||
|
627
package-lock.json
generated
627
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -12,7 +12,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/NicolasConstant/sengi.git"
|
||||
},
|
||||
"scripts": {
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"start-mem": "node --max_old_space_size=5048 ./node_modules/@angular/cli/bin/ng serve",
|
||||
@ -23,7 +23,9 @@
|
||||
"e2e": "ng e2e",
|
||||
"electron": "ng build --prod && electron .",
|
||||
"electron-debug": "ng build && electron .",
|
||||
"dist": "npm run build && electron-builder --publish onTagOrDraft"
|
||||
"electron-test": "electron .",
|
||||
"dist": "npm run build && electron-builder --publish onTagOrDraft",
|
||||
"travis": "electron-builder --publish onTagOrDraft"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
@ -68,7 +70,7 @@
|
||||
"@types/jasminewd2": "~2.0.3",
|
||||
"@types/node": "~8.9.4",
|
||||
"codelyzer": "~4.2.1",
|
||||
"electron": "^4.0.6",
|
||||
"electron": "^8.0.2",
|
||||
"electron-builder": "^20.39.0",
|
||||
"jasmine-core": "~2.99.1",
|
||||
"jasmine-spec-reporter": "~4.2.1",
|
||||
|
Loading…
x
Reference in New Issue
Block a user