diff options
| author | syuilo <Syuilotan@yahoo.co.jp> | 2021-10-11 00:36:47 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2021-10-11 00:36:47 +0900 |
| commit | 816493e01ffe613ba4eca1d56a71a8cbf1099bf6 (patch) | |
| tree | a7b373e319cb4d158525aa5fd37764e92407458d /src/client/components | |
| parent | fix ui (diff) | |
| download | sharkey-816493e01ffe613ba4eca1d56a71a8cbf1099bf6.tar.gz sharkey-816493e01ffe613ba4eca1d56a71a8cbf1099bf6.tar.bz2 sharkey-816493e01ffe613ba4eca1d56a71a8cbf1099bf6.zip | |
:art:
Diffstat (limited to 'src/client/components')
| -rw-r--r-- | src/client/components/global/header.vue | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/client/components/global/header.vue b/src/client/components/global/header.vue index 32a332cf69..346bf42611 100644 --- a/src/client/components/global/header.vue +++ b/src/client/components/global/header.vue @@ -37,13 +37,14 @@ </template> <script lang="ts"> -import { computed, defineComponent, onMounted, PropType, ref } from 'vue'; +import { computed, defineComponent, onMounted, onUnmounted, PropType, ref } from 'vue'; import * as tinycolor from 'tinycolor2'; import { popupMenu } from '@client/os'; import { url } from '@client/config'; import { scrollToTop } from '@client/scripts/scroll'; import MkButton from '@client/components/ui/button.vue'; -import { i18n } from '../../i18n'; +import { i18n } from '@client/i18n'; +import { globalEvents } from '@client/events'; export default defineComponent({ components: { @@ -136,11 +137,19 @@ export default defineComponent({ scrollToTop(el.value, { behavior: 'smooth' }); }; - onMounted(() => { + const calcBg = () => { const rawBg = props.info?.bg || 'var(--bg)'; const tinyBg = tinycolor(rawBg.startsWith('var(') ? getComputedStyle(document.documentElement).getPropertyValue(rawBg.slice(4, -1)) : rawBg); tinyBg.setAlpha(0.85); bg.value = tinyBg.toRgbString(); + }; + + onMounted(() => { + calcBg(); + globalEvents.on('themeChanged', calcBg); + onUnmounted(() => { + globalEvents.off('themeChanged', calcBg); + }); if (el.value.parentElement) { narrow.value = el.value.parentElement.offsetWidth < 500; |