From 89461c598f4746287d13dad6fa6d1215cb43c030 Mon Sep 17 00:00:00 2001 From: syuilo Date: Thu, 24 May 2018 05:28:46 +0900 Subject: Refactor --- src/client/app/boot.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/client/app/boot.js') diff --git a/src/client/app/boot.js b/src/client/app/boot.js index da1b64823f..7b884c8a54 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -18,6 +18,14 @@ return; } + //#region Load settings + let settings = null; + const vuex = localStorage.getItem('vuex'); + if (vuex) { + settings = JSON.parse(vuex); + } + //#endregion + // Get the current url information const url = new URL(location.href); @@ -35,10 +43,8 @@ // The default language is English if (!LANGS.includes(lang)) lang = 'en'; - const vuex = localStorage.getItem('vuex'); - if (vuex) { - const data = JSON.parse(vuex); - if (data.device.lang) lang = data.device.lang; + if (settings) { + if (settings.device.lang) lang = settings.device.lang; } //#endregion @@ -68,8 +74,10 @@ } // Dark/Light - if (localStorage.getItem('darkmode') == 'true') { - document.documentElement.setAttribute('data-darkmode', 'true'); + if (settings) { + if (settings.device.darkmode) { + document.documentElement.setAttribute('data-darkmode', 'true'); + } } // Script version -- cgit v1.3.1-freya