Add: custom advanced theme

This commit is contained in:
cutls 2019-10-09 23:00:46 +09:00
parent c7d911451c
commit 5b72b93248
2 changed files with 9 additions and 7 deletions

View File

@ -630,7 +630,8 @@ function custom() {
postMessage(["themeJsonRequest", id], "*") postMessage(["themeJsonRequest", id], "*")
} }
} }
function customConnect(args) { function customConnect(raw) {
var args = raw[0]
$("#custom_name").val(args.name); $("#custom_name").val(args.name);
$("#custom_desc").val(args.desc); $("#custom_desc").val(args.desc);
$("#" + args.base).prop("checked", true); $("#" + args.base).prop("checked", true);
@ -653,7 +654,7 @@ function customConnect(args) {
advancedConncet(args, "TheDeskBottom", "primary", 6) advancedConncet(args, "TheDeskBottom", "primary", 6)
advancedConncet(args, "TheDeskPostbox", "primary", 7) advancedConncet(args, "TheDeskPostbox", "primary", 7)
advancedConncet(args, "TheDeskSubcolor", "primary", 8) advancedConncet(args, "TheDeskSubcolor", "primary", 8)
$("#custom_json").val(JSON.stringify(args)); $("#custom_json").val(raw[1]);
} }
function advancedConncet(args, tar, sub, i){ function advancedConncet(args, tar, sub, i){
if (args.props) { if (args.props) {

View File

@ -23,7 +23,7 @@ function css(mainWindow) {
ipc.on('theme-json-create', function (e, arg) { ipc.on('theme-json-create', function (e, arg) {
var themecss = join(app.getPath("userData"), JSON5.parse(arg)["id"] + var themecss = join(app.getPath("userData"), JSON5.parse(arg)["id"] +
".thedesktheme"); ".thedesktheme");
fs.writeFileSync(themecss, JSON.stringify(JSON5.parse(arg))); fs.writeFileSync(themecss, JSON5.stringify(JSON5.parse(arg)));
if (JSON5.parse(arg)["id"]) { if (JSON5.parse(arg)["id"]) {
e.sender.webContents.send('theme-json-create-complete', ""); e.sender.webContents.send('theme-json-create-complete', "");
} else { } else {
@ -39,13 +39,14 @@ function css(mainWindow) {
}) })
ipc.on('theme-json-request', function (e, arg) { ipc.on('theme-json-request', function (e, arg) {
var themecss = join(app.getPath("userData"), arg + ".thedesktheme"); var themecss = join(app.getPath("userData"), arg + ".thedesktheme");
var json = JSON.parse(fs.readFileSync(themecss, 'utf8')); var raw = fs.readFileSync(themecss, 'utf8')
e.sender.webContents.send('theme-json-response', json); var json = JSON5.parse(raw);
e.sender.webContents.send('theme-json-response', [json, raw]);
}) })
ipc.on('theme-css-request', function (e, arg) { ipc.on('theme-css-request', function (e, arg) {
var themecss = join(app.getPath("userData"), arg + ".thedesktheme"); var themecss = join(app.getPath("userData"), arg + ".thedesktheme");
try { try {
var json = JSON.parse(fs.readFileSync(themecss, 'utf8')); var json = JSON5.parse(fs.readFileSync(themecss, 'utf8'));
var primary = json.vars.primary; var primary = json.vars.primary;
var secondary = json.vars.secondary; var secondary = json.vars.secondary;
@ -135,7 +136,7 @@ function css(mainWindow) {
var themes = []; var themes = [];
for (var i = 0; i < fileList.length; i++) { for (var i = 0; i < fileList.length; i++) {
var themecss = join(app.getPath("userData"), fileList[i]); var themecss = join(app.getPath("userData"), fileList[i]);
var json = JSON.parse(fs.readFileSync(themecss, 'utf8')); var json = JSON5.parse(fs.readFileSync(themecss, 'utf8'));
themes.push({ themes.push({
name: json.name, name: json.name,
id: json.id id: json.id