diff --git a/src/client/app/boot.js b/src/client/app/boot.js index a0709842b..ac90fda05 100644 --- a/src/client/app/boot.js +++ b/src/client/app/boot.js @@ -62,6 +62,14 @@ app = isMobile ? 'mobile' : 'desktop'; } + // Dark/Light + const me = JSON.parse(localStorage.getItem('me') || null); + if (me && me.clientSettings) { + if ((app == 'desktop' && me.clientSettings.dark) || (app == 'mobile' && me.clientSettings.darkMobile)) { + document.documentElement.setAttribute('data-darkmode', 'true'); + } + } + // Script version const ver = localStorage.getItem('v') || VERSION; diff --git a/src/client/app/desktop/script.ts b/src/client/app/desktop/script.ts index b3152e708..ba7a64ff2 100644 --- a/src/client/app/desktop/script.ts +++ b/src/client/app/desktop/script.ts @@ -2,6 +2,7 @@ * Desktop Client */ +import Vue from 'vue'; import VueRouter from 'vue-router'; // Style @@ -43,6 +44,30 @@ init(async (launch) => { require('./views/components'); require('./views/widgets'); + // Dark/Light + Vue.mixin({ + mounted() { + const set = () => { + if (!this.$el || !this.os || !this.os.i) return; + if (this.os.i.clientSettings.dark) { + document.documentElement.setAttribute('data-darkmode', 'true'); + this.$el.setAttribute('data-darkmode', 'true'); + } else { + document.documentElement.removeAttribute('data-darkmode'); + this.$el.removeAttribute('data-darkmode'); + } + }; + + set(); + + this.$watch('os.i.clientSettings', i => { + set(); + }, { + deep: true + }); + } + }); + // Init router const router = new VueRouter({ mode: 'history', diff --git a/src/client/app/desktop/style.styl b/src/client/app/desktop/style.styl index 49f71fbde..6c83cad2b 100644 --- a/src/client/app/desktop/style.styl +++ b/src/client/app/desktop/style.styl @@ -44,6 +44,9 @@ html height 100% background #f7f7f7 + &[data-darkmode] + background #191B22 + body display flex flex-direction column diff --git a/src/client/app/desktop/views/components/notes.note.vue b/src/client/app/desktop/views/components/notes.note.vue index 873d724b2..6a1207153 100644 --- a/src/client/app/desktop/views/components/notes.note.vue +++ b/src/client/app/desktop/views/components/notes.note.vue @@ -291,11 +291,11 @@ export default Vue.extend({ diff --git a/src/client/app/desktop/views/components/settings.vue b/src/client/app/desktop/views/components/settings.vue index f9d9bab18..ffa82b9e0 100644 --- a/src/client/app/desktop/views/components/settings.vue +++ b/src/client/app/desktop/views/components/settings.vue @@ -37,14 +37,17 @@

デザインと表示

- + +
+
+ +
位置情報が添付された投稿のマップを自動的に展開します。 -
@@ -298,6 +301,12 @@ export default Vue.extend({ autoWatch: v }); }, + onChangeDark(v) { + (this as any).api('i/update_client_setting', { + name: 'dark', + value: v + }); + }, onChangeShowPostFormOnTopOfTl(v) { (this as any).api('i/update_client_setting', { name: 'showPostFormOnTopOfTl', @@ -431,7 +440,6 @@ export default Vue.extend({ > .web > .div border-bottom solid 1px #eee - padding 0 0 16px 0 - margin 0 0 16px 0 + margin 16px 0 diff --git a/src/client/app/desktop/views/components/timeline.vue b/src/client/app/desktop/views/components/timeline.vue index c99fabcc6..12f928d15 100644 --- a/src/client/app/desktop/views/components/timeline.vue +++ b/src/client/app/desktop/views/components/timeline.vue @@ -66,14 +66,16 @@ export default Vue.extend({ diff --git a/src/client/app/desktop/views/components/ui.header.vue b/src/client/app/desktop/views/components/ui.header.vue index 2b63030cd..96c26367f 100644 --- a/src/client/app/desktop/views/components/ui.header.vue +++ b/src/client/app/desktop/views/components/ui.header.vue @@ -169,10 +169,10 @@ root(isDark) > .mk-ui-header-search display none -.header[data-is-darkmode] +.header[data-darkmode] root(true) -.header +.header:not([data-darkmode]) root(false) diff --git a/src/client/app/desktop/views/components/widget-container.vue b/src/client/app/desktop/views/components/widget-container.vue index 188a67313..c3fac1399 100644 --- a/src/client/app/desktop/views/components/widget-container.vue +++ b/src/client/app/desktop/views/components/widget-container.vue @@ -34,8 +34,8 @@ export default Vue.extend({ diff --git a/src/client/app/desktop/views/components/window.vue b/src/client/app/desktop/views/components/window.vue index e2cab2179..3de1413ac 100644 --- a/src/client/app/desktop/views/components/window.vue +++ b/src/client/app/desktop/views/components/window.vue @@ -465,7 +465,7 @@ export default Vue.extend({ diff --git a/src/client/app/init.css b/src/client/app/init.css index 2587f6394..fa59195f7 100644 --- a/src/client/app/init.css +++ b/src/client/app/init.css @@ -56,6 +56,13 @@ body > noscript { animation-delay: 0.32s; } +html[data-darkmode] #ini { + background: #191b22; +} + html[data-darkmode] #ini > p { + color: #fff; + } + @keyframes ini { 0%, 80%, 100% { opacity: 1;