From 861ee3250d16ffc9e35fbda8e468569c13bf307d Mon Sep 17 00:00:00 2001 From: Cutls Date: Sat, 15 Jun 2019 01:05:53 +0900 Subject: [PATCH] Remove: node in manager.js #86 --- app/js/login/manager.js | 15 +++------------ app/js/platform/preload.js | 9 +++++---- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/app/js/login/manager.js b/app/js/login/manager.js index 54389c1d..872b836e 100644 --- a/app/js/login/manager.js +++ b/app/js/login/manager.js @@ -310,15 +310,9 @@ function login(url) { localStorage.setItem("client_secret", json["client_secret"]); $("#auth").show(); $("#add").hide(); - const { - shell - } = require('electron'); - - shell.openExternal(auth); - var electron = require("electron"); - var ipc = electron.ipcRenderer; + postMessage(["openUrl", auth], "*") if ($('#linux:checked').val() == "on") { } else { - ipc.send('quit', 'go'); + postMessage(["sendSinmpleIpc", "quit"], "*") } } } @@ -407,16 +401,13 @@ function misskeyAuth(url, mkc) { httpreq.onreadystatechange = function () { if (httpreq.readyState === 4) { var json = httpreq.response; - const { - shell - } = require('electron'); var token = json.token; $("#auth").show(); $("#code").val(token); $("#add").hide(); $("#misskey").prop("checked", false); localStorage.setItem("domain_tmp", url); - shell.openExternal(json.url); + postMessage(["openUrl", json.url], "*") } } } diff --git a/app/js/platform/preload.js b/app/js/platform/preload.js index 231a3882..4fba29b3 100644 --- a/app/js/platform/preload.js +++ b/app/js/platform/preload.js @@ -1,9 +1,10 @@ var electron = require("electron"); +const shell = electron.shell; var ipc = electron.ipcRenderer; onmessage = function (e) { if (e.data[0] == "openUrl") { - urls = url.match(/https?:\/\/(.+)/); - if(urls){ + urls = e.data[1].match(/https?:\/\/(.+)/); + if (urls) { shell.openExternal(e.data[1]); } } else if (e.data[0] == "sendSinmpleIpc") { @@ -15,10 +16,10 @@ onmessage = function (e) { //version.js ipc.send("getPlatform", "") ipc.on('platform', function (event, arg) { - localStorage.setItem("platform",arg) + localStorage.setItem("platform", arg) }) ipc.on('winstore', function (event, arg) { - localStorage.setItem("winstore",arg) + localStorage.setItem("winstore", arg) }) ipc.on('reload', function (event, arg) {