mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-05-09 12:09:11 +08:00
2 lines
1.5 KiB
JavaScript
2 lines
1.5 KiB
JavaScript
import{g as i,o as u,i as f,h as c}from"./index-f0e321ba.js";const y=Vue.defineComponent({name:"RayIframe",props:{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}},setup(e,{expose:m}){const d=Vue.computed(()=>({"--ray-iframe-frameborder":i(e.frameborder),"--ray-iframe-width":i(e.width),"--ray-iframe-height":i(e.height)})),a=Vue.ref(),n=Vue.ref(!0),o=r=>{n.value=!1;const{onSuccess:t}=e;t&&c(t,a.value,r)},l=r=>{n.value=!1;const{onError:t}=e;t&&c(t,r)},s=()=>a.value;return m({iframeInst:a}),Vue.onMounted(()=>{u(s(),"load",o.bind(this)),u(s(),"error",l)}),Vue.onBeforeUnmount(()=>{f(s(),"load",o),f(s(),"error",l)}),{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",ref:"iframeRef",src:this.src,allow:this.allow,name:this.name,title:this.title},{loading:this.lazy?"lazy":null}),null)})])}});export{y as R};
|