Skip to content

Commit 767226b

Browse files
committed
1. 更新uparse
2. 优化tabs组建在头条小程序的布局
1 parent a32cd0f commit 767226b

File tree

6 files changed

+19
-12
lines changed

6 files changed

+19
-12
lines changed

store/$u.mixin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ try{
1010
}
1111

1212
module.exports = {
13-
created() {
13+
beforeCreate() {
1414
// 将vuex方法挂在到$u中
1515
// 使用方法为:如果要修改vuex的state中的user.name变量为"史诗" => this.$u.vuex('user.name', '史诗')
1616
// 如果要修改vuex的state的version变量为1.0.1 => this.$u.vuex('version', '1.0.1')

uview-ui/components/u-parse/libs/MpHtmlParser.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* html 解析器
33
* @tutorial https://github.com/jin-yufeng/Parser
4-
* @version 20200728
4+
* @version 20200828
55
* @author JinYufeng
66
* @listens MIT
77
*/
@@ -243,7 +243,7 @@ MpHtmlParser.prototype.setNode = function() {
243243
}
244244
var width;
245245
if (styleObj.width) width = styleObj.width;
246-
else if (attrs.width) width = attrs.width.includes('%') ? attrs.width : attrs.width + 'px';
246+
else if (attrs.width) width = attrs.width.includes('%') ? attrs.width : parseFloat(attrs.width) + 'px';
247247
if (width) {
248248
styleObj.width = width;
249249
attrs.width = '100%';
@@ -256,7 +256,7 @@ MpHtmlParser.prototype.setNode = function() {
256256
attrs.height = styleObj.height;
257257
styleObj.height = '';
258258
} else if (attrs.height && !attrs.height.includes('%'))
259-
attrs.height += 'px';
259+
attrs.height = parseFloat(attrs.height) + 'px';
260260
}
261261
for (var key in styleObj) {
262262
var value = styleObj[key];

uview-ui/components/u-parse/libs/trees.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
init() {
113113
for (var i = this.nodes.length, n; n = this.nodes[--i];) {
114114
if (n.name == 'img') {
115-
this.top.imgList.setItem(n.attrs.i, n.attrs.src);
115+
this.top.imgList.setItem(n.attrs.i, n.attrs['original-src'] || n.attrs.src);
116116
// #ifdef APP-PLUS
117117
if (this.lazyLoad && !this.observer) {
118118
this.observer = uni.createIntersectionObserver(this).relativeToViewport({

uview-ui/components/u-parse/u-parse.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
}
3535
// #endif
3636
// #ifdef H5 || APP-PLUS-NVUE || MP-360
37-
var windowWidth = uni.getSystemInfoSync().windowWidth,
37+
var {
38+
windowWidth,
39+
platform
40+
} = uni.getSystemInfoSync(),
3841
cfg = require('./libs/config.js');
3942
// #endif
4043
// #ifdef APP-PLUS-NVUE
@@ -63,7 +66,7 @@
6366
* @event {Function} imgtap 图片点击事件
6467
* @event {Function} linkpress 链接点击事件
6568
* @author JinYufeng
66-
* @version 20200728
69+
* @version 20200828
6770
* @listens MIT
6871
*/
6972
export default {
@@ -216,12 +219,13 @@
216219
'</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"})},' +
217220
(this.showWithAnimation ? 'document.body.style.animation="_show .5s",' : '') +
218221
'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');
219223
this.$refs.web.evalJs("document.write('" + html.replace(/'/g, "\\'") + "');document.close()");
220224
}
221225
this.$refs.web.evalJs(
222226
'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"))>' +
223227
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})}' +
225229
(this.autopause ? ',h.onplay=function(){for(var e,t=0;e=y[t];t++)e!=this&&e.pause()}' : '') +
226230
';for(var _,p=document.getElementsByTagName("audio"),w=0;_=p[w];w++)_.onerror=function(){e({action:"error",source:"audio",target:this})};' +
227231
(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,7 +288,7 @@
284288
}
285289
if (!img.hasAttribute('ignore') && img.parentElement.nodeName != 'A') {
286290
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'));
288292
img.onclick = function() {
289293
var preview = true;
290294
this.ignore = () => preview = false;
@@ -525,7 +529,7 @@
525529
style += '</style>';
526530
html = style + html;
527531
}
528-
// 处理rpx
532+
// 处理 rpx
529533
if (html.includes('rpx'))
530534
html = html.replace(/[0-9.]+\s*rpx/g, $ => (parseFloat($) * windowWidth / 750) + 'px');
531535
return html;

uview-ui/components/u-swiper/u-swiper.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
margin: effect3d && uCurrent != index ? '0 20rpx' : 0,
1515
backgroundColor: bgColor
1616
}">
17-
<image class="u-swiper-image" :src="item[name]" :mode="imgMode"></image>
18-
<view v-if="title" class="u-swiper-title u-line-1" :style="[{
17+
<image class="u-swiper-image" :src="item[name] || item" :mode="imgMode"></image>
18+
<view v-if="title && item.title" class="u-swiper-title u-line-1" :style="[{
1919
'padding-bottom': titlePaddingBottom
2020
}, titleStyle]">
2121
{{ item.title }}

uview-ui/components/u-tabs/u-tabs.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,9 @@
308308
309309
.u-scroll-box {
310310
position: relative;
311+
/* #ifdef MP-TOUTIAO */
312+
white-space: nowrap;
313+
/* #endif */
311314
}
312315
313316
/* #ifdef H5 */

0 commit comments

Comments
 (0)