From 9422c1f8d12f793d9074eac6da3b30e3e63e1039 Mon Sep 17 00:00:00 2001 From: booploops <49113086+booploops@users.noreply.github.com> Date: Fri, 25 Feb 2022 01:59:47 -0800 Subject: [PATCH] setting up for theme directives --- src/renderer/index.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/renderer/index.js b/src/renderer/index.js index a3c15d61..a1d35e90 100644 --- a/src/renderer/index.js +++ b/src/renderer/index.js @@ -211,6 +211,10 @@ const app = new Vue({ tmpVar: [], notification: false, chrome: { + appliedTheme: { + location: "", + info: {} + }, desiredPageTransition: "wpfade_transform", hideUserInfo: ipcRenderer.sendSync("is-dev") || false, artworkReady: false, @@ -894,7 +898,7 @@ const app = new Vue({ }, 500) ipcRenderer.invoke("renderer-ready", true) }, - setTheme(theme = "") { + async setTheme(theme = "") { console.log(theme) if (this.cfg.visual.theme == "") { this.cfg.visual.theme = "default.less" @@ -904,12 +908,22 @@ const app = new Vue({ } else { this.cfg.visual.theme = theme } + this.chrome.appliedTheme.info = await fetch("themes/" + app.cfg.visual.theme.replace("index.less", "theme.json")) + + document.querySelector("#userTheme").href = `themes/${this.cfg.visual.theme}` document.querySelectorAll(`[id*='less']`).forEach(el => { el.remove() }); less.refresh() }, + getThemeDirective(directive = "") { + if(this.chrome.appliedTheme.info.directives[directive]) { + return this.chrome.appliedTheme.info.directives[directive] + } else { + return "" + } + }, unauthorize() { bootbox.confirm(app.getLz('term.confirmLogout'), function (result) { if (result) {