2 lines
27 KiB
JavaScript
2 lines
27 KiB
JavaScript
|
import{y as t,z as s,A as e,B as i,C as n,D as a,h as r,i as o,w as l,E as h,F as c,G as d,l as p,n as u,H as m,I as g,j as f,J as y,K as b,L as x,M as k,t as v,N as w,O as T,P as _,f as $,Q as N,R as L,S as O,d as S,r as C,o as I,T as j,p as R,q as A}from"./index-849cf30e.js";import{_ as z}from"./_plugin-vue_export-helper.1b428a4d.js";var B={abbr:!0,b:!0,big:!0,code:!0,del:!0,em:!0,i:!0,ins:!0,label:!0,q:!0,small:!0,span:!0,strong:!0,sub:!0,sup:!0};const E={isInline:function(t,s){return B[t]||-1!==(s||"").indexOf("display:inline")}},V=t=>{t.$wxs||(t.$wxs=[]),t.$wxs.push("handler"),t.mixins||(t.mixins=[]),t.mixins.push({beforeCreate(){this.handler=E}})},q={name:"node",options:{},data:()=>({ctrl:{}}),props:{name:String,attrs:{type:Object,default:()=>({})},childs:Array,opts:Array},components:{},mounted(){if(this.$nextTick((()=>{for(this.root=this.$parent;"u-parse"!==this.root.$options.name;this.root=this.root.$parent);})),this.opts[0]){let s;for(s=this.childs.length;s--&&"img"!==this.childs[s].name;);-1!==s&&(this.observer=t(this).relativeToViewport({top:500,bottom:500}),this.observer.observe("._img",(t=>{t.intersectionRatio&&(this.$set(this.ctrl,"load",1),this.observer.disconnect())})))}},beforeDestroy(){this.observer&&this.observer.disconnect()},methods:{play(t){if(this.root.$emit("play"),this.root.pauseVideo){let e=!1;const i=t.target.id;for(let t=this.root._videos.length;t--;)this.root._videos[t].id===i?e=!0:this.root._videos[t].pause();if(!e){const t=s(i,this);t.id=i,this.root.playbackRate&&t.playbackRate(this.root.playbackRate),this.root._videos.push(t)}}},imgTap(t){const s=this.childs[t.currentTarget.dataset.i];s.a?this.linkTap(s.a):s.attrs.ignore||(s.attrs.src=s.attrs.src||s.attrs["data-src"],this.root.$emit("imgtap",s.attrs),this.root.previewImg&&e({current:parseInt(s.attrs.i),urls:this.root.imgList}))},imgLongTap(t){},imgLoad(t){const s=t.currentTarget.dataset.i;(this.opts[1]&&!this.ctrl[s]||-1===this.ctrl[s])&&this.$set(this.ctrl,s,1),this.checkReady()},checkReady(){this.root.lazyLoad||(this.root._unloadimgs-=1,this.root._unloadimgs||setTimeout((()=>{this.root.getRect().then((t=>{this.root.$emit("ready",t)})).catch((()=>{this.root.$emit("ready",{})}))}),350))},linkTap(t){const s=t.currentTarget?this.childs[t.currentTarget.dataset.i]:{},e=s.attrs||t,a=e.href;this.root.$emit("linktap",Object.assign({innerText:this.root.getText(s.children||[])},e)),a&&("#"===a[0]?this.root.navigateTo(a.substring(1)).catch((()=>{})):a.split("?")[0].includes("://")?this.root.copyLink&&window.open(a):i({url:a,fail(){n({url:a,fail(){}})}}))},mediaError(t){const s=t.currentTarget.dataset.i,e=this.childs[s];if("video"===e.name||"audio"===e.name){let t=(this.ctrl[s]||0)+1;if(t>e.src.length&&(t=0),t<e.src.length)return void this.$set(this.ctrl,s,t)}else if("img"===e.name){if(this.opts[0]&&!this.ctrl.load)return;this.opts[2]&&this.$set(this.ctrl,s,-1),this.checkReady()}this.root&&this.root.$emit("error",{source:e.name,attrs:e.attrs})}}};V(q);const D=z(q,[["render",function(t,s,e,i,n,_){const $=x,N=k,L=a("node",!0),O=v,S=w,C=T;return r(),o(O,{id:e.attrs.id,class:m("_block _"+e.name+" "+e.attrs.class),style:u(e.attrs.style)},{default:l((()=>[(r(!0),h(c,null,d(e.childs,((i,a)=>(r(),h(c,{key:a},[p(" 图片 "),p(" 占位图 "),"img"===i.name&&!i.t&&(e.opts[1]&&!n.ctrl[a]||n.ctrl[a]<0)?(r(),o($,{key:0,class:"_img",style:u(i.attrs.style),src:n.ctrl[a]<0?e.opts[2]:e.opts[1],mode:"widthFix"},null,8,["style","src"])):p("v-if",!0),p(" 显示图片 "),"img"===i.name?(r(),h("img",{key:1,id:i.attrs.id,class:m("_img "+i.attrs.class),style:u((-1===n.ctrl[a]?"display:none;":"")+i.attrs.style),src:i.attrs.src||(n.ctrl.load?i.attrs["data-src"]:""),"data-i":a,onLoad:s[0]||(s[0]=(...t)=>_.imgLoad&&_.imgLoad(...t)),onError:s[1]||(s[1]=(...t)=>_.mediaError&&_.mediaError(...t)),onClick:s[2]||(s[2]=g(((...t)=>_.imgTap&&_.imgTap(...t)),["stop"])),onLongpress:s[3]||(s[3]=(...t)=>_.imgLongTap&&_.imgLongTap(...t))},null,46,["id","src","data-i"])):i.text?(r(),h(c,{key:2},[p(" 文本 "),f(N,{decode:""},{default:l((()=>[y(b(i.text),1)])),_:2},1024)],2112)):"br"===i.name?
|