WIP: useragent
This commit is contained in:
parent
bb08ec2435
commit
3e2d40d248
|
@ -1,182 +1,188 @@
|
|||
var electron = require("electron");
|
||||
const shell = electron.shell;
|
||||
var ipc = electron.ipcRenderer;
|
||||
onmessage = function (e) {
|
||||
if (e.data[0] == "openUrl") {
|
||||
urls = e.data[1].match(/https?:\/\/(.+)/);
|
||||
if (urls) {
|
||||
shell.openExternal(e.data[1]);
|
||||
}
|
||||
} else if (e.data[0] == "sendSinmpleIpc") {
|
||||
ipc.send(e.data[1], "")
|
||||
} else if (e.data[0] == "dialogStore") {
|
||||
ipc.send("dialogStore", e.data[1])
|
||||
} else if (e.data[0] == "bmpImage") {
|
||||
ipc.send('bmp-image', e.data[1]);
|
||||
} else if (e.data[0] == "dialogCW") {
|
||||
ipc.send("dialogCW", e.data[1])
|
||||
} else if (e.data[0] == "nativeNotf") {
|
||||
console.log(e.data[1])
|
||||
ipc.send('native-notf', e.data[1]);
|
||||
} else if (e.data[0] == "dialogClient") {
|
||||
ipc.send("dialogClient", e.data[1])
|
||||
} else if (e.data[0] == "generalDL") {
|
||||
ipc.send('general-dl', e.data[1]);
|
||||
} else if (e.data[0] == "openFinder") {
|
||||
ipc.send('open-finder', e.data[1]);
|
||||
} else if (e.data[0] == "columnDel") {
|
||||
ipc.send('column-del', e.data[1]);
|
||||
} else if (e.data[0] == "lang") {
|
||||
ipc.send('lang', e.data[1]);
|
||||
} else if (e.data[0] == "exportSettings") {
|
||||
ipc.send('exportSettings', e.data[1]);
|
||||
} else if (e.data[0] == "exportSettingsCoreComplete") {
|
||||
ipc.send('export', e.data[1]);
|
||||
} else if (e.data[0] == "importSettings") {
|
||||
ipc.send('importSettings', e.data[1]);
|
||||
} else if (e.data[0] == "customSound") {
|
||||
ipc.send('customSound', e.data[1]);
|
||||
} else if (e.data[0] == "themeJsonDelete") {
|
||||
ipc.send('theme-json-delete', e.data[1]);
|
||||
} else if (e.data[0] == "themeJsonCreate") {
|
||||
ipc.send('theme-json-create', e.data[1]);
|
||||
} else if (e.data[0] == "themeJsonRequest") {
|
||||
ipc.send('theme-json-request', e.data[1]);
|
||||
} else if (e.data[0] == "ha") {
|
||||
ipc.send('ha', e.data[1]);
|
||||
} else if (e.data[0] == "aboutData") {
|
||||
ipc.send('aboutData', "");
|
||||
} else if (e.data[0] == "itunes") {
|
||||
console.log("NowPlaying")
|
||||
ipc.send("itunes", e.data[1])
|
||||
} else if (e.data[0] == "themeCSSRequest") {
|
||||
ipc.send('theme-css-request', e.data[1]);
|
||||
} else if (e.data[0] == "customCSSRequest") {
|
||||
ipc.send('custom-css-request', e.data[1]);
|
||||
} else if (e.data[0] == "downloadButton") {
|
||||
ipc.send('download-btn', e.data[1]);
|
||||
} else if (e.data[0] == "nano") {
|
||||
ipc.send('nano', null);
|
||||
} else if (e.data[0] == "asReadComp") {
|
||||
ipc.send('sendMarkersComplete', null);
|
||||
} else if (e.data[0] == "copy") {
|
||||
ipc.send('copy', e.data[1]);
|
||||
}
|
||||
}
|
||||
onmessage = function(e) {
|
||||
if (e.data[0] == "openUrl") {
|
||||
urls = e.data[1].match(/https?:\/\/(.+)/);
|
||||
if (urls) {
|
||||
shell.openExternal(e.data[1]);
|
||||
}
|
||||
} else if (e.data[0] == "sendSinmpleIpc") {
|
||||
ipc.send(e.data[1], "");
|
||||
} else if (e.data[0] == "dialogStore") {
|
||||
ipc.send("dialogStore", e.data[1]);
|
||||
} else if (e.data[0] == "bmpImage") {
|
||||
ipc.send("bmp-image", e.data[1]);
|
||||
} else if (e.data[0] == "dialogCW") {
|
||||
ipc.send("dialogCW", e.data[1]);
|
||||
} else if (e.data[0] == "nativeNotf") {
|
||||
console.log(e.data[1]);
|
||||
ipc.send("native-notf", e.data[1]);
|
||||
} else if (e.data[0] == "dialogClient") {
|
||||
ipc.send("dialogClient", e.data[1]);
|
||||
} else if (e.data[0] == "generalDL") {
|
||||
ipc.send("general-dl", e.data[1]);
|
||||
} else if (e.data[0] == "openFinder") {
|
||||
ipc.send("open-finder", e.data[1]);
|
||||
} else if (e.data[0] == "columnDel") {
|
||||
ipc.send("column-del", e.data[1]);
|
||||
} else if (e.data[0] == "lang") {
|
||||
ipc.send("lang", e.data[1]);
|
||||
} else if (e.data[0] == "exportSettings") {
|
||||
ipc.send("exportSettings", e.data[1]);
|
||||
} else if (e.data[0] == "exportSettingsCoreComplete") {
|
||||
ipc.send("export", e.data[1]);
|
||||
} else if (e.data[0] == "importSettings") {
|
||||
ipc.send("importSettings", e.data[1]);
|
||||
} else if (e.data[0] == "customSound") {
|
||||
ipc.send("customSound", e.data[1]);
|
||||
} else if (e.data[0] == "themeJsonDelete") {
|
||||
ipc.send("theme-json-delete", e.data[1]);
|
||||
} else if (e.data[0] == "themeJsonCreate") {
|
||||
ipc.send("theme-json-create", e.data[1]);
|
||||
} else if (e.data[0] == "themeJsonRequest") {
|
||||
ipc.send("theme-json-request", e.data[1]);
|
||||
} else if (e.data[0] == "ha") {
|
||||
ipc.send("ha", e.data[1]);
|
||||
} else if (e.data[0] == "ua") {
|
||||
ipc.send("ua", e.data[1]);
|
||||
} else if (e.data[0] == "aboutData") {
|
||||
ipc.send("aboutData", "");
|
||||
} else if (e.data[0] == "itunes") {
|
||||
console.log("NowPlaying");
|
||||
ipc.send("itunes", e.data[1]);
|
||||
} else if (e.data[0] == "themeCSSRequest") {
|
||||
ipc.send("theme-css-request", e.data[1]);
|
||||
} else if (e.data[0] == "customCSSRequest") {
|
||||
ipc.send("custom-css-request", e.data[1]);
|
||||
} else if (e.data[0] == "downloadButton") {
|
||||
ipc.send("download-btn", e.data[1]);
|
||||
} else if (e.data[0] == "nano") {
|
||||
ipc.send("nano", null);
|
||||
} else if (e.data[0] == "asReadComp") {
|
||||
ipc.send("sendMarkersComplete", null);
|
||||
} else if (e.data[0] == "copy") {
|
||||
ipc.send("copy", e.data[1]);
|
||||
}
|
||||
};
|
||||
//version.js
|
||||
ipc.send("getPlatform", "")
|
||||
ipc.on('platform', function (event, args) {
|
||||
localStorage.setItem("platform", args[0])
|
||||
localStorage.setItem("bit", args[1])
|
||||
localStorage.setItem("about", JSON.stringify([args[2], args[3], args[4], args[5]]))
|
||||
})
|
||||
ipc.send("getPlatform", "");
|
||||
ipc.on("platform", function(event, args) {
|
||||
localStorage.setItem("platform", args[0]);
|
||||
localStorage.setItem("bit", args[1]);
|
||||
localStorage.setItem("about", JSON.stringify([args[2], args[3], args[4], args[5]]));
|
||||
});
|
||||
|
||||
ipc.on('reload', function (event, arg) {
|
||||
location.reload();
|
||||
})
|
||||
ipc.on("reload", function(event, arg) {
|
||||
location.reload();
|
||||
});
|
||||
//Native Notf
|
||||
ipc.on('shownotf', function (event, args) {
|
||||
if (args["type"] == "toot") {
|
||||
postMessage(["details", [id, acct_id]], "*")
|
||||
} else if (args["type"] == "userdata") {
|
||||
postMessage(["udg", [user, acct_id]], "*")
|
||||
}
|
||||
})
|
||||
ipc.on("shownotf", function(event, args) {
|
||||
if (args["type"] == "toot") {
|
||||
postMessage(["details", [id, acct_id]], "*");
|
||||
} else if (args["type"] == "userdata") {
|
||||
postMessage(["udg", [user, acct_id]], "*");
|
||||
}
|
||||
});
|
||||
|
||||
//first.js
|
||||
ipc.on('custom-css-response', function (event, arg) {
|
||||
if (arg == "") { return false; }
|
||||
var styleNode = document.createElement("style");
|
||||
styleNode.setAttribute("type", "text/css")
|
||||
ipc.on("custom-css-response", function(event, arg) {
|
||||
if (arg == "") {
|
||||
return false;
|
||||
}
|
||||
var styleNode = document.createElement("style");
|
||||
styleNode.setAttribute("type", "text/css");
|
||||
|
||||
var content = document.createTextNode(arg)
|
||||
styleNode.append(content)
|
||||
document.getElementsByTagName("head")[0].append(styleNode)
|
||||
})
|
||||
ipc.on('theme-css-response', function (event, arg) {
|
||||
if (arg == "") { return false; }
|
||||
var styleNode = document.createElement("style");
|
||||
styleNode.setAttribute("type", "text/css")
|
||||
var content = document.createTextNode(arg);
|
||||
styleNode.append(content);
|
||||
document.getElementsByTagName("head")[0].append(styleNode);
|
||||
});
|
||||
ipc.on("theme-css-response", function(event, arg) {
|
||||
if (arg == "") {
|
||||
return false;
|
||||
}
|
||||
var styleNode = document.createElement("style");
|
||||
styleNode.setAttribute("type", "text/css");
|
||||
|
||||
var content = document.createTextNode(arg)
|
||||
styleNode.append(content)
|
||||
document.getElementsByTagName("head")[0].append(styleNode)
|
||||
})
|
||||
var content = document.createTextNode(arg);
|
||||
styleNode.append(content);
|
||||
document.getElementsByTagName("head")[0].append(styleNode);
|
||||
});
|
||||
//img.js
|
||||
ipc.on('bmp-img-comp', function (event, b64) {
|
||||
postMessage(["media", [b64[0], "image/png", b64[1]]], "*")
|
||||
ipc.on("bmp-img-comp", function(event, b64) {
|
||||
postMessage(["media", [b64[0], "image/png", b64[1]]], "*");
|
||||
});
|
||||
//ui,img.js
|
||||
ipc.on('general-dl-prog', function (event, arg) {
|
||||
console.log("Progress: " + arg);
|
||||
})
|
||||
ipc.on('general-dl-message', function (event, arg) {
|
||||
var argC = arg.replace(/\\/g, "\\\\") + "\\\\.";
|
||||
console.log("saved")
|
||||
postMessage(["toastSaved", [arg, argC]], "*")
|
||||
})
|
||||
ipc.on("general-dl-prog", function(event, arg) {
|
||||
console.log("Progress: " + arg);
|
||||
});
|
||||
ipc.on("general-dl-message", function(event, arg) {
|
||||
var argC = arg.replace(/\\/g, "\\\\") + "\\\\.";
|
||||
console.log("saved");
|
||||
postMessage(["toastSaved", [arg, argC]], "*");
|
||||
});
|
||||
//setting.js
|
||||
ipc.on('langres', function (event, arg) {
|
||||
location.href = "../" + arg + "/setting.html"
|
||||
ipc.on("langres", function(event, arg) {
|
||||
location.href = "../" + arg + "/setting.html";
|
||||
});
|
||||
ipc.on('exportSettingsFile', function (event, arg) {
|
||||
postMessage(["exportSettingsCore", arg], "*")
|
||||
ipc.on("exportSettingsFile", function(event, arg) {
|
||||
postMessage(["exportSettingsCore", arg], "*");
|
||||
});
|
||||
ipc.on('exportAllComplete', function (event, arg) {
|
||||
postMessage(["alert", "Complete"], "*")
|
||||
ipc.on("exportAllComplete", function(event, arg) {
|
||||
postMessage(["alert", "Complete"], "*");
|
||||
});
|
||||
ipc.on('config', function (event, arg) {
|
||||
postMessage(["importSettingsCore", arg], "*")
|
||||
ipc.on("config", function(event, arg) {
|
||||
postMessage(["importSettingsCore", arg], "*");
|
||||
});
|
||||
ipc.on('savefolder', function (event, arg) {
|
||||
localStorage.setItem("savefolder", arg);
|
||||
ipc.on("savefolder", function(event, arg) {
|
||||
localStorage.setItem("savefolder", arg);
|
||||
});
|
||||
ipc.on('font-list', function (event, arg) {
|
||||
postMessage(["fontList", arg], "*")
|
||||
ipc.on("font-list", function(event, arg) {
|
||||
postMessage(["fontList", arg], "*");
|
||||
});
|
||||
ipc.on('customSoundRender', function (event, args) {
|
||||
postMessage(["customSoundSave", [args[0], args[1]]], "*")
|
||||
ipc.on("customSoundRender", function(event, args) {
|
||||
postMessage(["customSoundSave", [args[0], args[1]]], "*");
|
||||
});
|
||||
ipc.on('theme-json-list-response', function (event, args) {
|
||||
postMessage(["ctLoadCore", args], "*")
|
||||
ipc.on("theme-json-list-response", function(event, args) {
|
||||
postMessage(["ctLoadCore", args], "*");
|
||||
});
|
||||
ipc.on('theme-json-delete-complete', function (event, args) {
|
||||
postMessage(["ctLoad", ""], "*")
|
||||
ipc.on("theme-json-delete-complete", function(event, args) {
|
||||
postMessage(["ctLoad", ""], "*");
|
||||
});
|
||||
ipc.on('theme-json-response', function (event, args) {
|
||||
postMessage(["customConnect", args], "*")
|
||||
ipc.on("theme-json-response", function(event, args) {
|
||||
postMessage(["customConnect", args], "*");
|
||||
});
|
||||
ipc.on('theme-json-create-complete', function (event, args) {
|
||||
postMessage(["clearCustomImport", ""], "*")
|
||||
postMessage(["ctLoad", ""], "*")
|
||||
ipc.on("theme-json-create-complete", function(event, args) {
|
||||
postMessage(["clearCustomImport", ""], "*");
|
||||
postMessage(["ctLoad", ""], "*");
|
||||
});
|
||||
//spotify.js
|
||||
ipc.on('itunes-np', function (event, arg) {
|
||||
postMessage(["npCore", arg], "*")
|
||||
})
|
||||
ipc.on("itunes-np", function(event, arg) {
|
||||
postMessage(["npCore", arg], "*");
|
||||
});
|
||||
//tips.js
|
||||
ipc.on('memory', function (event, arg) {
|
||||
var use = arg[0];
|
||||
var cpu = arg[1];
|
||||
var total = arg[2]
|
||||
postMessage(["renderMem", [use, cpu, total]], "*")
|
||||
})
|
||||
ipc.on("memory", function(event, arg) {
|
||||
var use = arg[0];
|
||||
var cpu = arg[1];
|
||||
var total = arg[2];
|
||||
postMessage(["renderMem", [use, cpu, total]], "*");
|
||||
});
|
||||
//update.html
|
||||
ipc.on('prog', function (event, arg) {
|
||||
postMessage(["updateProg", arg], "*")
|
||||
})
|
||||
ipc.on('mess', function (event, arg) {
|
||||
postMessage(["updateMess", arg], "*")
|
||||
})
|
||||
ipc.on('asRead', function (event, arg) {
|
||||
postMessage(["asRead", ""], "*")
|
||||
})
|
||||
ipc.on('asReadEnd', function (event, arg) {
|
||||
postMessage(["asReadEnd", ""], "*")
|
||||
})
|
||||
var webviewDom = document.getElementById('webview');
|
||||
ipc.on("prog", function(event, arg) {
|
||||
postMessage(["updateProg", arg], "*");
|
||||
});
|
||||
ipc.on("mess", function(event, arg) {
|
||||
postMessage(["updateMess", arg], "*");
|
||||
});
|
||||
ipc.on("asRead", function(event, arg) {
|
||||
postMessage(["asRead", ""], "*");
|
||||
});
|
||||
ipc.on("asReadEnd", function(event, arg) {
|
||||
postMessage(["asReadEnd", ""], "*");
|
||||
});
|
||||
var webviewDom = document.getElementById("webview");
|
||||
if (webviewDom) {
|
||||
webviewDom.addEventListener('new-window', function (e) {
|
||||
shell.openExternal(e.url);
|
||||
});
|
||||
webviewDom.addEventListener("new-window", function(e) {
|
||||
shell.openExternal(e.url);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ var envView = new Vue({
|
|||
if (ls == "ha") {
|
||||
hardwareAcceleration(val)
|
||||
}
|
||||
if (ls == "ua_setting") {
|
||||
useragent(val)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -693,6 +696,9 @@ function clearCustomImport() {
|
|||
function hardwareAcceleration(had) {
|
||||
postMessage(["ha", had], "*")
|
||||
}
|
||||
function useragent(val){
|
||||
postMessage(["ua", val], "*")
|
||||
}
|
||||
function customSound(key) {
|
||||
postMessage(["customSound", key], "*")
|
||||
}
|
||||
|
|
238
app/main.js
238
app/main.js
|
@ -1,17 +1,17 @@
|
|||
var dirname = __dirname;
|
||||
var dir = 'file://' + __dirname;
|
||||
var base = dir + '/view/';
|
||||
var dir = "file://" + __dirname;
|
||||
var base = dir + "/view/";
|
||||
// Electronのモジュール
|
||||
const electron = require("electron");
|
||||
const fs = require("fs");
|
||||
const language = require('./main/language.js');
|
||||
const css = require('./main/css.js');
|
||||
const dl = require('./main/dl.js');
|
||||
const img = require('./main/img.js');
|
||||
const np = require('./main/np.js');
|
||||
const systemFunc = require('./main/system.js');
|
||||
const Menu = electron.Menu
|
||||
const join = require('path').join;
|
||||
const language = require("./main/language.js");
|
||||
const css = require("./main/css.js");
|
||||
const dl = require("./main/dl.js");
|
||||
const img = require("./main/img.js");
|
||||
const np = require("./main/np.js");
|
||||
const systemFunc = require("./main/system.js");
|
||||
const Menu = electron.Menu;
|
||||
const join = require("path").join;
|
||||
|
||||
// アプリケーションをコントロールするモジュール
|
||||
const app = electron.app;
|
||||
|
@ -21,56 +21,43 @@ const BrowserWindow = electron.BrowserWindow;
|
|||
let mainWindow;
|
||||
|
||||
// アプリが多重起動しないようにする
|
||||
const gotTheLock = app.requestSingleInstanceLock()
|
||||
const gotTheLock = app.requestSingleInstanceLock();
|
||||
|
||||
if (!gotTheLock) {
|
||||
app.quit()
|
||||
app.quit();
|
||||
} else {
|
||||
app.on('second-instance', () => {
|
||||
app.on("second-instance", () => {
|
||||
// 多重起動を試みた場合、既に存在するウィンドウにフォーカスを移す
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
if (mainWindow) {
|
||||
if (mainWindow.isMinimized()) mainWindow.restore()
|
||||
mainWindow.focus()
|
||||
if (mainWindow.isMinimized()) mainWindow.restore();
|
||||
mainWindow.focus();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if (process.argv.indexOf("--dev") === -1) {
|
||||
var packaged = true;
|
||||
} else {
|
||||
var packaged = false;
|
||||
console.log(
|
||||
"||\\\\\\ \n" +
|
||||
"|||| \\\\\\\\ \n" +
|
||||
"|||| \\\\\\\\ \n" +
|
||||
"|||| Am I a \\\\\\\\ \n" +
|
||||
"|||| cat? ^ ^ \\\\\\\\\\ _____ _ ____ _ \n" +
|
||||
"|||| (.-.) \\\\\\\\\\ |_ _| |__ ___| _ \\ ___ ___| | __\n" +
|
||||
"|||| ___> ) ||||| | | | '_ \\ / _ \\ | | |/ _ \\/ __| |/ /\n" +
|
||||
"|||| < _ _) ////// | | | | | | __/ |_| | __/\__ \\ < \n" +
|
||||
"|||| |_||_| ///// |_| |_| |_|\\___|____/ \\___||___/_|\\_\\ \n" +
|
||||
"|||| ///// \n" +
|
||||
"|||| /////\n" +
|
||||
"|||| /////\n" +
|
||||
"||||//////"
|
||||
)
|
||||
console.log("Welcome!")
|
||||
console.log("||\\\\\\ \n" + "|||| \\\\\\\\ \n" + "|||| \\\\\\\\ \n" + "|||| Am I a \\\\\\\\ \n" + "|||| cat? ^ ^ \\\\\\\\\\ _____ _ ____ _ \n" + "|||| (.-.) \\\\\\\\\\ |_ _| |__ ___| _ \\ ___ ___| | __\n" + "|||| ___> ) ||||| | | | '_ \\ / _ \\ | | |/ _ \\/ __| |/ /\n" + "|||| < _ _) ////// | | | | | | __/ |_| | __/__ \\ < \n" + "|||| |_||_| ///// |_| |_| |_|\\___|____/ \\___||___/_|\\_\\ \n" + "|||| ///// \n" + "|||| /////\n" + "|||| /////\n" + "||||//////");
|
||||
console.log("Welcome!");
|
||||
}
|
||||
var info_path = join(app.getPath("userData"), "window-size.json");
|
||||
var max_info_path = join(app.getPath("userData"), "max-window-size.json");
|
||||
var lang_path = join(app.getPath("userData"), "language");
|
||||
var ha_path = join(app.getPath("userData"), "hardwareAcceleration");
|
||||
var ua_path = join(app.getPath("userData"), "useragent");
|
||||
try {
|
||||
fs.readFileSync(ha_path, 'utf8');
|
||||
app.disableHardwareAcceleration()
|
||||
fs.readFileSync(ha_path, "utf8");
|
||||
app.disableHardwareAcceleration();
|
||||
if (!packaged) console.log("disabled: Hardware Acceleration");
|
||||
} catch{
|
||||
} catch {
|
||||
if (!packaged) console.log("enabled: Hardware Acceleration");
|
||||
}
|
||||
var window_size;
|
||||
try {
|
||||
window_size = JSON.parse(fs.readFileSync(info_path, 'utf8'));
|
||||
window_size = JSON.parse(fs.readFileSync(info_path, "utf8"));
|
||||
} catch (e) {
|
||||
window_size = {
|
||||
width: 1000,
|
||||
|
@ -79,33 +66,32 @@ try {
|
|||
}
|
||||
var max_window_size;
|
||||
try {
|
||||
max_window_size = JSON.parse(fs.readFileSync(max_info_path, 'utf8'));
|
||||
max_window_size = JSON.parse(fs.readFileSync(max_info_path, "utf8"));
|
||||
} catch (e) {
|
||||
max_window_size = {
|
||||
width: "string",
|
||||
height: "string",
|
||||
x: "string",
|
||||
y: "string"
|
||||
|
||||
}; // デフォルトバリュー
|
||||
}
|
||||
function isFile(file) {
|
||||
try {
|
||||
fs.statSync(file);
|
||||
return true
|
||||
return true;
|
||||
} catch (err) {
|
||||
if (err.code === 'ENOENT') return false
|
||||
if (err.code === "ENOENT") return false;
|
||||
}
|
||||
}
|
||||
// 全てのウィンドウが閉じたら終了
|
||||
app.on('window-all-closed', function () {
|
||||
electron.session.defaultSession.clearCache(() => { })
|
||||
app.on("window-all-closed", function() {
|
||||
electron.session.defaultSession.clearCache(() => {});
|
||||
app.quit();
|
||||
});
|
||||
|
||||
function createWindow() {
|
||||
if (isFile(lang_path)) {
|
||||
var lang = fs.readFileSync(lang_path, 'utf8');
|
||||
var lang = fs.readFileSync(lang_path, "utf8");
|
||||
} else {
|
||||
var langs = app.getLocale();
|
||||
console.log(langs);
|
||||
|
@ -120,7 +106,7 @@ function createWindow() {
|
|||
} else {
|
||||
lang = "en";
|
||||
}
|
||||
fs.mkdir(app.getPath("userData"), function (err) {
|
||||
fs.mkdir(app.getPath("userData"), function(err) {
|
||||
fs.writeFileSync(lang_path, lang);
|
||||
});
|
||||
}
|
||||
|
@ -137,8 +123,13 @@ function createWindow() {
|
|||
contextIsolation: true,
|
||||
preload: join(__dirname, "js", "platform", "preload.js")
|
||||
},
|
||||
width: window_size.width, height: window_size.height, x: window_size.x, y: window_size.y, icon: __dirname + '/desk.png', show: false
|
||||
}
|
||||
width: window_size.width,
|
||||
height: window_size.height,
|
||||
x: window_size.x,
|
||||
y: window_size.y,
|
||||
icon: __dirname + "/desk.png",
|
||||
show: false
|
||||
};
|
||||
} else if (platform == "win32") {
|
||||
var arg = {
|
||||
webPreferences: {
|
||||
|
@ -147,8 +138,13 @@ function createWindow() {
|
|||
contextIsolation: true,
|
||||
preload: join(__dirname, "js", "platform", "preload.js")
|
||||
},
|
||||
width: window_size.width, height: window_size.height, x: window_size.x, y: window_size.y, simpleFullscreen: true, show: false
|
||||
}
|
||||
width: window_size.width,
|
||||
height: window_size.height,
|
||||
x: window_size.x,
|
||||
y: window_size.y,
|
||||
simpleFullscreen: true,
|
||||
show: false
|
||||
};
|
||||
} else if (platform == "darwin") {
|
||||
var arg = {
|
||||
webPreferences: {
|
||||
|
@ -157,25 +153,30 @@ function createWindow() {
|
|||
contextIsolation: true,
|
||||
preload: join(__dirname, "js", "platform", "preload.js")
|
||||
},
|
||||
width: window_size.width, height: window_size.height, x: window_size.x, y: window_size.y, simpleFullscreen: true, show: false
|
||||
}
|
||||
width: window_size.width,
|
||||
height: window_size.height,
|
||||
x: window_size.x,
|
||||
y: window_size.y,
|
||||
simpleFullscreen: true,
|
||||
show: false
|
||||
};
|
||||
}
|
||||
mainWindow = new BrowserWindow(arg);
|
||||
mainWindow.once('page-title-updated', () => {
|
||||
mainWindow.show()
|
||||
mainWindow.once("page-title-updated", () => {
|
||||
mainWindow.show();
|
||||
if (window_size.max) {
|
||||
mainWindow.maximize();
|
||||
}
|
||||
})
|
||||
});
|
||||
if (!packaged) mainWindow.toggleDevTools();
|
||||
electron.session.defaultSession.clearCache(() => { })
|
||||
electron.session.defaultSession.clearCache(() => {});
|
||||
if (process.argv) {
|
||||
if (process.argv[1]) {
|
||||
var m = process.argv[1].match(/([a-zA-Z0-9]+)\/\?[a-zA-Z-0-9]+=(.+)/);
|
||||
if (m) {
|
||||
var mode = m[1];
|
||||
var code = m[2];
|
||||
var plus = '?mode=' + mode + '&code=' + code;
|
||||
var plus = "?mode=" + mode + "&code=" + code;
|
||||
} else {
|
||||
var plus = "";
|
||||
}
|
||||
|
@ -185,56 +186,65 @@ function createWindow() {
|
|||
} else {
|
||||
var plus = "";
|
||||
}
|
||||
mainWindow.loadURL(base + lang + '/index.html' + plus);
|
||||
var ua;
|
||||
try {
|
||||
ua = fs.readFileSync(ua_path, "utf8");
|
||||
} catch (e) {
|
||||
//default UA Example:
|
||||
// Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) thedesk/18.11.3 Chrome/76.0.3809.146 Electron/6.0.12 Safari/537.36
|
||||
const crypto = require("crypto");
|
||||
const N = 100;
|
||||
var ua = "Mastodon client: "+crypto
|
||||
.randomBytes(N)
|
||||
.toString("base64")
|
||||
.substring(0, N);
|
||||
}
|
||||
mainWindow.loadURL(base + lang + "/index.html" + plus, { userAgent: ua });
|
||||
if (!window_size.x && !window_size.y) {
|
||||
mainWindow.center();
|
||||
}
|
||||
// ウィンドウが閉じられたらアプリも終了
|
||||
mainWindow.on('closed', function () {
|
||||
mainWindow.on("closed", function() {
|
||||
electron.ipcMain.removeAllListeners();
|
||||
mainWindow = null;
|
||||
});
|
||||
closeArg = false
|
||||
mainWindow.on('close', function (e, arg) {
|
||||
writePos(mainWindow)
|
||||
if(!closeArg){
|
||||
e.preventDefault()
|
||||
}
|
||||
const promise = new Promise(function (resolve) {
|
||||
mainWindow.webContents.send('asReadEnd', "")
|
||||
setTimeout(function () { resolve() }, 3000)
|
||||
})
|
||||
promise.then((function (response) {
|
||||
closeArg = true
|
||||
mainWindow.close()
|
||||
})
|
||||
);
|
||||
});
|
||||
electron.ipcMain.on('sendMarkersComplete', function (e, arg) {
|
||||
closeArg = true
|
||||
mainWindow.close()
|
||||
})
|
||||
function writePos(mainWindow){
|
||||
if (
|
||||
max_window_size.width == mainWindow.getBounds().width &&
|
||||
max_window_size.height == mainWindow.getBounds().height &&
|
||||
max_window_size.x == mainWindow.getBounds().x &&
|
||||
max_window_size.y == mainWindow.getBounds().y
|
||||
) {
|
||||
var size = { width: mainWindow.getBounds().width, height: mainWindow.getBounds().height, x: mainWindow.getBounds().x, y: mainWindow.getBounds().y, max: true }
|
||||
} else {
|
||||
var size = { width: mainWindow.getBounds().width, height: mainWindow.getBounds().height, x: mainWindow.getBounds().x, y: mainWindow.getBounds().y }
|
||||
closeArg = false;
|
||||
mainWindow.on("close", function(e, arg) {
|
||||
writePos(mainWindow);
|
||||
if (!closeArg) {
|
||||
e.preventDefault();
|
||||
}
|
||||
fs.writeFileSync(info_path, JSON.stringify(size))
|
||||
const promise = new Promise(function(resolve) {
|
||||
mainWindow.webContents.send("asReadEnd", "");
|
||||
setTimeout(function() {
|
||||
resolve();
|
||||
}, 3000);
|
||||
});
|
||||
promise.then(function(response) {
|
||||
closeArg = true;
|
||||
mainWindow.close();
|
||||
});
|
||||
});
|
||||
electron.ipcMain.on("sendMarkersComplete", function(e, arg) {
|
||||
closeArg = true;
|
||||
mainWindow.close();
|
||||
});
|
||||
function writePos(mainWindow) {
|
||||
if (max_window_size.width == mainWindow.getBounds().width && max_window_size.height == mainWindow.getBounds().height && max_window_size.x == mainWindow.getBounds().x && max_window_size.y == mainWindow.getBounds().y) {
|
||||
var size = { width: mainWindow.getBounds().width, height: mainWindow.getBounds().height, x: mainWindow.getBounds().x, y: mainWindow.getBounds().y, max: true };
|
||||
} else {
|
||||
var size = { width: mainWindow.getBounds().width, height: mainWindow.getBounds().height, x: mainWindow.getBounds().x, y: mainWindow.getBounds().y };
|
||||
}
|
||||
fs.writeFileSync(info_path, JSON.stringify(size));
|
||||
}
|
||||
mainWindow.on('maximize', function () {
|
||||
writePos(mainWindow)
|
||||
mainWindow.on("maximize", function() {
|
||||
writePos(mainWindow);
|
||||
fs.writeFileSync(max_info_path, JSON.stringify(mainWindow.getBounds()));
|
||||
});
|
||||
mainWindow.on('minimize', function () {
|
||||
writePos(mainWindow)
|
||||
mainWindow.webContents.send('asRead', "")
|
||||
})
|
||||
mainWindow.on("minimize", function() {
|
||||
writePos(mainWindow);
|
||||
mainWindow.webContents.send("asRead", "");
|
||||
});
|
||||
|
||||
var platform = process.platform;
|
||||
var bit = process.arch;
|
||||
|
@ -249,34 +259,36 @@ function createWindow() {
|
|||
np.TheDeskNowPlaying(mainWindow);
|
||||
//その他system
|
||||
systemFunc.system(mainWindow, dir, lang, dirname);
|
||||
setInterval(function () { mouseTrack(mainWindow) }, 1000);
|
||||
setInterval(function() {
|
||||
mouseTrack(mainWindow);
|
||||
}, 1000);
|
||||
}
|
||||
var x = 0
|
||||
var y = 0
|
||||
var unchanged = 0
|
||||
var locked = false
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var unchanged = 0;
|
||||
var locked = false;
|
||||
function mouseTrack(mainWindow) {
|
||||
let mousePos = electron.screen.getCursorScreenPoint()
|
||||
let xNow = mousePos.x
|
||||
let yNow = mousePos.x
|
||||
let mousePos = electron.screen.getCursorScreenPoint();
|
||||
let xNow = mousePos.x;
|
||||
let yNow = mousePos.x;
|
||||
if (x != xNow || y != yNow) {
|
||||
unchanged = 0
|
||||
locked = false
|
||||
unchanged = 0;
|
||||
locked = false;
|
||||
} else {
|
||||
unchanged++
|
||||
unchanged++;
|
||||
if (unchanged > 60 && !locked) {
|
||||
unchanged = 0
|
||||
locked = true
|
||||
mainWindow.webContents.send('asRead', "")
|
||||
unchanged = 0;
|
||||
locked = true;
|
||||
mainWindow.webContents.send("asRead", "");
|
||||
}
|
||||
}
|
||||
x = xNow
|
||||
y = yNow
|
||||
x = xNow;
|
||||
y = yNow;
|
||||
}
|
||||
// Electronの初期化完了後に実行
|
||||
app.on('ready', createWindow);
|
||||
var onError = function (err, response) {
|
||||
app.on("ready", createWindow);
|
||||
var onError = function(err, response) {
|
||||
console.error(err, response);
|
||||
};
|
||||
|
||||
app.setAsDefaultProtocolClient('thedesk')
|
||||
app.setAsDefaultProtocolClient("thedesk");
|
||||
|
|
|
@ -9,6 +9,7 @@ function system(mainWindow, dir, lang, dirname) {
|
|||
const clipboard = electron.clipboard;
|
||||
var tmp_img = join(app.getPath("userData"), "tmp.png");
|
||||
var ha_path = join(app.getPath("userData"), "hardwareAcceleration");
|
||||
var ua_path = join(app.getPath("userData"), "useragent");
|
||||
var lang_path = join(app.getPath("userData"), "language");
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
const dialog = electron.dialog;
|
||||
|
@ -92,6 +93,15 @@ function system(mainWindow, dir, lang, dirname) {
|
|||
app.relaunch()
|
||||
app.exit()
|
||||
})
|
||||
ipc.on('ua', function (e, arg) {
|
||||
if (arg == "") {
|
||||
fs.unlink(ua_path, function (err) { });
|
||||
} else {
|
||||
fs.writeFileSync(ua_path, arg);
|
||||
}
|
||||
app.relaunch()
|
||||
app.exit()
|
||||
})
|
||||
|
||||
ipc.on('quit', (e, args) => {
|
||||
app.quit();
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
"fontsize": "Font size",
|
||||
"savefolder": "Folder to save",
|
||||
"savefolderwarn": "TheDesk uses this value when it try to save pictures or take screenshots.",
|
||||
"useragent":"User agent",
|
||||
"useragentWarn":"Restart when changed",
|
||||
"absolute": "absolute value",
|
||||
"themeSel": "Select theme",
|
||||
"customtheme": "Edit and add custom themes",
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
"fontsize": "フォントサイズ",
|
||||
"savefolder": "デフォルトの保存先",
|
||||
"savefolderwarn": "画像ダウンロードやスクリーンショットに影響します。",
|
||||
"useragent":"ユーザーエージェント",
|
||||
"useragentWarn":"再起動します。",
|
||||
"absolute": "絶対指定",
|
||||
"themeSel": "テーマの選択",
|
||||
"customtheme": "カスタムテーマの作成・編集",
|
||||
|
|
|
@ -105,6 +105,18 @@ var envConstruction = [
|
|||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
id: "ua",
|
||||
storage: "ua_setting",
|
||||
checkbox: false,
|
||||
doubleText: false,
|
||||
setValue: "",
|
||||
width: 200,
|
||||
text: {
|
||||
head: "@@useragent@@",
|
||||
desc: "@@useragentWarn@@"
|
||||
}
|
||||
}
|
||||
];
|
||||
var tlConstruction = [
|
||||
|
|
Loading…
Reference in New Issue
Block a user