Introduce: JSON5 and export v2.1

This commit is contained in:
Cutls 2019-08-29 01:20:47 +09:00
parent 89bde2739a
commit 834fa719b2
6 changed files with 28 additions and 21 deletions

View File

@ -0,0 +1,3 @@
const JSON5 = require('json5')
const fs = require("fs")
fs.writeFileSync("main.json", JSON.stringify(JSON5.parse(fs.readFileSync("lang." + process.argv[2] + ".js", 'utf8').replace("var lang = ", ""))))

View File

@ -141,8 +141,11 @@ onmessage = function (e) {
} else if (e.data[0] == "parseColumn") { } else if (e.data[0] == "parseColumn") {
parseColumn(e.data[1]) parseColumn(e.data[1])
} else if (e.data[0] == "exportSettingsCore") { } else if (e.data[0] == "exportSettingsCore") {
exportSettingsCore() var exp = exportSettingsCore()
} else if (e.data[0] == "fontList") { postMessage(["exportSettingsCoreComplete", [e.data[1], exp]], "*")
} else if (e.data[0] == "importSettingsCore") {
importSettingsCore(e.data[1])
}else if (e.data[0] == "fontList") {
fontList(e.data[1]) fontList(e.data[1])
} else if (e.data[0] == "customSoundSave") { } else if (e.data[0] == "customSoundSave") {
customSoundSave(e.data[1][0], e.data[1][1]) customSoundSave(e.data[1][0], e.data[1][1])

View File

@ -2,7 +2,6 @@ var electron = require("electron");
const shell = electron.shell; const shell = electron.shell;
var ipc = electron.ipcRenderer; var ipc = electron.ipcRenderer;
onmessage = function (e) { onmessage = function (e) {
console.log(e)
if (e.data[0] == "openUrl") { if (e.data[0] == "openUrl") {
urls = e.data[1].match(/https?:\/\/(.+)/); urls = e.data[1].match(/https?:\/\/(.+)/);
if (urls) { if (urls) {
@ -31,6 +30,8 @@ onmessage = function (e) {
ipc.send('lang', e.data[1]); ipc.send('lang', e.data[1]);
} else if (e.data[0] == "exportSettings") { } else if (e.data[0] == "exportSettings") {
ipc.send('exportSettings', e.data[1]); ipc.send('exportSettings', e.data[1]);
} else if (e.data[0] == "exportSettingsCoreComplete") {
ipc.send('export', e.data[1]);
} else if (e.data[0] == "importSettings") { } else if (e.data[0] == "importSettings") {
ipc.send('importSettings', e.data[1]); ipc.send('importSettings', e.data[1]);
} else if (e.data[0] == "customSound") { } else if (e.data[0] == "customSound") {
@ -112,12 +113,8 @@ ipc.on('general-dl-message', function (event, arg) {
ipc.on('langres', function (event, arg) { ipc.on('langres', function (event, arg) {
location.href = "../" + arg + "/setting.html" location.href = "../" + arg + "/setting.html"
}); });
ipc.on('exportSettingsFile', function (event, savedFiles) { ipc.on('exportSettingsFile', function (event, arg) {
var exp = exportSettingsCore() postMessage(["exportSettingsCore", arg], "*")
ipc.send('export', [savedFiles, JSON.stringify(exp)]);
postMessage(["alert", "Done"], "*")
//cards
//lang
}); });
ipc.on('config', function (event, arg) { ipc.on('config', function (event, arg) {
postMessage(["importSettingsCore", arg], "*") postMessage(["importSettingsCore", arg], "*")

View File

@ -323,6 +323,7 @@ function exportSettingsCore() {
var tagarr = localStorage.getItem("tag"); var tagarr = localStorage.getItem("tag");
var favtag = JSON.parse(tagarr); var favtag = JSON.parse(tagarr);
exp.favoriteTags = favtag; exp.favoriteTags = favtag;
exp.version = "2.1"
return exp; return exp;
} }
function importSettings() { function importSettings() {
@ -340,8 +341,7 @@ function importSettings() {
} }
}) })
} }
function importSettingsCore(arg) { function importSettingsCore(obj) {
var obj = JSON.parse(arg);
if (obj) { if (obj) {
localStorage.clear(); localStorage.clear();
localStorage.setItem("multi", JSON.stringify(obj.accts)); localStorage.setItem("multi", JSON.stringify(obj.accts));
@ -356,7 +356,7 @@ function importSettingsCore(arg) {
} }
localStorage.setItem("column", JSON.stringify(obj.columns)); localStorage.setItem("column", JSON.stringify(obj.columns));
if (obj.config) { if (obj.config) {
//Version 2 //Version 2~
var max = envView.config.length; var max = envView.config.length;
for (var i = 0; i < max; i++) { for (var i = 0; i < max; i++) {
var ls = envView.config[i].storage; var ls = envView.config[i].storage;

View File

@ -4,6 +4,7 @@ function system(mainWindow, dir, lang, dirname) {
const join = require('path').join; const join = require('path').join;
var Jimp = require("jimp"); var Jimp = require("jimp");
const fs = require("fs"); const fs = require("fs");
var JSON5 = require('json5');
var ipc = electron.ipcMain; var ipc = electron.ipcMain;
var tmp_img = join(app.getPath("userData"), "tmp.png"); var tmp_img = join(app.getPath("userData"), "tmp.png");
var ha_path = join(app.getPath("userData"), "hardwareAcceleration"); var ha_path = join(app.getPath("userData"), "hardwareAcceleration");
@ -61,7 +62,7 @@ function system(mainWindow, dir, lang, dirname) {
dialog.showSaveDialog(null, { dialog.showSaveDialog(null, {
title: 'Export', title: 'Export',
properties: ['openFile', 'createDirectory'], properties: ['openFile', 'createDirectory'],
defaultPath: "export.thedeskconfigv2" defaultPath: "export.thedeskconfig.json5"
}, (savedFiles) => { }, (savedFiles) => {
if (!savedFiles) { if (!savedFiles) {
return false; return false;
@ -75,13 +76,13 @@ function system(mainWindow, dir, lang, dirname) {
title: 'Import', title: 'Import',
properties: ['openFile'], properties: ['openFile'],
filters: [ filters: [
{ name: 'TheDesk Config', extensions: ['thedeskconfig', 'thedeskconfigv2'] }, { name: 'TheDesk Config', extensions: ['thedeskconfig', 'thedeskconfigv2', 'json5'] },
] ]
}, (fileNames) => { }, (fileNames) => {
if (!fileNames) { if (!fileNames) {
return false; return false;
} }
e.sender.webContents.send('config', fs.readFileSync(arg, 'utf8')); e.sender.webContents.send('config', JSON5.parse(fs.readFileSync(fileNames[0], 'utf8')));
}) })
}) })
//保存フォルダのダイアログ //保存フォルダのダイアログ
@ -194,7 +195,7 @@ function system(mainWindow, dir, lang, dirname) {
ipc.on('export', (e, args) => { ipc.on('export', (e, args) => {
fs.writeFileSync(args[0], args[1]); fs.writeFileSync(args[0], JSON5.stringify(args[1]));
}); });
//フォント //フォント
function object_array_sort(data, key, order, fn) { function object_array_sort(data, key, order, fn) {

View File

@ -681,11 +681,14 @@
Pixiv Fanboxでは支援者様限定で様々なTheDeskに関する記事をご覧いただけます。最低月一更新。<br> Pixiv Fanboxでは支援者様限定で様々なTheDeskに関する記事をご覧いただけます。最低月一更新。<br>
困ったときは、<a href="https://docs.thedesk.top">TheDesk Docs</a>をご覧ください。 困ったときは、<a href="https://docs.thedesk.top">TheDesk Docs</a>をご覧ください。
<h5>Release Note Usamin (18.8.3)</h5> <h5>Release Note Usamin (18.8.3)</h5>
・Pawooでフォローできなかった不具合を修正。<br> ・設定エクスポートファイルが変更された<br>
・(macOS)iTunes NowPlayingでにの不具合を修正。<br> .thedeskconfigv2: 17.2.0~18.8.3<br>
・トゥートのアクションが正しく切り替えれれない不具合を修正。<br> .thedeskconfig: 16.0.1~17.2.0<br>
・アカウント画面のトゥートのカウントが上手くいってなかった不具合を修正。<br> .json5: 本バージョン以降<br>
・アカウント画面のデザインを大幅に改善。<br> <u>エクスポート可能な形式</u><br>
.json5<br>
<u>インポート可能な形式</u><br>
.thedeskconfigv2, .thedeskconfig, .json5
</div> </div>
<div id="release-en" style="display:none"> <div id="release-en" style="display:none">
<h5>Let's make it native!</h5> <h5>Let's make it native!</h5>