|
34 | 34 | }
|
35 | 35 | // #endif
|
36 | 36 | // #ifdef H5 || APP-PLUS-NVUE || MP-360
|
37 |
| - var windowWidth = uni.getSystemInfoSync().windowWidth, |
| 37 | + var { |
| 38 | + windowWidth, |
| 39 | + platform |
| 40 | + } = uni.getSystemInfoSync(), |
38 | 41 | cfg = require('./libs/config.js');
|
39 | 42 | // #endif
|
40 | 43 | // #ifdef APP-PLUS-NVUE
|
|
63 | 66 | * @event {Function} imgtap 图片点击事件
|
64 | 67 | * @event {Function} linkpress 链接点击事件
|
65 | 68 | * @author JinYufeng
|
66 |
| - * @version 20200728 |
| 69 | + * @version 20200828 |
67 | 70 | * @listens MIT
|
68 | 71 | */
|
69 | 72 | export default {
|
|
216 | 219 | '</div><script>"use strict";function e(e){if(window.__dcloud_weex_postMessage||window.__dcloud_weex_){var t={data:[e]};window.__dcloud_weex_postMessage?window.__dcloud_weex_postMessage(t):window.__dcloud_weex_.postMessage(JSON.stringify(t))}}document.body.onclick=function(){e({action:"click"})},' +
|
217 | 220 | (this.showWithAnimation ? 'document.body.style.animation="_show .5s",' : '') +
|
218 | 221 | 'setTimeout(function(){e({action:"load",text:document.body.innerText,height:document.getElementById("parser").scrollHeight})},50);\x3c/script>';
|
| 222 | + if (platform == 'android') html = html.replace(/%/g, '%25'); |
219 | 223 | this.$refs.web.evalJs("document.write('" + html.replace(/'/g, "\\'") + "');document.close()");
|
220 | 224 | }
|
221 | 225 | this.$refs.web.evalJs(
|
222 | 226 | 'var t=document.getElementsByTagName("title");t.length&&e({action:"getTitle",title:t[0].innerText});for(var o,n=document.getElementsByTagName("style"),r=1;o=n[r++];)o.innerHTML=o.innerHTML.replace(/body/g,"#parser");for(var a,c=document.getElementsByTagName("img"),s=[],i=0==c.length,d=0,l=0,g=0;a=c[l];l++)parseInt(a.style.width||a.getAttribute("width"))>' +
|
223 | 227 | windowWidth + '&&(a.style.height="auto"),a.onload=function(){++d==c.length&&(i=!0)},a.onerror=function(){++d==c.length&&(i=!0),' + (cfg.errorImg ? 'this.src="' + cfg.errorImg + '",' : '') +
|
224 |
| - 'e({action:"error",source:"img",target:this})},a.hasAttribute("ignore")||"A"==a.parentElement.nodeName||(a.i=g++,s.push(a.src),a.onclick=function(){e({action:"preview",img:{i:this.i,src:this.src}})});e({action:"getImgList",imgList:s});for(var u,m=document.getElementsByTagName("a"),f=0;u=m[f];f++)u.onclick=function(){var t,o=this.getAttribute("href");if("#"==o[0]){var n=document.getElementById(o.substr(1));n&&(t=n.offsetTop)}return e({action:"linkpress",href:o,offset:t}),!1};for(var h,y=document.getElementsByTagName("video"),v=0;h=y[v];v++)h.style.maxWidth="100%",h.onerror=function(){e({action:"error",source:"video",target:this})}' + |
| 228 | + 'e({action:"error",source:"img",target:this})},a.hasAttribute("ignore")||"A"==a.parentElement.nodeName||(a.i=g++,s.push(a.getAttribute("original-src")||a.src||a.getAttribute("data-src")),a.onclick=function(){e({action:"preview",img:{i:this.i,src:this.src}})});e({action:"getImgList",imgList:s});for(var u,m=document.getElementsByTagName("a"),f=0;u=m[f];f++)u.onclick=function(){var t,o=this.getAttribute("href");if("#"==o[0]){var n=document.getElementById(o.substr(1));n&&(t=n.offsetTop)}return e({action:"linkpress",href:o,offset:t}),!1};for(var h,y=document.getElementsByTagName("video"),v=0;h=y[v];v++)h.style.maxWidth="100%",h.onerror=function(){e({action:"error",source:"video",target:this})}' + |
225 | 229 | (this.autopause ? ',h.onplay=function(){for(var e,t=0;e=y[t];t++)e!=this&&e.pause()}' : '') +
|
226 | 230 | ';for(var _,p=document.getElementsByTagName("audio"),w=0;_=p[w];w++)_.onerror=function(){e({action:"error",source:"audio",target:this})};' +
|
227 | 231 | (this.autoscroll ? 'for(var T,E=document.getElementsByTagName("table"),B=0;T=E[B];B++){var N=document.createElement("div");N.style.overflow="scroll",T.parentNode.replaceChild(N,T),N.appendChild(T)}' : '') +
|
|
284 | 288 | }
|
285 | 289 | if (!img.hasAttribute('ignore') && img.parentElement.nodeName != 'A') {
|
286 | 290 | img.i = j++;
|
287 |
| - _ts.imgList.push(img.src || img.getAttribute('data-src')); |
| 291 | + _ts.imgList.push(img.getAttribute('original-src') || img.src || img.getAttribute('data-src')); |
288 | 292 | img.onclick = function() {
|
289 | 293 | var preview = true;
|
290 | 294 | this.ignore = () => preview = false;
|
|
525 | 529 | style += '</style>';
|
526 | 530 | html = style + html;
|
527 | 531 | }
|
528 |
| - // 处理rpx |
| 532 | + // 处理 rpx |
529 | 533 | if (html.includes('rpx'))
|
530 | 534 | html = html.replace(/[0-9.]+\s*rpx/g, $ => (parseFloat($) * windowWidth / 750) + 'px');
|
531 | 535 | return html;
|
|
0 commit comments