summaryrefslogtreecommitdiff
path: root/src/client/app/init.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-04-20 07:59:01 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-04-20 07:59:01 +0900
commit160f441a95462fde0941f491d94ce1ece249c711 (patch)
treeb4bd58fe17b5987507e271dada29c930a4ac1cd0 /src/client/app/init.ts
parent[wip] darkmode (diff)
downloadmisskey-160f441a95462fde0941f491d94ce1ece249c711.tar.gz
misskey-160f441a95462fde0941f491d94ce1ece249c711.tar.bz2
misskey-160f441a95462fde0941f491d94ce1ece249c711.zip
[wip] darkmode
Diffstat (limited to '')
-rw-r--r--src/client/app/init.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/client/app/init.ts b/src/client/app/init.ts
index 990933ec0e..a3ab2e8e31 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!
*/