Commit 7a7b6a4d authored by yiruiwen's avatar yiruiwen

1. 【新增】navbar新增title-bold参数,用于加粗标题

2. 【优化】优化$u.test.url()无法校验url中有中文时的问题
3. 【优化】升级parse组件,图片和链接的点击事件不冒泡
parent 04da8d47
...@@ -16,5 +16,4 @@ ...@@ -16,5 +16,4 @@
<style lang="scss"> <style lang="scss">
@import "uview-ui/index.scss"; @import "uview-ui/index.scss";
@import "common/demo.scss"; @import "common/demo.scss";
/*每个页面公共css */
</style> </style>
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name" : "uView", "name" : "uView",
"appid" : "__UNI__60F4B81", "appid" : "__UNI__60F4B81",
"description" : "多平台快速开发的UI框架", "description" : "多平台快速开发的UI框架",
"versionName" : "1.7.4", "versionName" : "1.7.8",
"versionCode" : "100", "versionCode" : "100",
"transformPx" : false, "transformPx" : false,
"app-plus" : { "app-plus" : {
......
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
<view class="u-demo-wrap"> <view class="u-demo-wrap">
<view class="u-demo-title">演示效果</view> <view class="u-demo-title">演示效果</view>
<view class="u-demo-area"> <view class="u-demo-area">
<u-row :justify="justify"> <u-row :justify="justify" @click="rowClick">
<u-col :span="span" :offset="offset" @click="click"> <u-col :span="span" :offset="offset" @click="click" stop>
<view class="demo-layout bg-purple-dark"> <view class="demo-layout bg-purple-dark">
</view> </view>
...@@ -54,6 +54,12 @@ ...@@ -54,6 +54,12 @@
} }
}, },
methods: { methods: {
click() {
console.log('col click');
},
rowClick() {
console.log('row click');
},
spanChange(e) { spanChange(e) {
switch (e) { switch (e) {
case 0: case 0:
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
justifyContent: uJustify, justifyContent: uJustify,
textAlign: textAlign textAlign: textAlign
}" }"
@tap.stop.prevent="click"> @tap="click">
<slot></slot> <slot></slot>
</view> </view>
</template> </template>
...@@ -51,6 +51,11 @@ ...@@ -51,6 +51,11 @@
textAlign: { textAlign: {
type: String, type: String,
default: 'left' default: 'left'
},
// 是否阻止事件传播
stop: {
type: Boolean,
default: true
} }
}, },
data() { data() {
...@@ -81,7 +86,7 @@ ...@@ -81,7 +86,7 @@
} }
}, },
methods: { methods: {
click() { click(e) {
this.$emit('click'); this.$emit('click');
} }
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
background: bgColor, background: bgColor,
width: width, 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 /> <slot />
</view> </view>
</view> </view>
......
...@@ -14,7 +14,8 @@ ...@@ -14,7 +14,8 @@
class="u-title u-line-1" class="u-title u-line-1"
:style="{ :style="{
color: titleColor, color: titleColor,
fontSize: titleSize + 'rpx' fontSize: titleSize + 'rpx',
fontWeight: titleBold ? 'bold' : 'normal'
}"> }">
{{ title }} {{ title }}
</view> </view>
...@@ -115,6 +116,11 @@ ...@@ -115,6 +116,11 @@
type: String, type: String,
default: '#606266' default: '#606266'
}, },
// 标题字体是否加粗
titleBold: {
type: Boolean,
default: false
},
// 标题的字体大小 // 标题的字体大小
titleSize: { titleSize: {
type: [String, Number], type: [String, Number],
......
/** /**
* html 解析器 * html 解析器
* @tutorial https://github.com/jin-yufeng/Parser * @tutorial https://github.com/jin-yufeng/Parser
* @version 20201014 * @version 20201029
* @author JinYufeng * @author JinYufeng
* @listens MIT * @listens MIT
*/ */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view :class="'interlayer '+(c||'')" :style="s"> <view :class="'interlayer '+(c||'')" :style="s">
<block v-for="(n, i) in nodes" v-bind:key="i"> <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'}]" /> <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" <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" :show-menu-by-longpress="!n.attrs.ignore" :data-i="i" :data-index="n.attrs.i" data-source="img" @load="loadImg"
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<!--#endif--> <!--#endif-->
<!--视频--> <!--视频-->
<view v-else-if="((n.lazyLoad&&!n.attrs.autoplay)||(n.name=='video'&&!loadVideo))&&ctrl[i]==undefined" :id="n.attrs.id" <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" <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]" :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" /> :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 @@ ...@@ -26,7 +26,7 @@
@play.native="play" /> @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" <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" /> <trees class="_span" c="_span" :nodes="n.children" />
</view> </view>
<!--广告--> <!--广告-->
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
</template> </template>
<script> <script>
var search;
// #ifndef H5 || APP-PLUS-NVUE || MP-360 // #ifndef H5 || APP-PLUS-NVUE || MP-360
import trees from './libs/trees'; import trees from './libs/trees';
var cache = {}, var cache = {},
...@@ -66,7 +67,7 @@ ...@@ -66,7 +67,7 @@
* @event {Function} imgtap 图片点击事件 * @event {Function} imgtap 图片点击事件
* @event {Function} linkpress 链接点击事件 * @event {Function} linkpress 链接点击事件
* @author JinYufeng * @author JinYufeng
* @version 20201014 * @version 20201029
* @listens MIT * @listens MIT
*/ */
export default { export default {
...@@ -173,6 +174,7 @@ ...@@ -173,6 +174,7 @@
// #ifndef H5 || APP-PLUS-NVUE || MP-360 // #ifndef H5 || APP-PLUS-NVUE || MP-360
if (dom) this.document = new dom(this); if (dom) this.document = new dom(this);
// #endif // #endif
if (search) this.search = args => search(this, args);
// #ifdef APP-PLUS-NVUE // #ifdef APP-PLUS-NVUE
this.document = this.$refs.web; this.document = this.$refs.web;
setTimeout(() => { setTimeout(() => {
...@@ -225,7 +227,7 @@ ...@@ -225,7 +227,7 @@
this.$refs.web.evalJs( 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"))>' + '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 + '",' : '') + 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()}' : '') + (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})};' + ';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)}' : '') + (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 @@ ...@@ -272,24 +274,29 @@
uni.setNavigationBarTitle({ uni.setNavigationBarTitle({
title: title[0].innerText 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; this.imgList.length = 0;
var imgs = this.rtf.getElementsByTagName('img'); var imgs = this.rtf.getElementsByTagName('img');
for (let i = 0, j = 0, img; img = imgs[i]; i++) { for (let i = 0, j = 0, img; img = imgs[i]; i++) {
if (parseInt(img.style.width || img.getAttribute('width')) > windowWidth) if (parseInt(img.style.width || img.getAttribute('width')) > windowWidth)
img.style.height = 'auto'; img.style.height = 'auto';
var src = img.getAttribute('src'); fill(img);
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;
}
if (!img.hasAttribute('ignore') && img.parentElement.nodeName != 'A') { if (!img.hasAttribute('ignore') && img.parentElement.nodeName != 'A') {
img.i = j++; img.i = j++;
_ts.imgList.push(img.getAttribute('original-src') || img.src || img.getAttribute('data-src')); _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; var preview = true;
this.ignore = () => preview = false; this.ignore = () => preview = false;
_ts.$emit('imgtap', this); _ts.$emit('imgtap', this);
...@@ -318,7 +325,8 @@ ...@@ -318,7 +325,8 @@
// 链接处理 // 链接处理
var links = this.rtf.getElementsByTagName('a'); var links = this.rtf.getElementsByTagName('a');
for (var link of links) { for (var link of links) {
link.onclick = function() { link.onclick = function(e) {
e.stopPropagation();
var jump = true, var jump = true,
href = this.getAttribute('href'); href = this.getAttribute('href');
_ts.$emit('linkpress', { _ts.$emit('linkpress', {
...@@ -346,6 +354,7 @@ ...@@ -346,6 +354,7 @@
var videos = this.rtf.getElementsByTagName('video'); var videos = this.rtf.getElementsByTagName('video');
_ts.videoContexts = videos; _ts.videoContexts = videos;
for (let video, i = 0; video = videos[i++];) { for (let video, i = 0; video = videos[i++];) {
fill(video);
video.style.maxWidth = '100%'; video.style.maxWidth = '100%';
video.onerror = function() { video.onerror = function() {
_ts.$emit('error', { _ts.$emit('error', {
...@@ -361,13 +370,15 @@ ...@@ -361,13 +370,15 @@
} }
// 音频处理 // 音频处理
var audios = this.rtf.getElementsByTagName('audio'); var audios = this.rtf.getElementsByTagName('audio');
for (var audio of audios) for (var audio of audios) {
fill(audio);
audio.onerror = function() { audio.onerror = function() {
_ts.$emit('error', { _ts.$emit('error', {
source: 'audio', source: 'audio',
target: this target: this
}); });
} }
}
// 表格处理 // 表格处理
if (this.autoscroll) { if (this.autoscroll) {
var tables = this.rtf.getElementsByTagName('table'); var tables = this.rtf.getElementsByTagName('table');
...@@ -626,7 +637,7 @@ ...@@ -626,7 +637,7 @@
/* #ifdef MP-WEIXIN */ /* #ifdef MP-WEIXIN */
:host { :host {
display: block; display: block;
overflow: scroll; overflow: auto;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
alignItems: uAlignItem, alignItems: uAlignItem,
justifyContent: uJustify justifyContent: uJustify
}" }"
@tap.stop.prevent="click" @tap="click"
> >
<slot /> <slot />
</view> </view>
...@@ -36,6 +36,11 @@ ...@@ -36,6 +36,11 @@
align: { align: {
type: String, type: String,
default: 'center' default: 'center'
},
// 是否阻止事件传播
stop: {
type: Boolean,
default: true
} }
}, },
computed: { computed: {
...@@ -51,7 +56,7 @@ ...@@ -51,7 +56,7 @@
} }
}, },
methods: { methods: {
click() { click(e) {
this.$emit('click'); this.$emit('click');
} }
} }
......
// 此版本发布于2020-10-13 // 此版本发布于2020-10-31
let version = '1.7.4'; let version = '1.7.8';
export default { export default {
v: version, v: version,
......
...@@ -16,8 +16,7 @@ function mobile(value) { ...@@ -16,8 +16,7 @@ function mobile(value) {
* 验证URL格式 * 验证URL格式
*/ */
function url(value) { 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_!~*'().;?:@&=+$,%#-]+)+\/?)$/ return /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-.\/?%&=]*)?/.test(value)
.test(value)
} }
/** /**
......
...@@ -39,6 +39,10 @@ module.exports = { ...@@ -39,6 +39,10 @@ module.exports = {
}); });
} }
}, },
// 阻止事件冒泡
preventEvent(e) {
e && e.stopPropagation && e.stopPropagation()
}
}, },
onReachBottom() { onReachBottom() {
uni.$emit('uOnReachBottom') uni.$emit('uOnReachBottom')
......
{ {
"name": "uview-ui", "name": "uview-ui",
"version": "1.7.6", "version": "1.7.8",
"description": "uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水", "description": "uView UI,是uni-app生态优秀的UI框架,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
"main": "index.js", "main": "index.js",
"keywords": [ "keywords": [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment