Skip to content

Commit 7a7b6a4

Browse files
committed
1. 【新增】navbar新增title-bold参数,用于加粗标题
2. 【优化】优化$u.test.url()无法校验url中有中文时的问题 3. 【优化】升级parse组件,图片和链接的点击事件不冒泡
1 parent 04da8d4 commit 7a7b6a4

File tree

15 files changed

+69
-34
lines changed

15 files changed

+69
-34
lines changed

App.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@
1616
<style lang="scss">
1717
@import "uview-ui/index.scss";
1818
@import "common/demo.scss";
19-
/*每个页面公共css */
2019
</style>

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name" : "uView",
33
"appid" : "__UNI__60F4B81",
44
"description" : "多平台快速开发的UI框架",
5-
"versionName" : "1.7.4",
5+
"versionName" : "1.7.8",
66
"versionCode" : "100",
77
"transformPx" : false,
88
"app-plus" : {

pages/componentsC/layout/index.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
<view class="u-demo-wrap">
44
<view class="u-demo-title">演示效果</view>
55
<view class="u-demo-area">
6-
<u-row :justify="justify">
7-
<u-col :span="span" :offset="offset" @click="click">
6+
<u-row :justify="justify" @click="rowClick">
7+
<u-col :span="span" :offset="offset" @click="click" stop>
88
<view class="demo-layout bg-purple-dark">
99

1010
</view>
@@ -54,6 +54,12 @@
5454
}
5555
},
5656
methods: {
57+
click() {
58+
console.log('col click');
59+
},
60+
rowClick() {
61+
console.log('row click');
62+
},
5763
spanChange(e) {
5864
switch (e) {
5965
case 0:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
},
135135
computed: {
136136
wrapStyle() {
137-
let style = {};
137+
let style = {};
138138
style.height = this.size == 'large' ? '120rpx' : this.size == 'default' ?
139139
'90rpx' : this.size == 'mini' ? '70rpx' : this.size + 'rpx';
140140
style.width = style.height;

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
justifyContent: uJustify,
1010
textAlign: textAlign
1111
}"
12-
@tap.stop.prevent="click">
12+
@tap="click">
1313
<slot></slot>
1414
</view>
1515
</template>
@@ -51,6 +51,11 @@
5151
textAlign: {
5252
type: String,
5353
default: 'left'
54+
},
55+
// 是否阻止事件传播
56+
stop: {
57+
type: Boolean,
58+
default: true
5459
}
5560
},
5661
data() {
@@ -81,7 +86,7 @@
8186
}
8287
},
8388
methods: {
84-
click() {
89+
click(e) {
8590
this.$emit('click');
8691
}
8792
}

uview-ui/components/u-grid-item/u-grid-item.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
background: bgColor,
55
width: width,
66
}">
7-
<view class="u-grid-item-box" :style="customStyle" :class="[parentData.border ? 'u-border-right u-border-bottom' : '']">
7+
<view class="u-grid-item-box" :style="[customStyle]" :class="[parentData.border ? 'u-border-right u-border-bottom' : '']">
88
<slot />
99
</view>
1010
</view>

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
class="u-title u-line-1"
1515
:style="{
1616
color: titleColor,
17-
fontSize: titleSize + 'rpx'
17+
fontSize: titleSize + 'rpx',
18+
fontWeight: titleBold ? 'bold' : 'normal'
1819
}">
1920
{{ title }}
2021
</view>
@@ -115,6 +116,11 @@
115116
type: String,
116117
default: '#606266'
117118
},
119+
// 标题字体是否加粗
120+
titleBold: {
121+
type: Boolean,
122+
default: false
123+
},
118124
// 标题的字体大小
119125
titleSize: {
120126
type: [String, Number],

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

Lines changed: 1 addition & 1 deletion
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 20201014
4+
* @version 20201029
55
* @author JinYufeng
66
* @listens MIT
77
*/

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<view :class="'interlayer '+(c||'')" :style="s">
33
<block v-for="(n, i) in nodes" v-bind:key="i">
44
<!--图片-->
5-
<view v-if="n.name=='img'" :class="'_img '+n.attrs.class" :style="n.attrs.style" :data-attrs="n.attrs" @tap="imgtap">
5+
<view v-if="n.name=='img'" :class="'_img '+n.attrs.class" :style="n.attrs.style" :data-attrs="n.attrs" @tap.stop="imgtap">
66
<rich-text v-if="ctrl[i]!=0" :nodes="[{attrs:{src:loading&&(ctrl[i]||0)<2?loading:(lazyLoad&&!ctrl[i]?placeholder:(ctrl[i]==3?errorImg:n.attrs.src||'')),alt:n.attrs.alt||'',width:n.attrs.width||'',style:'-webkit-touch-callout:none;max-width:100%;display:block'+(n.attrs.height?';height:'+n.attrs.height:'')},name:'img'}]" />
77
<image class="_image" :src="lazyLoad&&!ctrl[i]?placeholder:n.attrs.src" :lazy-load="lazyLoad"
88
:show-menu-by-longpress="!n.attrs.ignore" :data-i="i" :data-index="n.attrs.i" data-source="img" @load="loadImg"
@@ -15,7 +15,7 @@
1515
<!--#endif-->
1616
<!--视频-->
1717
<view v-else-if="((n.lazyLoad&&!n.attrs.autoplay)||(n.name=='video'&&!loadVideo))&&ctrl[i]==undefined" :id="n.attrs.id"
18-
:class="'_video '+(n.attrs.class||'')" :style="n.attrs.style" :data-i="i" @tap="_loadVideo" />
18+
:class="'_video '+(n.attrs.class||'')" :style="n.attrs.style" :data-i="i" @tap.stop="_loadVideo" />
1919
<video v-else-if="n.name=='video'" :id="n.attrs.id" :class="n.attrs.class" :style="n.attrs.style" :autoplay="n.attrs.autoplay||ctrl[i]==0"
2020
:controls="n.attrs.controls" :loop="n.attrs.loop" :muted="n.attrs.muted" :poster="n.attrs.poster" :src="n.attrs.source[ctrl[i]||0]"
2121
:unit-id="n.attrs['unit-id']" :data-id="n.attrs.id" :data-i="i" data-source="video" @error="error" @play="play" />
@@ -26,7 +26,7 @@
2626
@play.native="play" />
2727
<!--链接-->
2828
<view v-else-if="n.name=='a'" :id="n.attrs.id" :class="'_a '+(n.attrs.class||'')" hover-class="_hover" :style="n.attrs.style"
29-
:data-attrs="n.attrs" @tap="linkpress">
29+
:data-attrs="n.attrs" @tap.stop="linkpress">
3030
<trees class="_span" c="_span" :nodes="n.children" />
3131
</view>
3232
<!--广告-->

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

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
</template>
1919

2020
<script>
21+
var search;
2122
// #ifndef H5 || APP-PLUS-NVUE || MP-360
2223
import trees from './libs/trees';
2324
var cache = {},
@@ -66,7 +67,7 @@
6667
* @event {Function} imgtap 图片点击事件
6768
* @event {Function} linkpress 链接点击事件
6869
* @author JinYufeng
69-
* @version 20201014
70+
* @version 20201029
7071
* @listens MIT
7172
*/
7273
export default {
@@ -173,6 +174,7 @@
173174
// #ifndef H5 || APP-PLUS-NVUE || MP-360
174175
if (dom) this.document = new dom(this);
175176
// #endif
177+
if (search) this.search = args => search(this, args);
176178
// #ifdef APP-PLUS-NVUE
177179
this.document = this.$refs.web;
178180
setTimeout(() => {
@@ -225,7 +227,7 @@
225227
this.$refs.web.evalJs(
226228
'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"))>' +
227229
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 + '",' : '') +
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})}' +
230+
'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(t){t.stopPropagation(),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(m){m.stopPropagation();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})}' +
229231
(this.autopause ? ',h.onplay=function(){for(var e,t=0;e=y[t];t++)e!=this&&e.pause()}' : '') +
230232
';for(var _,p=document.getElementsByTagName("audio"),w=0;_=p[w];w++)_.onerror=function(){e({action:"error",source:"audio",target:this})};' +
231233
(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)}' : '') +
@@ -272,24 +274,29 @@
272274
uni.setNavigationBarTitle({
273275
title: title[0].innerText
274276
})
277+
// 填充 domain
278+
var fill = target => {
279+
var src = target.getAttribute('src');
280+
if (this.domain && src) {
281+
if (src[0] == '/') {
282+
if (src[1] == '/')
283+
target.src = (this.domain.includes('://') ? this.domain.split('://')[0] : '') + ':' + src;
284+
else target.src = this.domain + src;
285+
} else if (!src.includes('://') && src.indexOf('data:') != 0) target.src = this.domain + '/' + src;
286+
}
287+
}
275288
// 图片处理
276289
this.imgList.length = 0;
277290
var imgs = this.rtf.getElementsByTagName('img');
278291
for (let i = 0, j = 0, img; img = imgs[i]; i++) {
279292
if (parseInt(img.style.width || img.getAttribute('width')) > windowWidth)
280293
img.style.height = 'auto';
281-
var src = img.getAttribute('src');
282-
if (this.domain && src) {
283-
if (src[0] == '/') {
284-
if (src[1] == '/')
285-
img.src = (this.domain.includes('://') ? this.domain.split('://')[0] : '') + ':' + src;
286-
else img.src = this.domain + src;
287-
} else if (!src.includes('://')) img.src = this.domain + '/' + src;
288-
}
294+
fill(img);
289295
if (!img.hasAttribute('ignore') && img.parentElement.nodeName != 'A') {
290296
img.i = j++;
291297
_ts.imgList.push(img.getAttribute('original-src') || img.src || img.getAttribute('data-src'));
292-
img.onclick = function() {
298+
img.onclick = function(e) {
299+
e.stopPropagation();
293300
var preview = true;
294301
this.ignore = () => preview = false;
295302
_ts.$emit('imgtap', this);
@@ -318,7 +325,8 @@
318325
// 链接处理
319326
var links = this.rtf.getElementsByTagName('a');
320327
for (var link of links) {
321-
link.onclick = function() {
328+
link.onclick = function(e) {
329+
e.stopPropagation();
322330
var jump = true,
323331
href = this.getAttribute('href');
324332
_ts.$emit('linkpress', {
@@ -346,6 +354,7 @@
346354
var videos = this.rtf.getElementsByTagName('video');
347355
_ts.videoContexts = videos;
348356
for (let video, i = 0; video = videos[i++];) {
357+
fill(video);
349358
video.style.maxWidth = '100%';
350359
video.onerror = function() {
351360
_ts.$emit('error', {
@@ -361,13 +370,15 @@
361370
}
362371
// 音频处理
363372
var audios = this.rtf.getElementsByTagName('audio');
364-
for (var audio of audios)
373+
for (var audio of audios) {
374+
fill(audio);
365375
audio.onerror = function() {
366376
_ts.$emit('error', {
367377
source: 'audio',
368378
target: this
369379
});
370380
}
381+
}
371382
// 表格处理
372383
if (this.autoscroll) {
373384
var tables = this.rtf.getElementsByTagName('table');
@@ -626,7 +637,7 @@
626637
/* #ifdef MP-WEIXIN */
627638
:host {
628639
display: block;
629-
overflow: scroll;
640+
overflow: auto;
630641
-webkit-overflow-scrolling: touch;
631642
}
632643

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
alignItems: uAlignItem,
44
justifyContent: uJustify
55
}"
6-
@tap.stop.prevent="click"
6+
@tap="click"
77
>
88
<slot />
99
</view>
@@ -36,6 +36,11 @@
3636
align: {
3737
type: String,
3838
default: 'center'
39+
},
40+
// 是否阻止事件传播
41+
stop: {
42+
type: Boolean,
43+
default: true
3944
}
4045
},
4146
computed: {
@@ -51,7 +56,7 @@
5156
}
5257
},
5358
methods: {
54-
click() {
59+
click(e) {
5560
this.$emit('click');
5661
}
5762
}

uview-ui/libs/config/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// 此版本发布于2020-10-13
2-
let version = '1.7.4';
1+
// 此版本发布于2020-10-31
2+
let version = '1.7.8';
33

44
export default {
55
v: version,

uview-ui/libs/function/test.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ function mobile(value) {
1616
* 验证URL格式
1717
*/
1818
function url(value) {
19-
return /^((https|http|ftp|rtsp|mms):\/\/)(([0-9a-zA-Z_!~*'().&=+$%-]+: )?[0-9a-zA-Z_!~*'().&=+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z].[a-zA-Z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-zA-Z_!~*'().;?:@&=+$,%#-]+)+\/?)$/
20-
.test(value)
19+
return /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?/.test(value)
2120
}
2221

2322
/**

uview-ui/libs/mixin/mixin.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ module.exports = {
3939
});
4040
}
4141
},
42+
// 阻止事件冒泡
43+
preventEvent(e) {
44+
e && e.stopPropagation && e.stopPropagation()
45+
}
4246
},
4347
onReachBottom() {
4448
uni.$emit('uOnReachBottom')

uview-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "uview-ui",
3-
"version": "1.7.6",
3+
"version": "1.7.8",
44
"description": "uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
55
"main": "index.js",
66
"keywords": [

0 commit comments

Comments
 (0)