UNPKG

@ccos/webos-vue

Version:

A Web-Ui Framework for Skyworth/Coocaa TV

33 lines (32 loc) 708 B
import { createApp } from "vue"; import Toast from "./index32.mjs"; let toastDom = null; let app = null; const TvToast = (options) => { const dom = document.body.querySelector(".my-toast"); if (!dom) { toastDom = document.createElement("div"); toastDom.className = `my-toast`; document.body.appendChild(toastDom); } else { app.unmount(); } app = createApp(Toast, { ...options, hide() { if (app) { app.unmount(); app = null; } if (toastDom) { document.body.removeChild(toastDom); toastDom = null; } } }); return app.mount(toastDom); }; TvToast.show = (options) => TvToast(options).show(); export { TvToast };