setting up for theme directives

This commit is contained in:
booploops 2022-02-25 01:59:47 -08:00
parent a2fa4bdd22
commit 9422c1f8d1

View file

@ -211,6 +211,10 @@ const app = new Vue({
tmpVar: [], tmpVar: [],
notification: false, notification: false,
chrome: { chrome: {
appliedTheme: {
location: "",
info: {}
},
desiredPageTransition: "wpfade_transform", desiredPageTransition: "wpfade_transform",
hideUserInfo: ipcRenderer.sendSync("is-dev") || false, hideUserInfo: ipcRenderer.sendSync("is-dev") || false,
artworkReady: false, artworkReady: false,
@ -894,7 +898,7 @@ const app = new Vue({
}, 500) }, 500)
ipcRenderer.invoke("renderer-ready", true) ipcRenderer.invoke("renderer-ready", true)
}, },
setTheme(theme = "") { async setTheme(theme = "") {
console.log(theme) console.log(theme)
if (this.cfg.visual.theme == "") { if (this.cfg.visual.theme == "") {
this.cfg.visual.theme = "default.less" this.cfg.visual.theme = "default.less"
@ -904,12 +908,22 @@ const app = new Vue({
} else { } else {
this.cfg.visual.theme = theme 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.querySelector("#userTheme").href = `themes/${this.cfg.visual.theme}`
document.querySelectorAll(`[id*='less']`).forEach(el => { document.querySelectorAll(`[id*='less']`).forEach(el => {
el.remove() el.remove()
}); });
less.refresh() less.refresh()
}, },
getThemeDirective(directive = "") {
if(this.chrome.appliedTheme.info.directives[directive]) {
return this.chrome.appliedTheme.info.directives[directive]
} else {
return ""
}
},
unauthorize() { unauthorize() {
bootbox.confirm(app.getLz('term.confirmLogout'), function (result) { bootbox.confirm(app.getLz('term.confirmLogout'), function (result) {
if (result) { if (result) {