UNPKG

@ued_fpi/data-visual

Version:

<br /> <br /> <div style="text-align:center"> <b style="font-size:30px">@ued_fpi/data-visual</b> <p>基于Vite4+TypeScript的Vue3大屏组件库开发框架</p> <img style="display:inline" src="https://img.shields.io/npm/v/@ued_fpi/data-visual" />

102 lines (97 loc) 2.91 kB
'use strict'; Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); const vue = require('vue'); const index = require('./wgms/config/index.js'); const index$1 = require('./ipes/config/index.js'); const index$2 = require('./aims/config/index.js'); const index$3 = require('./bmp/config/index.js'); const install = (comp) => { comp.install = (app) => { const name = comp.name || comp.__name; app.component(name, comp); }; return comp; }; const setDomain = (domain, type) => { switch (type) { case "aims": index$2.default.domain = domain; break; case "ipes": index$1.default.domain = domain; break; case "bmp": index$3.default.domain = domain; break; case "wgms": index.default.domain = domain; break; default: index.default.domain = domain; index$1.default.domain = domain; index$2.default.domain = domain; index$3.default.domain = domain; break; } }; const useThemeValue = (styleVariables) => { return getComputedStyle(document.documentElement).getPropertyValue(styleVariables); }; const useThemeHook = () => { const htmlDom = document.querySelector("html"); if (!htmlDom) return { isDark: vue.ref(false) }; const isDark = vue.ref(!!htmlDom.classList.contains("dark")); const observer = new MutationObserver((mutationsList) => { for (const mutation of mutationsList) { if (mutation.type === "attributes" && mutation.attributeName === "class") { const currentClass = mutation.target.className; isDark.value = currentClass.includes("dark"); } } }); const observerOptions = { attributes: true, attributeFilter: ["class"] }; observer.observe(htmlDom, observerOptions); return { isDark }; }; function replaceVarStrings(obj) { const newObj = Array.isArray(obj) ? [] : {}; for (const key in obj) { if (typeof obj[key] === "object") { newObj[key] = replaceVarStrings(obj[key]); } else if (typeof obj[key] === "string" && obj[key].startsWith("var(") && obj[key].endsWith(")")) { const varContent = obj[key].slice(4, -1); newObj[key] = useThemeValue(varContent); } else { newObj[key] = obj[key]; } } return newObj; } const setConfig = (type, resetFn) => { switch (type) { case "aims": Object.assign(index$2.default, resetFn(index$2.default)); break; case "wgms": Object.assign(index.default, resetFn(index.default)); break; case "ipes": Object.assign(index$1.default, resetFn(index$1.default)); break; case "bmp": Object.assign(index$3.default, resetFn(index$3.default)); break; } }; exports.install = install; exports.replaceVarStrings = replaceVarStrings; exports.setConfig = setConfig; exports.setDomain = setDomain; exports.useThemeHook = useThemeHook; exports.useThemeValue = useThemeValue;