ray-template/assets/index-4b024853.js
XiaoDaiGua-Ray 5dda627d63 v4.2.3
2023-10-14 17:20:31 +08:00

2 lines
1.5 KiB
JavaScript

import{g as l,o as u,i as f,h as c}from"./index-0017ec2b.js";const p={src:{type:String,required:!0},iframeWrapperClass:{type:String,default:null},frameborder:{type:Number,default:0},width:{type:[String,Number],default:"100%"},height:{type:[String,Number],default:"100%"},allow:{type:String,default:null},name:{type:String,default:null},title:{type:String,default:null},onSuccess:{type:[Function,Array],default:null},onError:{type:[Function,Array],default:null},customSpinProps:{type:Object,default:()=>({})},lazy:{type:Boolean,default:!0},wrapperClass:{type:String,default:null}},y=Vue.defineComponent({name:"RIframe",props:p,setup(e,{expose:m}){const d=Vue.computed(()=>({"--ray-iframe-frameborder":l(e.frameborder),"--ray-iframe-width":l(e.width),"--ray-iframe-height":l(e.height)})),a=Vue.ref(),n=Vue.ref(!0),i=r=>{n.value=!1;const{onSuccess:t}=e;t&&c(t,a.value,r)},o=r=>{n.value=!1;const{onError:t}=e;t&&c(t,r)},s=()=>a.value;return m({iframeInst:a}),Vue.onMounted(()=>{u(s(),"load",i.bind(this)),u(s(),"error",o)}),Vue.onBeforeUnmount(()=>{f(s(),"load",i),f(s(),"error",o)}),{cssVars:d,iframeRef:a,spinShow:n}},render(){return Vue.createVNode("div",{class:["ray-iframe",this.iframeWrapperClass],style:[this.cssVars]},[Vue.createVNode(naive.NSpin,Vue.mergeProps(this.customSpinProps,{show:this.spinShow}),{...this.$slots,default:()=>Vue.createVNode("iframe",Vue.mergeProps({class:["ray-iframe__container",this.wrapperClass],ref:"iframeRef",src:this.src,allow:this.allow,name:this.name,title:this.title},{loading:this.lazy?"lazy":null}),null)})])}});export{y as R};