Introduce: JSON5 and export v2.1
This commit is contained in:
parent
89bde2739a
commit
834fa719b2
3
app/js/lang/json5Tojson.js
Normal file
3
app/js/lang/json5Tojson.js
Normal 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 = ", ""))))
|
|
@ -141,8 +141,11 @@ onmessage = function (e) {
|
|||
} else if (e.data[0] == "parseColumn") {
|
||||
parseColumn(e.data[1])
|
||||
} else if (e.data[0] == "exportSettingsCore") {
|
||||
exportSettingsCore()
|
||||
} else if (e.data[0] == "fontList") {
|
||||
var exp = exportSettingsCore()
|
||||
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])
|
||||
} else if (e.data[0] == "customSoundSave") {
|
||||
customSoundSave(e.data[1][0], e.data[1][1])
|
||||
|
|
|
@ -2,7 +2,6 @@ var electron = require("electron");
|
|||
const shell = electron.shell;
|
||||
var ipc = electron.ipcRenderer;
|
||||
onmessage = function (e) {
|
||||
console.log(e)
|
||||
if (e.data[0] == "openUrl") {
|
||||
urls = e.data[1].match(/https?:\/\/(.+)/);
|
||||
if (urls) {
|
||||
|
@ -31,6 +30,8 @@ onmessage = function (e) {
|
|||
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") {
|
||||
|
@ -112,12 +113,8 @@ ipc.on('general-dl-message', function (event, arg) {
|
|||
ipc.on('langres', function (event, arg) {
|
||||
location.href = "../" + arg + "/setting.html"
|
||||
});
|
||||
ipc.on('exportSettingsFile', function (event, savedFiles) {
|
||||
var exp = exportSettingsCore()
|
||||
ipc.send('export', [savedFiles, JSON.stringify(exp)]);
|
||||
postMessage(["alert", "Done"], "*")
|
||||
//cards
|
||||
//lang
|
||||
ipc.on('exportSettingsFile', function (event, arg) {
|
||||
postMessage(["exportSettingsCore", arg], "*")
|
||||
});
|
||||
ipc.on('config', function (event, arg) {
|
||||
postMessage(["importSettingsCore", arg], "*")
|
||||
|
|
|
@ -323,6 +323,7 @@ function exportSettingsCore() {
|
|||
var tagarr = localStorage.getItem("tag");
|
||||
var favtag = JSON.parse(tagarr);
|
||||
exp.favoriteTags = favtag;
|
||||
exp.version = "2.1"
|
||||
return exp;
|
||||
}
|
||||
function importSettings() {
|
||||
|
@ -340,8 +341,7 @@ function importSettings() {
|
|||
}
|
||||
})
|
||||
}
|
||||
function importSettingsCore(arg) {
|
||||
var obj = JSON.parse(arg);
|
||||
function importSettingsCore(obj) {
|
||||
if (obj) {
|
||||
localStorage.clear();
|
||||
localStorage.setItem("multi", JSON.stringify(obj.accts));
|
||||
|
@ -356,7 +356,7 @@ function importSettingsCore(arg) {
|
|||
}
|
||||
localStorage.setItem("column", JSON.stringify(obj.columns));
|
||||
if (obj.config) {
|
||||
//Version 2
|
||||
//Version 2~
|
||||
var max = envView.config.length;
|
||||
for (var i = 0; i < max; i++) {
|
||||
var ls = envView.config[i].storage;
|
||||
|
|
|
@ -4,6 +4,7 @@ function system(mainWindow, dir, lang, dirname) {
|
|||
const join = require('path').join;
|
||||
var Jimp = require("jimp");
|
||||
const fs = require("fs");
|
||||
var JSON5 = require('json5');
|
||||
var ipc = electron.ipcMain;
|
||||
var tmp_img = join(app.getPath("userData"), "tmp.png");
|
||||
var ha_path = join(app.getPath("userData"), "hardwareAcceleration");
|
||||
|
@ -61,7 +62,7 @@ function system(mainWindow, dir, lang, dirname) {
|
|||
dialog.showSaveDialog(null, {
|
||||
title: 'Export',
|
||||
properties: ['openFile', 'createDirectory'],
|
||||
defaultPath: "export.thedeskconfigv2"
|
||||
defaultPath: "export.thedeskconfig.json5"
|
||||
}, (savedFiles) => {
|
||||
if (!savedFiles) {
|
||||
return false;
|
||||
|
@ -75,13 +76,13 @@ function system(mainWindow, dir, lang, dirname) {
|
|||
title: 'Import',
|
||||
properties: ['openFile'],
|
||||
filters: [
|
||||
{ name: 'TheDesk Config', extensions: ['thedeskconfig', 'thedeskconfigv2'] },
|
||||
{ name: 'TheDesk Config', extensions: ['thedeskconfig', 'thedeskconfigv2', 'json5'] },
|
||||
]
|
||||
}, (fileNames) => {
|
||||
if (!fileNames) {
|
||||
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) => {
|
||||
fs.writeFileSync(args[0], args[1]);
|
||||
fs.writeFileSync(args[0], JSON5.stringify(args[1]));
|
||||
});
|
||||
//フォント
|
||||
function object_array_sort(data, key, order, fn) {
|
||||
|
|
|
@ -681,11 +681,14 @@
|
|||
Pixiv Fanboxでは支援者様限定で様々なTheDeskに関する記事をご覧いただけます。最低月一更新。<br>
|
||||
困ったときは、<a href="https://docs.thedesk.top">TheDesk Docs</a>をご覧ください。
|
||||
<h5>Release Note Usamin (18.8.3)</h5>
|
||||
・Pawooでフォローできなかった不具合を修正。<br>
|
||||
・(macOS)iTunes NowPlayingでにの不具合を修正。<br>
|
||||
・トゥートのアクションが正しく切り替えれれない不具合を修正。<br>
|
||||
・アカウント画面のトゥートのカウントが上手くいってなかった不具合を修正。<br>
|
||||
・アカウント画面のデザインを大幅に改善。<br>
|
||||
・設定エクスポートファイルが変更された<br>
|
||||
.thedeskconfigv2: 17.2.0~18.8.3<br>
|
||||
.thedeskconfig: 16.0.1~17.2.0<br>
|
||||
.json5: 本バージョン以降<br>
|
||||
<u>エクスポート可能な形式</u><br>
|
||||
.json5<br>
|
||||
<u>インポート可能な形式</u><br>
|
||||
.thedeskconfigv2, .thedeskconfig, .json5
|
||||
</div>
|
||||
<div id="release-en" style="display:none">
|
||||
<h5>Let's make it native!</h5>
|
||||
|
|
Loading…
Reference in New Issue
Block a user