2023-07-07 19:22:30 +00:00
|
|
|
import { Directive } from "vue";
|
|
|
|
|
|
|
|
export default {
|
2023-07-23 13:31:28 +00:00
|
|
|
mounted(src, binding, vn) {
|
|
|
|
const getBgColor = (el: HTMLElement) => {
|
|
|
|
const style = window.getComputedStyle(el);
|
|
|
|
if (
|
|
|
|
style.backgroundColor &&
|
|
|
|
!["rgba(0, 0, 0, 0)", "rgba(0,0,0,0)", "transparent"].includes(
|
2024-04-08 01:10:23 +00:00
|
|
|
style.backgroundColor,
|
2023-07-23 13:31:28 +00:00
|
|
|
)
|
|
|
|
) {
|
|
|
|
return style.backgroundColor;
|
|
|
|
} else {
|
|
|
|
return el.parentElement
|
|
|
|
? getBgColor(el.parentElement)
|
|
|
|
: "transparent";
|
|
|
|
}
|
|
|
|
};
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
const parentBg = getBgColor(src.parentElement);
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
const myBg = window.getComputedStyle(src).backgroundColor;
|
2023-07-07 19:22:30 +00:00
|
|
|
|
2023-07-23 13:31:28 +00:00
|
|
|
if (parentBg === myBg) {
|
|
|
|
src.style.borderColor = "var(--divider)";
|
|
|
|
} else {
|
|
|
|
src.style.borderColor = myBg;
|
|
|
|
}
|
|
|
|
},
|
2023-07-07 19:22:30 +00:00
|
|
|
} as Directive;
|