Remove: node on setting/system.js #86

This commit is contained in:
Cutls 2019-06-15 02:01:38 +09:00
parent 7b46145114
commit 7da16a7428
4 changed files with 320 additions and 282 deletions

View File

@ -25,6 +25,22 @@ onmessage = function (e) {
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] == "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', id);
} else if (e.data[0] == "ha") {
ipc.send('ha', had);
}
}
//version.js
@ -163,6 +179,42 @@ ipc.on('column-del-reply', function (event, args) {
sortload()
}
})
//setting.js
ipc.on('langres', function (event, arg) {
location.href = "../" + lang + "/setting.html"
});
ipc.on('exportSettingsFile', function (event, savedFiles) {
var exp = exportSettingsCore()
ipc.send('export', [savedFiles, JSON.stringify(exp)]);
alert("Done.")
//cards
//lang
});
ipc.on('config', function (event, arg) {
importSettingsCore(arg)
});
ipc.on('savefolder', function (event, arg) {
localStorage.setItem("savefolder", arg);
});
ipc.on('font-list', function (event, arg) {
fontList(arg)
});
ipc.on('customSoundRender', function (event, args) {
customSoundSave(args[0], args[1])
});
ipc.on('theme-json-list-response', function (event, args) {
ctLoadCore(args)
});
ipc.on('theme-json-delete-complete', function (event, args) {
ctLoad()
});
ipc.on('theme-json-response', function (event, args) {
customConnect(args)
});
ipc.on('theme-json-create-complete', function (event, args) {
clearCustomImport()
ctLoad()
});
/*
var webviewDom = document.getElementById('webview');
const {

View File

@ -51,6 +51,5 @@ $(function () {
});
});
function help() {
const { shell } = require('electron');
shell.openExternal("https://docs.thedesk.top");
postMessage(["openUrl", "https://docs.thedesk.top"], "*")
}

View File

@ -190,9 +190,7 @@ function wordempSave() {
localStorage.setItem("word_emp", json);
}
function notftest() {
var electron = require("electron");
var ipc = electron.ipcRenderer;
var os = electron.remote.process.platform;
var os = localStorage.getItem("platform");
var options = {
body: lang.lang_setting_notftest + '(' + lang.lang_setting_notftestprof + ')',
icon: localStorage.getItem("prof_0")
@ -200,7 +198,8 @@ function notftest() {
if (os == "darwin") {
var n = new Notification('TheDesk' + lang.lang_setting_notftest, options);
} else {
ipc.send('native-notf', ['TheDesk' + lang.lang_setting_notftest, lang.lang_setting_notftest + '(' + lang.lang_setting_notftestprof + ')', localStorage.getItem('prof_0'), "", ""]);
var nativeNotfOpt = ['TheDesk' + lang.lang_setting_notftest, lang.lang_setting_notftest + '(' + lang.lang_setting_notftestprof + ')', localStorage.getItem('prof_0'), "", ""]
postMessage(["nativeNotf", nativeNotfOpt], "*")
}
}
@ -215,29 +214,15 @@ function oksload() {
if (localStorage.getItem("oks-3")) { $("#oks-3").val(localStorage.getItem("oks-3")) }
}
function changelang(lang) {
var electron = require("electron");
var ipc = electron.ipcRenderer;
ipc.send('lang', lang);
ipc.on('langres', function (event, arg) {
location.href = "../" + lang + "/setting.html"
});
postMessage(["lang", lang], "*")
}
function exportSettings() {
if (!confirm(lang.lang_setting_exportwarn)) {
return false;
}
var electron = require("electron");
var remote = electron.remote;
var dialog = remote.dialog;
var ipc = electron.ipcRenderer;
dialog.showSaveDialog(null, {
title: 'Export',
properties: ['openFile', 'createDirectory'],
defaultPath: "export.thedeskconfigv2"
}, (savedFiles) => {
if (!savedFiles) {
return false;
}
postMessage(["exportSettings", ""], "*")
}
function exportSettingsCore() {
var exp = {};
//Accounts
var multi = localStorage.getItem("multi");
@ -295,32 +280,15 @@ function exportSettings() {
var tagarr = localStorage.getItem("tag");
var favtag = JSON.parse(tagarr);
exp.favoriteTags = favtag;
ipc.send('export', [savedFiles, JSON.stringify(exp)]);
alert("Done.")
//cards
//lang
});
return exp;
}
function importSettings() {
if (!confirm(lang.lang_setting_importwarn)) {
return false;
}
var electron = require("electron");
var remote = electron.remote;
var dialog = remote.dialog;
var ipc = electron.ipcRenderer;
dialog.showOpenDialog(null, {
title: 'Import',
properties: ['openFile'],
filters: [
{ name: 'TheDesk Config', extensions: ['thedeskconfig', 'thedeskconfigv2'] },
]
}, (fileNames) => {
if (!fileNames) {
return false;
}
ipc.send('import', fileNames[0]);
ipc.on('config', function (event, arg) {
postMessage(["importSettings", ""], "*")
}
function importSettingsCore(arg) {
var obj = JSON.parse(arg);
if (obj) {
localStorage.clear();
@ -409,34 +377,20 @@ function importSettings() {
} else {
alert("Error.")
}
})
//cards
//lang
});
}
function savefolder() {
var electron = require("electron");
var remote = electron.remote;
var dialog = remote.dialog;
dialog.showOpenDialog(null, {
title: 'Save folder',
properties: ['openDirectory'],
}, (fileNames) => {
localStorage.setItem("savefolder", fileNames[0]);
});
postMessage(["sendSinmpleIpc", "savefolder"], "*")
}
function font() {
var electron = require("electron");
var ipc = electron.ipcRenderer;
ipc.send('fonts', []);
ipc.on('font-list', function (event, arg) {
postMessage(["sendSinmpleIpc", "fonts"], "*")
}
function fontList(arg) {
$("#fonts").removeClass("hide");
for (var i = 0; i < arg.length; i++) {
var font = arg[i];
$("#fonts").append('<div class="font pointer" style="font-family:' + font.family + '" onclick="insertFont(\'' + font.family + '\')">' + font.family + "</div>")
}
});
}
function insertFont(name) {
$("#font").val(name);
@ -522,7 +476,7 @@ function customComp() {
pickerDefine(1, "fff");
pickerDefine(2, "fff");
pickerDefine(3, "fff");
ipc.send('theme-json-create', JSON.stringify(json));
postMessage(["themeJsonCreate", JSON.stringify(json)], "*")
}
function deleteIt() {
var id = $("#custom-sel-sel").val();
@ -542,14 +496,12 @@ function deleteIt() {
pickerDefine(1, "fff");
pickerDefine(2, "fff");
pickerDefine(3, "fff");
ipc.on('theme-json-delete-complete', function (event, args) {
ctLoad()
});
ipc.send('theme-json-delete', id);
postMessage(["themeJsonDelete", id], "*")
}
function ctLoad() {
ipc.send('theme-json-list', "");
ipc.on('theme-json-list-response', function (event, args) {
postMessage(["sendSinmpleIpc", "theme-json-list"], "*")
}
function ctLoadCore(args) {
var templete = "";
Object.keys(args).forEach(function (key) {
var theme = args[key];
@ -563,7 +515,6 @@ function ctLoad() {
templete = '<option value="add_new">' + $("#edit-selector").attr("data-add") + '</option>' + templete;
$("#custom-edit-sel").html(templete);
$('select').formSelect();
});
}
function customSel() {
var id = $("#custom-sel-sel").val();
@ -591,8 +542,10 @@ function custom() {
$("#delTheme").addClass("disabled")
} else {
$("#delTheme").removeClass("disabled")
ipc.send('theme-json-request', id);
ipc.on('theme-json-response', function (event, args) {
postMessage(["themeJsonRequest", id], "*")
}
}
function customConnect(args) {
$("#custom_name").val(args.name);
$("#custom_desc").val(args.desc);
$("#" + args.base).prop("checked", true);
@ -617,40 +570,27 @@ function custom() {
$("#color-picker3-wrap").html('<div class="color-picker" id="color-picker3"></div>')
pickerDefine(3, rgbToHex(accent))
$("#custom_json").val(JSON.stringify(args));
});
}
}
function customImp() {
var json = $("#custom_import").val();
if (JSON5.parse(json)) {
ipc.send('theme-json-create', json);
postMessage(["themeJsonCreate", json], "*")
} else {
alert("Error")
}
}
function hardwareAcceleration(had) {
ipc.send('ha', had);
}
ipc.on('theme-json-create-complete', function (event, args) {
function clearCustomImport() {
$("#custom_import").val("");
ctLoad()
});
}
function hardwareAcceleration(had) {
postMessage(["ha", had], "*")
}
function customSound(key) {
var electron = require("electron");
var remote = electron.remote;
var dialog = remote.dialog;
dialog.showOpenDialog(null, {
title: 'Custom sound',
properties: ['openFile'],
filters: [
{ name: 'Audio', extensions: ['mp3', 'aac', 'wav', 'flac', 'm4a'] },
{ name: 'All', extensions: ['*'] },
]
}, (fileNames) => {
localStorage.setItem("custom" + key, fileNames[0]);
$("#c1-file").text(fileNames[0])
});
postMessage(["customSound", key], "*")
}
function customSoundSave(key, file) {
localStorage.setItem("custom" + key, file);
$("#c1-file").text(file)
}
window.onload = function () {
//最初に読む

View File

@ -73,6 +73,56 @@ function system(mainWindow, dir, lang) {
e.sender.webContents.send('dialogClientRender', arg);
});
})
//エクスポートのダイアログ
ipc.on('exportSettings', function (e, args) {
dialog.showSaveDialog(null, {
title: 'Export',
properties: ['openFile', 'createDirectory'],
defaultPath: "export.thedeskconfigv2"
}, (savedFiles) => {
if (!savedFiles) {
return false;
}
e.sender.webContents.send('exportSettingsFile', savedFiles);
})
})
//インポートのダイアログ
ipc.on('importSettings', function (e, args) {
dialog.showOpenDialog(null, {
title: 'Import',
properties: ['openFile'],
filters: [
{ name: 'TheDesk Config', extensions: ['thedeskconfig', 'thedeskconfigv2'] },
]
}, (fileNames) => {
if (!fileNames) {
return false;
}
e.sender.webContents.send('config', fs.readFileSync(arg, 'utf8'));
})
})
//保存フォルダのダイアログ
ipc.on('savefolder', function (e, args) {
dialog.showOpenDialog(null, {
title: 'Save folder',
properties: ['openDirectory'],
}, (fileNames) => {
e.sender.webContents.send('savefolder', fileNames[0]);
});
})
//カスタムサウンドのダイアログ
ipc.on('customSound', function (e, arg) {
dialog.showOpenDialog(null, {
title: 'Custom sound',
properties: ['openFile'],
filters: [
{ name: 'Audio', extensions: ['mp3', 'aac', 'wav', 'flac', 'm4a'] },
{ name: 'All', extensions: ['*'] },
]
}, (fileNames) => {
e.sender.webContents.send('customSoundRender', [key, fileNames[0]]);
});
})
//ハードウェアアクセラレーションの無効化
ipc.on('ha', function (e, arg) {
@ -169,9 +219,6 @@ function system(mainWindow, dir, lang) {
ipc.on('export', (e, args) => {
fs.writeFileSync(args[0], args[1]);
});
ipc.on('import', (e, arg) => {
e.sender.webContents.send('config', fs.readFileSync(arg, 'utf8'));
});
//フォント
function object_array_sort(data, key, order, fn) {
//デフォは降順(DESC)