You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
27 KiB
2 lines
27 KiB
11 months ago
|
import{r as t,o as e,c as s,w as i,b as n,F as a,d as r,n as o,e as l,j as h,l as c,f as d,t as p,a as g,g as m,k as u,i as f,P as y,a7 as b,A as x}from"./index-ae8bbb19.js";import{_ as k}from"./_plugin-vue_export-helper.1b428a4d.js";var v={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 w={isInline:function(t,e){return v[t]||-1!==(e||"").indexOf("display:inline")}},T=t=>{t.$wxs||(t.$wxs=[]),t.$wxs.push("handler"),t.mixins||(t.mixins=[]),t.mixins.push({beforeCreate(){this.handler=w}})},_={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;"mp-html"!==this.root.$options.name;this.root=this.root.$parent);})),this.opts[0]){let t;for(t=this.childs.length;t--&&"img"!==this.childs[t].name;);-1!==t&&(this.observer=uni.createIntersectionObserver(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 s=t.target.id;for(let t=this.root._videos.length;t--;)this.root._videos[t].id===s?e=!0:this.root._videos[t].pause();if(!e){const t=uni.createVideoContext(s,this);t.id=s,this.root.playbackRate&&t.playbackRate(this.root.playbackRate),this.root._videos.push(t)}}},imgTap(t){const e=this.childs[t.currentTarget.dataset.i];e.a?this.linkTap(e.a):e.attrs.ignore||(e.attrs.src=e.attrs.src||e.attrs["data-src"],this.root.$emit("imgtap",e.attrs),this.root.previewImg&&uni.previewImage({current:parseInt(e.attrs.i),urls:this.root.imgList}))},imgLongTap(t){},imgLoad(t){const e=t.currentTarget.dataset.i;(this.opts[1]&&!this.ctrl[e]||-1===this.ctrl[e])&&this.$set(this.ctrl,e,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 e=t.currentTarget?this.childs[t.currentTarget.dataset.i]:{},s=e.attrs||t,i=s.href.replace("client://","");this.root.$emit("linktap",Object.assign({innerText:this.root.getText(e.children||[])},s)),i&&("#"===i[0]?this.root.navigateTo(i.substring(1)).catch((()=>{})):i.split("?")[0].includes("://")?this.root.copyLink&&window.open(i):uni.navigateTo({url:"/"+i,fail(){uni.switchTab({url:"/"+i,fail(){}})}}))},mediaError(t){const e=t.currentTarget.dataset.i,s=this.childs[e];if("video"===s.name||"audio"===s.name){let t=(this.ctrl[e]||0)+1;if(t>s.src.length&&(t=0),t<s.src.length)return void this.$set(this.ctrl,e,t)}else if("img"===s.name){if(this.opts[0]&&!this.ctrl.load)return;this.opts[2]&&this.$set(this.ctrl,e,-1),this.checkReady()}this.root&&this.root.$emit("error",{source:s.name,attrs:s.attrs})}}};T(_);const $=k(_,[["render",function(x,k,v,w,T,_){const $=m,N=u,S=t("node",!0),L=f,O=y,I=b;return e(),s(L,{id:v.attrs.id,class:h("_block _"+v.name+" "+v.attrs.class),style:o(v.attrs.style)},{default:i((()=>[(e(!0),n(a,null,r(v.childs,((t,m)=>(e(),n(a,{key:m},["img"===t.name&&!t.t&&(v.opts[1]&&!T.ctrl[m]||T.ctrl[m]<0)?(e(),s($,{key:0,class:"_img",style:o(t.attrs.style),src:T.ctrl[m]<0?v.opts[2]:v.opts[1],mode:"widthFix"},null,8,["style","src"])):l("",!0),"img"===t.name?(e(),n("img",{key:1,id:t.attrs.id,class:h("_img "+t.attrs.class),style:o((-1===T.ctrl[m]?"display:none;":"")+t.attrs.style),src:t.attrs.src||(T.ctrl.load?t.attrs["data-src"]:""),"data-i":m,onLoad:k[0]||(k[0]=(...t)=>_.imgLoad&&_.imgLoad(...t)),onError:k[1]||(k[1]=(...t)=>_.mediaError&&_.mediaError(...t)),onClick:k[2]||(k[2]=c(((...t)=>_.imgTap&&_.imgTap(...t)),["stop"])),onLongpress:k[3]||(k[3]=(...t)=>_.imgLongTap&&_.imgLongTap(...t))},null,46,["id","src","data-i"])):t.text?(e(),s(N,{key:2,decode:""},{default:i((()=>[d(p(t.text),1)])),_:2},1024)):"br"===t.name?(e(),s(N,{key:3},{default:i((()=>[d("\\n")])),_:1})):"a"===t.name
|