Skip to content

Commit

Permalink
Merge branch 'yiruiwen'
Browse files Browse the repository at this point in the history
  • Loading branch information
wlxuqu committed Oct 31, 2020
2 parents 8659ce3 + 7a7b6a4 commit a8e8f5b
Show file tree
Hide file tree
Showing 15 changed files with 69 additions and 34 deletions.
1 change: 0 additions & 1 deletion App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@
<style lang="scss">
@import "uview-ui/index.scss";
@import "common/demo.scss";
/*每个页面公共css */
</style>
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name" : "uView",
"appid" : "__UNI__60F4B81",
"description" : "多平台快速开发的UI框架",
"versionName" : "1.7.4",
"versionName" : "1.7.8",
"versionCode" : "100",
"transformPx" : false,
"app-plus" : {
Expand Down
10 changes: 8 additions & 2 deletions pages/componentsC/layout/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<view class="u-demo-wrap">
<view class="u-demo-title">演示效果</view>
<view class="u-demo-area">
<u-row :justify="justify">
<u-col :span="span" :offset="offset" @click="click">
<u-row :justify="justify" @click="rowClick">
<u-col :span="span" :offset="offset" @click="click" stop>
<view class="demo-layout bg-purple-dark">

</view>
Expand Down Expand Up @@ -54,6 +54,12 @@
}
},
methods: {
click() {
console.log('col click');
},
rowClick() {
console.log('row click');
},
spanChange(e) {
switch (e) {
case 0:
Expand Down
2 changes: 1 addition & 1 deletion uview-ui/components/u-avatar/u-avatar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
},
computed: {
wrapStyle() {
let style = {};
let style = {};
style.height = this.size == 'large' ? '120rpx' : this.size == 'default' ?
'90rpx' : this.size == 'mini' ? '70rpx' : this.size + 'rpx';
style.width = style.height;
Expand Down
9 changes: 7 additions & 2 deletions uview-ui/components/u-col/u-col.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
justifyContent: uJustify,
textAlign: textAlign
}"
@tap.stop.prevent="click">
@tap="click">
<slot></slot>
</view>
</template>
Expand Down Expand Up @@ -51,6 +51,11 @@
textAlign: {
type: String,
default: 'left'
},
// 是否阻止事件传播
stop: {
type: Boolean,
default: true
}
},
data() {
Expand Down Expand Up @@ -81,7 +86,7 @@
}
},
methods: {
click() {
click(e) {
this.$emit('click');
}
}
Expand Down
2 changes: 1 addition & 1 deletion uview-ui/components/u-grid-item/u-grid-item.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
background: bgColor,
width: width,
}">
<view class="u-grid-item-box" :style="customStyle" :class="[parentData.border ? 'u-border-right u-border-bottom' : '']">
<view class="u-grid-item-box" :style="[customStyle]" :class="[parentData.border ? 'u-border-right u-border-bottom' : '']">
<slot />
</view>
</view>
Expand Down
8 changes: 7 additions & 1 deletion uview-ui/components/u-navbar/u-navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
class="u-title u-line-1"
:style="{
color: titleColor,
fontSize: titleSize + 'rpx'
fontSize: titleSize + 'rpx',
fontWeight: titleBold ? 'bold' : 'normal'
}">
{{ title }}
</view>
Expand Down Expand Up @@ -115,6 +116,11 @@
type: String,
default: '#606266'
},
// 标题字体是否加粗
titleBold: {
type: Boolean,
default: false
},
// 标题的字体大小
titleSize: {
type: [String, Number],
Expand Down
2 changes: 1 addition & 1 deletion uview-ui/components/u-parse/libs/MpHtmlParser.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* html 解析器
* @tutorial https://github.com/jin-yufeng/Parser
* @version 20201014
* @version 20201029
* @author JinYufeng
* @listens MIT
*/
Expand Down
6 changes: 3 additions & 3 deletions uview-ui/components/u-parse/libs/trees.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<view :class="'interlayer '+(c||'')" :style="s">
<block v-for="(n, i) in nodes" v-bind:key="i">
<!--图片-->
<view v-if="n.name=='img'" :class="'_img '+n.attrs.class" :style="n.attrs.style" :data-attrs="n.attrs" @tap="imgtap">
<view v-if="n.name=='img'" :class="'_img '+n.attrs.class" :style="n.attrs.style" :data-attrs="n.attrs" @tap.stop="imgtap">
<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'}]" />
<image class="_image" :src="lazyLoad&&!ctrl[i]?placeholder:n.attrs.src" :lazy-load="lazyLoad"
:show-menu-by-longpress="!n.attrs.ignore" :data-i="i" :data-index="n.attrs.i" data-source="img" @load="loadImg"
Expand All @@ -15,7 +15,7 @@
<!--#endif-->
<!--视频-->
<view v-else-if="((n.lazyLoad&&!n.attrs.autoplay)||(n.name=='video'&&!loadVideo))&&ctrl[i]==undefined" :id="n.attrs.id"
:class="'_video '+(n.attrs.class||'')" :style="n.attrs.style" :data-i="i" @tap="_loadVideo" />
:class="'_video '+(n.attrs.class||'')" :style="n.attrs.style" :data-i="i" @tap.stop="_loadVideo" />
<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"
:controls="n.attrs.controls" :loop="n.attrs.loop" :muted="n.attrs.muted" :poster="n.attrs.poster" :src="n.attrs.source[ctrl[i]||0]"
:unit-id="n.attrs['unit-id']" :data-id="n.attrs.id" :data-i="i" data-source="video" @error="error" @play="play" />
Expand All @@ -26,7 +26,7 @@
@play.native="play" />
<!--链接-->
<view v-else-if="n.name=='a'" :id="n.attrs.id" :class="'_a '+(n.attrs.class||'')" hover-class="_hover" :style="n.attrs.style"
:data-attrs="n.attrs" @tap="linkpress">
:data-attrs="n.attrs" @tap.stop="linkpress">
<trees class="_span" c="_span" :nodes="n.children" />
</view>
<!--广告-->
Expand Down
39 changes: 25 additions & 14 deletions uview-ui/components/u-parse/u-parse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</template>

<script>
var search;
// #ifndef H5 || APP-PLUS-NVUE || MP-360
import trees from './libs/trees';
var cache = {},
Expand Down Expand Up @@ -66,7 +67,7 @@
* @event {Function} imgtap 图片点击事件
* @event {Function} linkpress 链接点击事件
* @author JinYufeng
* @version 20201014
* @version 20201029
* @listens MIT
*/
export default {
Expand Down Expand Up @@ -173,6 +174,7 @@
// #ifndef H5 || APP-PLUS-NVUE || MP-360
if (dom) this.document = new dom(this);
// #endif
if (search) this.search = args => search(this, args);
// #ifdef APP-PLUS-NVUE
this.document = this.$refs.web;
setTimeout(() => {
Expand Down Expand Up @@ -225,7 +227,7 @@
this.$refs.web.evalJs(
'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"))>' +
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 + '",' : '') +
'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})}' +
'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})}' +
(this.autopause ? ',h.onplay=function(){for(var e,t=0;e=y[t];t++)e!=this&&e.pause()}' : '') +
';for(var _,p=document.getElementsByTagName("audio"),w=0;_=p[w];w++)_.onerror=function(){e({action:"error",source:"audio",target:this})};' +
(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)}' : '') +
Expand Down Expand Up @@ -272,24 +274,29 @@
uni.setNavigationBarTitle({
title: title[0].innerText
})
// 填充 domain
var fill = target => {
var src = target.getAttribute('src');
if (this.domain && src) {
if (src[0] == '/') {
if (src[1] == '/')
target.src = (this.domain.includes('://') ? this.domain.split('://')[0] : '') + ':' + src;
else target.src = this.domain + src;
} else if (!src.includes('://') && src.indexOf('data:') != 0) target.src = this.domain + '/' + src;
}
}
// 图片处理
this.imgList.length = 0;
var imgs = this.rtf.getElementsByTagName('img');
for (let i = 0, j = 0, img; img = imgs[i]; i++) {
if (parseInt(img.style.width || img.getAttribute('width')) > windowWidth)
img.style.height = 'auto';
var src = img.getAttribute('src');
if (this.domain && src) {
if (src[0] == '/') {
if (src[1] == '/')
img.src = (this.domain.includes('://') ? this.domain.split('://')[0] : '') + ':' + src;
else img.src = this.domain + src;
} else if (!src.includes('://')) img.src = this.domain + '/' + src;
}
fill(img);
if (!img.hasAttribute('ignore') && img.parentElement.nodeName != 'A') {
img.i = j++;
_ts.imgList.push(img.getAttribute('original-src') || img.src || img.getAttribute('data-src'));
img.onclick = function() {
img.onclick = function(e) {
e.stopPropagation();
var preview = true;
this.ignore = () => preview = false;
_ts.$emit('imgtap', this);
Expand Down Expand Up @@ -318,7 +325,8 @@
// 链接处理
var links = this.rtf.getElementsByTagName('a');
for (var link of links) {
link.onclick = function() {
link.onclick = function(e) {
e.stopPropagation();
var jump = true,
href = this.getAttribute('href');
_ts.$emit('linkpress', {
Expand Down Expand Up @@ -346,6 +354,7 @@
var videos = this.rtf.getElementsByTagName('video');
_ts.videoContexts = videos;
for (let video, i = 0; video = videos[i++];) {
fill(video);
video.style.maxWidth = '100%';
video.onerror = function() {
_ts.$emit('error', {
Expand All @@ -361,13 +370,15 @@
}
// 音频处理
var audios = this.rtf.getElementsByTagName('audio');
for (var audio of audios)
for (var audio of audios) {
fill(audio);
audio.onerror = function() {
_ts.$emit('error', {
source: 'audio',
target: this
});
}
}
// 表格处理
if (this.autoscroll) {
var tables = this.rtf.getElementsByTagName('table');
Expand Down Expand Up @@ -626,7 +637,7 @@
/* #ifdef MP-WEIXIN */
:host {
display: block;
overflow: scroll;
overflow: auto;
-webkit-overflow-scrolling: touch;
}
Expand Down
9 changes: 7 additions & 2 deletions uview-ui/components/u-row/u-row.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
alignItems: uAlignItem,
justifyContent: uJustify
}"
@tap.stop.prevent="click"
@tap="click"
>
<slot />
</view>
Expand Down Expand Up @@ -36,6 +36,11 @@
align: {
type: String,
default: 'center'
},
// 是否阻止事件传播
stop: {
type: Boolean,
default: true
}
},
computed: {
Expand All @@ -51,7 +56,7 @@
}
},
methods: {
click() {
click(e) {
this.$emit('click');
}
}
Expand Down
4 changes: 2 additions & 2 deletions uview-ui/libs/config/config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// 此版本发布于2020-10-13
let version = '1.7.4';
// 此版本发布于2020-10-31
let version = '1.7.8';

export default {
v: version,
Expand Down
3 changes: 1 addition & 2 deletions uview-ui/libs/function/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ function mobile(value) {
* 验证URL格式
*/
function url(value) {
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_!~*'().;?:@&=+$,%#-]+)+\/?)$/
.test(value)
return /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?/.test(value)
}

/**
Expand Down
4 changes: 4 additions & 0 deletions uview-ui/libs/mixin/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ module.exports = {
});
}
},
// 阻止事件冒泡
preventEvent(e) {
e && e.stopPropagation && e.stopPropagation()
}
},
onReachBottom() {
uni.$emit('uOnReachBottom')
Expand Down
2 changes: 1 addition & 1 deletion uview-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uview-ui",
"version": "1.7.6",
"version": "1.7.8",
"description": "uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
"main": "index.js",
"keywords": [
Expand Down

0 comments on commit a8e8f5b

Please sign in to comment.