@moohng/dui
Version:
基于 Vue 3 的轻量级组件库
2 lines (1 loc) • 4.99 kB
JavaScript
this.toast=function(t){"use strict";var e=t.defineComponent({name:"dui-toast",props:{text:{type:String,default:""}},setup(e){const n=t.reactive({toastText:e.text,toastShow:!1});let r;return t.onUnmounted(()=>{r&&clearTimeout(r)}),{...t.toRefs(n),show:t=>{t&&(n.toastText=t),r&&clearTimeout(r),n.toastShow=!0,r=window.setTimeout(()=>{n.toastShow=!1},2e3)}}}});e.render=function(e,n,r,o,u,i){return t.openBlock(),t.createBlock("div",{class:["dui-toast",{show:e.toastShow}]},[t.renderSlot(e.$slots,"default",{},()=>[t.createTextVNode(t.toDisplayString(e.toastText),1)])],2)},e.__file="src/components/toast/toast.vue";var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r=function(t){return t&&t.Math==Math&&t},o=r("object"==typeof globalThis&&globalThis)||r("object"==typeof window&&window)||r("object"==typeof self&&self)||r("object"==typeof n&&n)||function(){return this}()||Function("return this")(),u=function(t){try{return!!t()}catch(t){return!0}},i=!u((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),c={}.propertyIsEnumerable,a=Object.getOwnPropertyDescriptor,f={f:a&&!c.call({1:2},1)?function(t){var e=a(this,t);return!!e&&e.enumerable}:c},l=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},s={}.toString,p="".split,y=u((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==function(t){return s.call(t).slice(8,-1)}(t)?p.call(t,""):Object(t)}:Object,d=function(t){return y(function(t){if(null==t)throw TypeError("Can't call method on "+t);return t}(t))},h=function(t){return"object"==typeof t?null!==t:"function"==typeof t},w=function(t,e){if(!h(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!h(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!h(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!h(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")},b={}.hasOwnProperty,g=function(t,e){return b.call(t,e)},m=o.document,v=h(m)&&h(m.createElement),T=!i&&!u((function(){return 7!=Object.defineProperty((t="div",v?m.createElement(t):{}),"a",{get:function(){return 7}}).a;var t})),j=Object.getOwnPropertyDescriptor,S={f:i?j:function(t,e){if(t=d(t),e=w(e,!0),T)try{return j(t,e)}catch(t){}if(g(t,e))return l(!f.f.call(t,e),t[e])}},O=/#|\.prototype\./,E=function(t,e){var n=I[P(t)];return n==C||n!=x&&("function"==typeof e?u(e):!!e)},P=E.normalize=function(t){return String(t).replace(O,".").toLowerCase()},I=E.data={},x=E.NATIVE="N",C=E.POLYFILL="P",D=E,A={},F=function(t,e,n){if(function(t){if("function"!=typeof t)throw TypeError(String(t)+" is not a function")}(t),void 0===e)return t;switch(n){case 0:return function(){return t.call(e)};case 1:return function(n){return t.call(e,n)};case 2:return function(n,r){return t.call(e,n,r)};case 3:return function(n,r,o){return t.call(e,n,r,o)}}return function(){return t.apply(e,arguments)}},L=function(t){if(!h(t))throw TypeError(String(t)+" is not an object");return t},M=Object.defineProperty,N={f:i?M:function(t,e,n){if(L(t),e=w(e,!0),L(n),T)try{return M(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},V=i?function(t,e,n){return N.f(t,e,l(1,n))}:function(t,e,n){return t[e]=n,t},k=S.f,z=function(t){var e=function(e,n,r){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,r)}return t.apply(this,arguments)};return e.prototype=t.prototype,e},B=function(t,e){var n,r,u,i,c,a,f,l,s=t.target,p=t.global,y=t.stat,d=t.proto,h=p?o:y?o[s]:(o[s]||{}).prototype,w=p?A:A[s]||(A[s]={}),b=w.prototype;for(u in e)n=!D(p?u:s+(y?".":"#")+u,t.forced)&&h&&g(h,u),c=w[u],n&&(a=t.noTargetGet?(l=k(h,u))&&l.value:h[u]),i=n&&a?a:e[u],n&&typeof c==typeof i||(f=t.bind&&n?F(i,o):t.wrap&&n?z(i):d&&"function"==typeof i?F(Function.call,i):i,(t.sham||i&&i.sham||c&&c.sham)&&V(f,"sham",!0),w[u]=f,d&&(g(A,r=s+"Prototype")||V(A,r,{}),A[r][u]=i,t.real&&b&&!b[u]&&V(b,u,i)))},$=function(t){return"function"==typeof t?t:void 0},_=function(t,e){return arguments.length<2?$(A[t])||$(o[t]):A[t]&&A[t][e]||o[t]&&o[t][e]}("navigator","userAgent")||"",G=[].slice,R=function(t){return function(e,n){var r=arguments.length>2,o=r?G.call(arguments,2):void 0;return t(r?function(){("function"==typeof e?e:Function(e)).apply(this,o)}:e,n)}};B({global:!0,bind:!0,forced:/MSIE .\./.test(_)},{setTimeout:R(o.setTimeout),setInterval:R(o.setInterval)}),B({target:"Date",stat:!0},{now:function(){return(new Date).getTime()}});A.Date.now;return{install:n=>{let r;n.config.globalProperties.$toast=(n="")=>{if(!r){const{instance:n}=function(e){const n=document.createElement("div");document.body.appendChild(n);const r=t.createApp(e);return{instance:r.mount(n),unmount:()=>{r.unmount(n),document.body.removeChild(n)}}}(e);r=n}r.show(n)},n.component(e.name,e)}}}(Vue);