mirror of
https://github.com/misskey-dev/misskey.git
synced 2025-03-16 09:55:16 +09:00
fix(frontend): テーマ切り替え時に一部の色が変わらない問題を修正
This commit is contained in:
parent
6419af2179
commit
4df9083bf0
@ -7,6 +7,7 @@
|
||||
- Feat: 設定の管理が強化されました
|
||||
- 自動でバックアップされるように
|
||||
- Enhance: プラグインの管理が強化されました
|
||||
- Fix: テーマ切り替え時に一部の色が変わらない問題を修正
|
||||
|
||||
### Server
|
||||
- Fix: プロフィール追加情報で無効なURLに入力された場合に照会エラーを出るのを修正
|
||||
|
@ -43,14 +43,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
<script lang="ts" setup>
|
||||
import { onMounted, onUnmounted, ref, inject, shallowRef, computed } from 'vue';
|
||||
import tinycolor from 'tinycolor2';
|
||||
import { scrollToTop } from '@@/js/scroll.js';
|
||||
import XTabs from './MkPageHeader.tabs.vue';
|
||||
import type { Tab } from './MkPageHeader.tabs.vue';
|
||||
import { scrollToTop } from '@@/js/scroll.js';
|
||||
import type { PageHeaderItem } from '@/types/page-header.js';
|
||||
import type { PageMetadata } from '@/utility/page-metadata.js';
|
||||
import { globalEvents } from '@/events.js';
|
||||
import { injectReactiveMetadata } from '@/utility/page-metadata.js';
|
||||
import { $i, openAccountMenu as openAccountMenu_ } from '@/account.js';
|
||||
import type { PageHeaderItem } from '@/types/page-header.js';
|
||||
import type { PageMetadata } from '@/utility/page-metadata.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
overridePageMetadata?: PageMetadata;
|
||||
@ -114,7 +114,7 @@ let ro: ResizeObserver | null;
|
||||
|
||||
onMounted(() => {
|
||||
calcBg();
|
||||
globalEvents.on('themeChanged', calcBg);
|
||||
globalEvents.on('themeChanging', calcBg);
|
||||
|
||||
if (el.value && el.value.parentElement) {
|
||||
narrow.value = el.value.parentElement.offsetWidth < 500;
|
||||
@ -128,7 +128,7 @@ onMounted(() => {
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
globalEvents.off('themeChanged', calcBg);
|
||||
globalEvents.off('themeChanging', calcBg);
|
||||
if (ro) ro.disconnect();
|
||||
});
|
||||
</script>
|
||||
|
@ -5,17 +5,32 @@
|
||||
|
||||
import type { Directive } from 'vue';
|
||||
import { getBgColor } from '@/utility/get-bg-color.js';
|
||||
import { globalEvents } from '@/events.js';
|
||||
|
||||
const handlerMap = new WeakMap<any, any>();
|
||||
|
||||
export default {
|
||||
mounted(src, binding, vn) {
|
||||
const parentBg = getBgColor(src.parentElement) ?? 'transparent';
|
||||
function calc() {
|
||||
const parentBg = getBgColor(src.parentElement) ?? 'transparent';
|
||||
|
||||
const myBg = window.getComputedStyle(src).backgroundColor;
|
||||
const myBg = window.getComputedStyle(src).backgroundColor;
|
||||
|
||||
if (parentBg === myBg) {
|
||||
src.style.borderColor = 'var(--MI_THEME-divider)';
|
||||
} else {
|
||||
src.style.borderColor = myBg;
|
||||
if (parentBg === myBg) {
|
||||
src.style.borderColor = 'var(--MI_THEME-divider)';
|
||||
} else {
|
||||
src.style.borderColor = myBg;
|
||||
}
|
||||
}
|
||||
|
||||
handlerMap.set(src, calc);
|
||||
|
||||
calc();
|
||||
|
||||
globalEvents.on('themeChanged', calc);
|
||||
},
|
||||
|
||||
unmounted(src, binding, vn) {
|
||||
globalEvents.off('themeChanged', handlerMap.get(src));
|
||||
},
|
||||
} as Directive;
|
||||
|
@ -7,6 +7,7 @@ import { EventEmitter } from 'eventemitter3';
|
||||
import * as Misskey from 'misskey-js';
|
||||
|
||||
export const globalEvents = new EventEmitter<{
|
||||
themeChanging: () => void;
|
||||
themeChanged: () => void;
|
||||
clientNotification: (notification: Misskey.entities.Notification) => void;
|
||||
requestClearPageCache: () => void;
|
||||
|
@ -35,8 +35,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
<script lang="ts" setup>
|
||||
import { computed, onMounted, onUnmounted, ref, shallowRef, watch, nextTick } from 'vue';
|
||||
import tinycolor from 'tinycolor2';
|
||||
import { popupMenu } from '@/os.js';
|
||||
import { scrollToTop } from '@@/js/scroll.js';
|
||||
import { popupMenu } from '@/os.js';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import { globalEvents } from '@/events.js';
|
||||
import { injectReactiveMetadata } from '@/utility/page-metadata.js';
|
||||
@ -127,7 +127,7 @@ const calcBg = () => {
|
||||
|
||||
onMounted(() => {
|
||||
calcBg();
|
||||
globalEvents.on('themeChanged', calcBg);
|
||||
globalEvents.on('themeChanging', calcBg);
|
||||
|
||||
watch(() => [props.tab, props.tabs], () => {
|
||||
nextTick(() => {
|
||||
@ -147,7 +147,7 @@ onMounted(() => {
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
globalEvents.off('themeChanged', calcBg);
|
||||
globalEvents.off('themeChanging', calcBg);
|
||||
});
|
||||
</script>
|
||||
|
||||
|
@ -72,6 +72,9 @@ export function applyTheme(theme: Theme, persist = true) {
|
||||
|
||||
timeout = window.setTimeout(() => {
|
||||
document.documentElement.classList.remove('_themeChanging_');
|
||||
|
||||
// 色計算など再度行えるようにクライアント全体に通知
|
||||
globalEvents.emit('themeChanged');
|
||||
}, 1000);
|
||||
|
||||
const colorScheme = theme.base === 'dark' ? 'dark' : 'light';
|
||||
@ -108,7 +111,7 @@ export function applyTheme(theme: Theme, persist = true) {
|
||||
}
|
||||
|
||||
// 色計算など再度行えるようにクライアント全体に通知
|
||||
globalEvents.emit('themeChanged');
|
||||
globalEvents.emit('themeChanging');
|
||||
}
|
||||
|
||||
function compile(theme: Theme): Record<string, string> {
|
||||
|
Loading…
Reference in New Issue
Block a user