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

View File

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