fix(frontend): テーマ切り替え時に一部の色が変わらない問題を修正

This commit is contained in:
syuilo
2025-03-10 10:05:50 +09:00
parent 6419af2179
commit 4df9083bf0
6 changed files with 35 additions and 15 deletions

View File

@@ -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;