From 160f441a95462fde0941f491d94ce1ece249c711 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 20 Apr 2018 07:59:01 +0900 Subject: [PATCH] [wip] darkmode --- src/client/app/desktop/script.ts | 37 -------------------------------- src/client/app/init.ts | 37 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/client/app/desktop/script.ts b/src/client/app/desktop/script.ts index e79573c77..8d95d8177 100644 --- a/src/client/app/desktop/script.ts +++ b/src/client/app/desktop/script.ts @@ -44,43 +44,6 @@ init(async (launch) => { require('./views/components'); require('./views/widgets'); - // Dark/Light - Vue.mixin({ - data() { - return { - _darkmode_: false - }; - }, - beforeCreate() { - // なぜか警告が出るため - this._darkmode_ = false; - }, - mounted() { - const set = () => { - if (!this.$el || !this.$el.setAttribute || !this.os || !this.os.i) return; - if (this.os.i.clientSettings.dark) { - document.documentElement.setAttribute('data-darkmode', 'true'); - this.$el.setAttribute('data-darkmode', 'true'); - this._darkmode_ = true; - this.$forceUpdate(); - } else { - document.documentElement.removeAttribute('data-darkmode'); - this.$el.removeAttribute('data-darkmode'); - this._darkmode_ = false; - this.$forceUpdate(); - } - }; - - set(); - - this.$watch('os.i.clientSettings', i => { - set(); - }, { - deep: true - }); - } - }); - // Init router const router = new VueRouter({ mode: 'history', diff --git a/src/client/app/init.ts b/src/client/app/init.ts index 990933ec0..a3ab2e8e3 100644 --- a/src/client/app/init.ts +++ b/src/client/app/init.ts @@ -47,6 +47,43 @@ Vue.mixin({ } }); +// Dark/Light +Vue.mixin({ + data() { + return { + _darkmode_: false + }; + }, + beforeCreate() { + // なぜか警告が出るため + this._darkmode_ = false; + }, + mounted() { + const set = () => { + if (!this.$el || !this.$el.setAttribute || !this.os || !this.os.i) return; + if (this.os.i.clientSettings.dark) { + document.documentElement.setAttribute('data-darkmode', 'true'); + this.$el.setAttribute('data-darkmode', 'true'); + this._darkmode_ = true; + this.$forceUpdate(); + } else { + document.documentElement.removeAttribute('data-darkmode'); + this.$el.removeAttribute('data-darkmode'); + this._darkmode_ = false; + this.$forceUpdate(); + } + }; + + set(); + + this.$watch('os.i.clientSettings', i => { + set(); + }, { + deep: true + }); + } +}); + /** * APP ENTRY POINT! */