suyuan/public/mobile/assets/u-parse.a47c6099.js

2 lines
7.1 KiB
JavaScript
Raw Permalink Normal View History

2023-11-21 11:51:27 +08:00
import{Y as t,aw as e,ax as i,H as r,G as s,a2 as o,o as a,c as n,w as l,E as h,h as d,b as c,a7 as u,x as f,k as m}from"./index.26a6cf84.js";import{_ as p}from"./plugin-vue_export-helper.21dcd24c.js";v(" , ,\t,\r,\n,\f"),v("allowfullscreen,autoplay,autostart,controls,ignore,loop,muted"),v("address,article,aside,body,caption,center,cite,footer,header,html,nav,pre,section"),v("area,base,canvas,frame,iframe,input,link,map,meta,param,script,source,style,svg,textarea,title,track,wbr"),v("a,colgroup,fieldset,legend"),v("area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr"),v("a,abbr,ad,audio,b,blockquote,br,code,col,colgroup,dd,del,dl,dt,div,em,fieldset,h1,h2,h3,h4,h5,h6,hr,i,img,ins,label,legend,li,ol,p,q,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video");var g={address:"font-style:italic",big:"display:inline;font-size:1.2em",blockquote:"background-color:#f6f6f6;border-left:3px solid #dbdbdb;color:#6c6c6c;padding:5px 0 5px 10px",caption:"display:table-caption;text-align:center",center:"text-align:center",cite:"font-style:italic",dd:"margin-left:40px",mark:"background-color:yellow",pre:"font-family:monospace;white-space:pre;overflow:scroll",s:"text-decoration:line-through",small:"display:inline;font-size:0.8em",u:"text-decoration:underline"};function v(t){for(var e=Object.create(null),i=t.split(","),r=i.length;r--;)e[i[r]]=!0;return e}var{windowWidth:b,platform:y}=t();var x=p({name:"parser",emits:["parse","load","ready","error","imgtap","linkpress"],data(){return{uid:this._uid,showAm:"",nodes:[]}},props:{html:String,autopause:{type:Boolean,default:!0},preview:{type:Boolean,default:!0},autoscroll:Boolean,autosetTitle:{type:Boolean,default:!0},domain:String,lazyLoad:Boolean,selectable:Boolean,tagStyle:Object,showWithAnimation:Boolean,useAnchor:Boolean},watch:{html(t){this.setContent(t)}},created(){this.imgList=[],this.imgList.each=function(t){for(var e=0,i=this.length;e<i;e++)this.setItem(e,t(this[e],e,this))},this.imgList.setItem=function(t,e){if(null!=t&&e){if(0==e.indexOf("http")&&this.includes(e)){for(var i,r=e.split("://")[0],s=r.length;(i=e[s])&&("/"!=i||"/"==e[s-1]||"/"==e[s+1]);s++)r+=Math.random()>.5?i.toUpperCase():i;return r+=e.substr(s),this[t]=r}if(this[t]=e,e.includes("data:image"))if(!e.match(/data:image\/(\S+?);(\S+?),(.+)/))return}}},mounted(){this.document=document.getElementById("rtf"+this._uid),this.html&&this.setContent(this.html)},beforeUnmount(){this._observer&&this._observer.disconnect(),this.imgList.each((t=>{})),clearInterval(this._timer)},methods:{setContent(t,s){if(t){var o=document.createElement("div");s?this.rtf?this.rtf.appendChild(o):this.rtf=o:(this.rtf&&this.rtf.parentNode.removeChild(this.rtf),this.rtf=o),o.innerHTML=this._handleHtml(t,s);for(var a,n=this.rtf.getElementsByTagName("style"),l=0;a=n[l++];)a.innerHTML=a.innerHTML.replace(/body/g,"#rtf"+this._uid),a.setAttribute("scoped","true");!this._observer&&this.lazyLoad&&IntersectionObserver&&(this._observer=new IntersectionObserver((t=>{for(let e,i=0;e=t[i++];)e.isIntersecting&&(e.target.src=e.target.getAttribute("data-src"),e.target.removeAttribute("data-src"),this._observer.unobserve(e.target))}),{rootMargin:"500px 0px 500px 0px"}));var h=this,d=this.rtf.getElementsByTagName("title");d.length&&this.autosetTitle&&e({title:d[0].innerText});var c=t=>{var e=t.getAttribute("src");this.domain&&e&&("/"==e[0]?"/"==e[1]?t.src=(this.domain.includes("://")?this.domain.split("://")[0]:"")+":"+e:t.src=this.domain+e:e.includes("://")||0==e.indexOf("data:")||(t.src=this.domain+"/"+e))};this.imgList.length=0;var u=this.rtf.getElementsByTagName("img");for(let t,e=0,r=0;t=u[e];e++)parseInt(t.style.width||t.getAttribute("width"))>b&&(t.style.height="auto"),c(t),t.hasAttribute("ignore")||"A"==t.parentElement.nodeName||(t.i=r++,h.imgList.push(t.getAttribute("original-src")||t.src||t.getAttribute("data-src")),t.onclick=function(t){t.stopPropagation();var e=h.preview;this.ignore=()=>e=!1,h.$emit("imgtap",this),e&&i({current:this.i,urls:h.imgList})}),t.onerror=function(){