From 714bcf28d5158dead53feb7365fbbd9607421744 Mon Sep 17 00:00:00 2001 From: fuyu <54523771+mfmfuyu@users.noreply.github.com> Date: Sun, 16 Feb 2020 20:20:02 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=86=E3=83=BC=E3=83=9E=E3=81=AE=E5=88=87?= =?UTF-8?q?=E3=82=8A=E6=9B=BF=E3=81=88=E6=99=82=E3=81=AB=E6=99=82=E8=A8=88?= =?UTF-8?q?=E3=81=AE=E8=89=B2=E3=81=8C=E5=A4=89=E3=82=8F=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=20(#5959)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * テーマの切り替え時に時計の色が変わるように * ディレイを追加 --- src/client/components/analog-clock.vue | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/client/components/analog-clock.vue b/src/client/components/analog-clock.vue index b8fb4cf7be..b689266780 100644 --- a/src/client/components/analog-clock.vue +++ b/src/client/components/analog-clock.vue @@ -55,15 +55,17 @@ export default Vue.extend({ handsTailLength: 0.7, hHandLengthRatio: 0.75, mHandLengthRatio: 1, - sHandLengthRatio: 1 + sHandLengthRatio: 1, + + computedStyle: getComputedStyle(document.documentElement) }; }, computed: { dark(): boolean { - return tinycolor(getComputedStyle(document.documentElement).getPropertyValue('--bg')).isDark(); + return tinycolor(this.computedStyle.getPropertyValue('--bg')).isDark(); }, - + majorGraduationColor(): string { return this.dark ? 'rgba(255, 255, 255, 0.3)' : 'rgba(0, 0, 0, 0.3)'; }, @@ -75,10 +77,10 @@ export default Vue.extend({ return this.dark ? 'rgba(255, 255, 255, 0.5)' : 'rgba(0, 0, 0, 0.3)'; }, mHandColor(): string { - return tinycolor(getComputedStyle(document.documentElement).getPropertyValue('--fg')).toHexString(); + return tinycolor(this.computedStyle.getPropertyValue('--fg')).toHexString(); }, hHandColor(): string { - return tinycolor(getComputedStyle(document.documentElement).getPropertyValue('--accent')).toHexString(); + return tinycolor(this.computedStyle.getPropertyValue('--accent')).toHexString(); }, ms(): number { @@ -123,6 +125,16 @@ export default Vue.extend({ } }; update(); + + this.$store.subscribe((mutation, state) => { + if (mutation.type !== 'device/set') return; + + if (mutation?.payload?.key !== 'theme') return; + + setTimeout(() => { + this.computedStyle = getComputedStyle(document.documentElement); + }, 250); + }); }, beforeDestroy() {