mirror of
https://github.com/XiaoDaiGua-Ray/ray-template.git
synced 2025-04-06 03:57:49 +08:00
2 lines
1.5 KiB
JavaScript
2 lines
1.5 KiB
JavaScript
import{i as l,o,n as u,k as f}from"./index-4cfc8ec4.js";const m={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}},h=Vue.defineComponent({name:"RIframe",props:m,setup(r,{expose:c}){const d=Vue.computed(()=>({"--ray-iframe-frameborder":l(r.frameborder),"--ray-iframe-width":l(r.width),"--ray-iframe-height":l(r.height)})),e=Vue.ref(),s=Vue.ref(!0),n=a=>{s.value=!1;const{onSuccess:t}=r;t&&f(t,e.value,a)},i=a=>{s.value=!1;const{onError:t}=r;t&&f(t,a)};return c({iframeInst:e}),Vue.onMounted(()=>{o(e.value,"load",n.bind(this)),o(e.value,"error",i)}),Vue.onBeforeUnmount(()=>{u(e.value,"load",n),u(e.value,"error",i)}),{cssVars:d,iframeRef:e,spinShow:s}},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{h as R};
|