From a5f8e34ee6d4534447c92898ea0950102aa574e1 Mon Sep 17 00:00:00 2001 From: Cutls Date: Sat, 15 Jun 2019 18:52:28 +0900 Subject: [PATCH] Fix: 'about' preload #86 --- app/about.html | 6 +++--- app/js/platform/first-not-view.js | 2 -- app/js/platform/preload.js | 2 +- app/main.js | 6 +++--- app/main/dl.js | 9 ++++++--- app/main/language.js | 5 ++++- app/main/system.js | 18 ++++++++++++------ 7 files changed, 29 insertions(+), 19 deletions(-) diff --git a/app/about.html b/app/about.html index c2814fc0..3a88f050 100644 --- a/app/about.html +++ b/app/about.html @@ -107,9 +107,9 @@ postMessage(["sendSinmpleIpc", "aboutData"], "*") function renderAbout(args) { $("#now").text(localStorage.getItem("ver")); - $("#node").text(args.version); - $("#chrome").text(args.versions.chrome); - $("#electron").text(args.versions.electron); + $("#node").text(args[0]); + $("#chrome").text(args[1]); + $("#electron").text(args[2]); } if (location.search) { var m = location.search.match(/\?ver=([a-zA-Z-0-9.]+)/); diff --git a/app/js/platform/first-not-view.js b/app/js/platform/first-not-view.js index 3e544c99..15bc7f06 100644 --- a/app/js/platform/first-not-view.js +++ b/app/js/platform/first-not-view.js @@ -1,3 +1 @@ //jQuery読む -window.jQuery = window.$ = require('./js/common/jquery.js'); -var Hammer = require('./js/common/hammer.min.js'); \ No newline at end of file diff --git a/app/js/platform/preload.js b/app/js/platform/preload.js index 3585538b..78045616 100644 --- a/app/js/platform/preload.js +++ b/app/js/platform/preload.js @@ -244,7 +244,7 @@ ipc.on('mess', function (event, arg) { updateMess(arg) }) //about.html -ipc.on('aboutData', function (event, arg) { +ipc.on('aboutDataRender', function (event, arg) { renderAbout(arg) }) var webviewDom = document.getElementById('webview'); diff --git a/app/main.js b/app/main.js index 57b237e8..1ef8ceb3 100644 --- a/app/main.js +++ b/app/main.js @@ -1,4 +1,4 @@ - +var dirname = __dirname; var dir = 'file://' + __dirname; var base = dir + '/view/'; // Electronのモジュール @@ -179,13 +179,13 @@ function createWindow() { //CSS css.css(mainWindow); //アップデータとダウンロード - dl.dl(mainWindow, lang_path, base); + dl.dl(mainWindow, lang_path, base, dirname); //画像選択と画像処理 img.img(mainWindow, dir); //NowPlaying np.TheDeskNowPlaying(mainWindow); //その他system - systemFunc.system(mainWindow, dir, lang); + systemFunc.system(mainWindow, dir, lang, dirname); } // Electronの初期化完了後に実行 app.on('ready', createWindow); diff --git a/app/main/dl.js b/app/main/dl.js index 0e2ea1b1..0601a452 100644 --- a/app/main/dl.js +++ b/app/main/dl.js @@ -1,4 +1,4 @@ -function dl(mainWindow, lang_path, base) { +function dl(mainWindow, lang_path, base, dirname) { const electron = require("electron"); const shell = electron.shell; const fs = require("fs"); @@ -16,7 +16,10 @@ function dl(mainWindow, lang_path, base) { if (platform != "others") { updatewin = new BrowserWindow({ webPreferences: { - nodeIntegration: true + webviewTag: false, + nodeIntegration: false, + contextIsolation: true, + preload: "../js/platform/preload.js" }, width: 600, height: 400, @@ -35,7 +38,7 @@ function dl(mainWindow, lang_path, base) { }) //アプデDL ipc.on('download-btn', (e, args) => { - function dl(url, file, dir,e) { + function dl(url, file, dir, e) { e.sender.webContents.send('mess', "ダウンロードを開始します。"); const opts = { diff --git a/app/main/language.js b/app/main/language.js index 843ecd30..8bc592cf 100644 --- a/app/main/language.js +++ b/app/main/language.js @@ -73,7 +73,10 @@ function templete(lang, mainWindow, packaged, dir) { var ver = app.getVersion() var window = new BrowserWindow({ webPreferences: { - nodeIntegration:true + webviewTag: false, + nodeIntegration: false, + contextIsolation: true, + preload: "../js/platform/preload.js" }, width: 300, height: 460, "transparent": false, // ウィンドウの背景を透過 diff --git a/app/main/system.js b/app/main/system.js index 86c4efa4..4290b551 100644 --- a/app/main/system.js +++ b/app/main/system.js @@ -1,4 +1,4 @@ -function system(mainWindow, dir, lang) { +function system(mainWindow, dir, lang, dirname) { const electron = require("electron"); const app = electron.app; const join = require('path').join; @@ -145,19 +145,22 @@ function system(mainWindow, dir, lang) { about(); }); ipc.on('aboutData', (e, args) => { - e.sender.webContents.send('aboutDataRender', process); + e.sender.webContents.send('aboutDataRender', [process.version, process.versions.chrome, process.versions.electron]); }); function about() { var ver = app.getVersion() var window = new BrowserWindow({ webPreferences: { - nodeIntegration: true + webviewTag: false, + nodeIntegration: false, + contextIsolation: false, + preload: join(dirname,"js", "platform", "preload.js") }, width: 300, height: 480, "transparent": false, // ウィンドウの背景を透過 - "frame": false, // 枠の無いウィンドウ - "resizable": false + "frame": true, // 枠の無いウィンドウ + "resizable": true }); window.loadURL(dir + '/about.html?ver=' + ver); return "true" @@ -182,7 +185,10 @@ function system(mainWindow, dir, lang) { } var nanowindow = new BrowserWindow({ webPreferences: { - nodeIntegration: true + webviewTag: false, + nodeIntegration: false, + contextIsolation: true, + preload: join(dirname,"js", "platform", "preload.js") }, width: 350, height: 200,