/** * {} * @author yutent * @date 2023/08/10 10:19:12 */ import { Component } from 'wkit' import { WKITD_COMPONENTS } from './constants.js' class Wkitd extends WeakMap { /** * 广播式推送更新 */ broadcast() { for (let it of WKITD_COMPONENTS) { it.$requestUpdate() } } /** * 注册缓存组件 */ assign(target) { WKITD_COMPONENTS.add(target) } /** * 取消注册 */ deassign(target) { WKITD_COMPONENTS.add(target) } } const __WKITD__ = new Wkitd() Object.defineProperty(window, 'wkitd', { get() { return __WKITD__ }, set(val) { console.error('Can not set readonly property wkitd of window') }, enumerable: false })