初始化代码
This commit is contained in:
56
front/components/jyf-Parser/handler.wxs
Normal file
56
front/components/jyf-Parser/handler.wxs
Normal file
@@ -0,0 +1,56 @@
|
||||
var inlineTags = {
|
||||
abbr: true,
|
||||
b: true,
|
||||
big: true,
|
||||
code: true,
|
||||
del: true,
|
||||
em: true,
|
||||
font: true,
|
||||
i: true,
|
||||
ins: true,
|
||||
label: true,
|
||||
mark: true,
|
||||
q: true,
|
||||
s: true,
|
||||
small: true,
|
||||
span: true,
|
||||
strong: true,
|
||||
u: true
|
||||
}
|
||||
module.exports = {
|
||||
getStyle: function(style, display) {
|
||||
var res = "";
|
||||
var reg = getRegExp("float[^;]+(?![\s\S]*?float)", "i");
|
||||
if (reg.test(style)) res += reg.exec(style)[0];
|
||||
reg = getRegExp("margin[^;]+", "gi");
|
||||
if (reg.test(style)) res += (';' + style.match(reg).join(';'));
|
||||
reg = getRegExp("display\s*:\s*([^;]*)(?![\s\S]*?display)", "i");
|
||||
if (reg.test(style) && reg.exec(style)[1] != "flex") res += (';' + reg.exec(style)[0]);
|
||||
else res += (';display:' + display);
|
||||
reg = getRegExp("flex[^;]*:[^;]+", "ig");
|
||||
if (reg.test(style)) res += (';' + style.match(reg).join(';'));
|
||||
reg = getRegExp("[^;\s]*width[^;]+", "ig");
|
||||
if (reg.test(style)) res += (';' + style.match(reg).join(';'));
|
||||
return res;
|
||||
},
|
||||
setImgStyle: function(item, imgMode, imgLoad) {
|
||||
if (imgMode == "widthFix") item.attrs.style = (item.attrs.style || '') + ";height:auto !important";
|
||||
if (item.attrs.style)
|
||||
item.attrs.style = item.attrs.style.replace(getRegExp("width[^;]*?%", "gi"), "width:100%").replace(getRegExp(
|
||||
'margin[^;]+', "gi"), "");
|
||||
if (!imgLoad) {
|
||||
delete item.attrs.src;
|
||||
item.attrs.style += ";width:20px !important;height:20px !important";
|
||||
}
|
||||
return [item];
|
||||
},
|
||||
setStyle: function(item) {
|
||||
if (item.attrs.style)
|
||||
item.attrs.style = item.attrs.style.replace(getRegExp("width[^;]*?%", "gi"), "width:100%").replace(getRegExp(
|
||||
'margin[^;]+', "gi"), "");
|
||||
return [item];
|
||||
},
|
||||
notContinue: function(item) {
|
||||
return !(item.c || inlineTags[item.name] || item["continue"]);
|
||||
}
|
||||
}
|
||||
10
front/components/jyf-Parser/index.js
Normal file
10
front/components/jyf-Parser/index.js
Normal file
File diff suppressed because one or more lines are too long
6
front/components/jyf-Parser/index.json
Normal file
6
front/components/jyf-Parser/index.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"trees": "/components/jyf-Parser/trees"
|
||||
}
|
||||
}
|
||||
1
front/components/jyf-Parser/index.wxml
Normal file
1
front/components/jyf-Parser/index.wxml
Normal file
@@ -0,0 +1 @@
|
||||
<view><block wx:if="{{$root.g0}}"><slot></slot></block><trees class="_contain" style="{{('display:block;'+(selectable?'user-select:text;-webkit-user-select:text;':'')+(showWithAnimation?'opacity:0;'+showAnimation:''))}}" vue-id="116ecbda-1" nodes="{{$root.g1?nodes:html[0].name||html[0].type?html:[]}}" imgMode="{{imgMode}}" loadVideo="{{loadVideo}}" bind:__l="__l"></trees></view>
|
||||
1
front/components/jyf-Parser/index.wxss
Normal file
1
front/components/jyf-Parser/index.wxss
Normal file
@@ -0,0 +1 @@
|
||||
:host{display:block;overflow:scroll;-webkit-overflow-scrolling:touch}
|
||||
10
front/components/jyf-Parser/trees.js
Normal file
10
front/components/jyf-Parser/trees.js
Normal file
@@ -0,0 +1,10 @@
|
||||
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/jyf-Parser/trees"],{"162f":function(t,r,e){"use strict";(function(t){function n(t,r){var e="undefined"!==typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,r){if(!t)return;if("string"===typeof t)return o(t,r);var e=Object.prototype.toString.call(t).slice(8,-1);"Object"===e&&t.constructor&&(e=t.constructor.name);if("Map"===e||"Set"===e)return Array.from(t);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return o(t,r)}(t))||r&&t&&"number"===typeof t.length){e&&(t=e);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,s=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return u=t.done,t},e:function(t){s=!0,a=t},f:function(){try{u||null==e.return||e.return()}finally{if(s)throw a}}}}function o(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}Object.defineProperty(r,"__esModule",{value:!0}),r.default=void 0;var i={components:{trees:function(){Promise.resolve().then(function(){return resolve(e("ada1"))}.bind(null,e)).catch(e.oe)}},name:"trees",data:function(){return{controls:{},imgLoad:!0}},props:{nodes:{type:Array,default:[]},imgMode:{type:String,default:"default"}},mounted:function(){this._top=this.$parent;while("parser"!=this._top.$options.name){if(this._top._top){this._top=this._top._top;break}this._top=this._top.$parent}},beforeDestroy:function(){this._observer&&this._observer.disconnect()},methods:{playEvent:function(t){if((this._top.videoContexts||[]).length>1&&this._top.autopause){var r,e=n(this._top.videoContexts);try{for(e.s();!(r=e.n()).done;){var o=r.value;o.id!=t.currentTarget.id&&o.pause()}}catch(i){e.e(i)}finally{e.f()}}},previewEvent:function(r){var e=r.currentTarget.dataset.attrs;if(!e.ignore){var n=!0;if(this._top.$emit("imgtap",{id:r.currentTarget.id,src:e.src,ignore:function(){return n=!1}}),n&&this._top.autopreview){var o=this._top.imgList||[],i=o[e.i]?e.i:(o=[e.src],0);t.previewImage({current:i,urls:o})}}},tapEvent:function(r){var e=!0,n=r.currentTarget.dataset.attrs;if(n.ignore=function(){return e=!1},this._top.$emit("linkpress",n),e){if(n["app-id"]||n.appId)return t.navigateToMiniProgram({appId:n["app-id"]||n.appId,path:n.path||""});n.href&&("#"==n.href[0]?this._top.useAnchor&&this._top.navigateTo({id:n.href.substring(1)}):0==n.href.indexOf("http")||0==n.href.indexOf("//")?this._top.autocopy&&t.setClipboardData({data:n.href,success:function(){t.showToast({title:"链接已复制"})}}):t.navigateTo({url:n.href}))}},triggerError:function(t,r,e,n,o){this._top.$emit("error",{source:t,target:r,errMsg:e,errCode:n,context:o})},loadSource:function(t){var r=(this.controls[t.id]?this.controls[t.id].index:0)+1;return r<t.dataset.source.length&&(this.$set(this.controls[t.id],"index",r),!0)},adError:function(t){this.triggerError("ad",t.currentTarget,"",t.detail.errorCode)},videoError:function(r){!this.loadSource(r.currentTarget)&&this._top&&this.triggerError("video",r.currentTarget,r.detail.errMsg,void 0,t.createVideoContext(r.currentTarget.id,this))},audioError:function(t){this.loadSource(t.currentTarget)||this.triggerError("audio",t.currentTarget,t.detail.errMsg)},_loadVideo:function(t){this.$set(this.controls,t.currentTarget.id,{play:!0,index:0})}}};r.default=i}).call(this,e("543d")["default"])},"2db3":function(t,r,e){},"6d39":function(t,r,e){"use strict";e.r(r);var n=e("162f"),o=e.n(n);for(var i in n)["default"].indexOf(i)<0&&function(t){e.d(r,t,(function(){return n[t]}))}(i);r["default"]=o.a},a87d:function(t,r,e){"use strict";e.d(r,"b",(function(){return n})),e.d(r,"c",(function(){return o})),e.d(r,"a",(function(){}));var n=function(){var t=this.$createElement;this._self._c},o=[]},ada1:function(t,r,e){"use strict";e.r(r);var n=e("a87d"),o=e("6d39");for(var i in o)["default"].indexOf(i)<0&&function(t){e.d(r,t,(function(){return o[t]}))}(i);e("b870");var a=e("f0c5"),u=e("d5b9"),s=Object(a["a"])(o["default"],n["b"],n["c"],!1,null,null,null,!1,n["a"],void 0);"function"===typeof u["a"]&&Object(u["a"])(s),r["default"]=s.exports},b870:function(t,r,e){"use strict";var n=e("2db3"),o=e.n(n);o.a},d5b9:function(t,r,e){"use strict";r["a"]=function(t){t.options.wxsCallMethods||(t.options.wxsCallMethods=[])}}}]);
|
||||
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
|
||||
'components/jyf-Parser/trees-create-component',
|
||||
{
|
||||
'components/jyf-Parser/trees-create-component':(function(module, exports, __webpack_require__){
|
||||
__webpack_require__('543d')['createComponent'](__webpack_require__("ada1"))
|
||||
})
|
||||
},
|
||||
[['components/jyf-Parser/trees-create-component']]
|
||||
]);
|
||||
6
front/components/jyf-Parser/trees.json
Normal file
6
front/components/jyf-Parser/trees.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"trees": "/components/jyf-Parser/trees"
|
||||
}
|
||||
}
|
||||
2
front/components/jyf-Parser/trees.wxml
Normal file
2
front/components/jyf-Parser/trees.wxml
Normal file
@@ -0,0 +1,2 @@
|
||||
<wxs src="./handler.wxs" module="handler"></wxs>
|
||||
<view style="display:inherit;white-space:inherit;"><block wx:for="{{nodes}}" wx:for-item="item" wx:for-index="index" wx:key="index"><block><block wx:if="{{handler.notContinue(item)}}"><block><block wx:if="{{item.name=='img'}}"><rich-text class="img" style="{{('text-indent:0;'+handler.getStyle(item.attrs.style,'inline-block'))}}" id="{{item.attrs.id}}" nodes="{{handler.setImgStyle(item,imgMode,imgLoad)}}" data-attrs="{{item.attrs}}" data-event-opts="{{[['tap',[['previewEvent',['$event']]]]]}}" bindtap="__e"></rich-text></block><block wx:else><block wx:if="{{item.type=='text'}}"><block><block wx:if="{{!item.decode}}"><text decode="{{true}}">{{item.text}}</text></block><block wx:else><rich-text style="display:inline-block;" nodes="{{[item]}}"></rich-text></block></block></block><block wx:else><block wx:if="{{item.name=='br'}}"><text>\n</text></block><block wx:else><block wx:if="{{item.name=='video'}}"><block><block wx:if="{{item.lazyLoad&&!controls[item.attrs.id].play}}"><view class="{{['_video '+(item.attrs.class||'')]}}" style="{{(item.attrs.style||'')}}" id="{{item.attrs.id}}" data-event-opts="{{[['tap',[['_loadVideo',['$event']]]]]}}" bindtap="__e"></view></block><block wx:else><video class="{{[item.attrs.class]}}" style="{{(item.attrs.style||'')}}" src="{{controls[item.attrs.id]?item.attrs.source[controls[item.attrs.id].index]:item.attrs.src}}" id="{{item.attrs.id}}" loop="{{item.attrs.loop}}" controls="{{item.attrs.controls}}" autoplay="{{item.attrs.autoplay||controls[item.attrs.id]&&controls[item.attrs.id].play}}" unit-id="{{item.attrs['unit-id']}}" data-source="{{item.attrs.source}}" data-event-opts="{{[['play',[['playEvent',['$event']]]],['error',[['videoError',['$event']]]]]}}" muted="{{item.attrs.muted}}" bindplay="__e" binderror="__e"></video></block></block></block><block wx:else><block wx:if="{{item.name=='iframe'}}"><block><block wx:if="{{item.attrs.lbType=='vid'||item.attrs.lbtype=='vid'}}"><txv-video vue-id="{{'26db2430-1-'+index}}" vid="{{item.attrs.src}}" playerid="{{item.attrs.src}}" width="100%" height="100%" controls="{{true}}" autoplay="{{false}}" isHiddenStop="{{true}}" bind:__l="__l"></txv-video></block></block></block><block wx:else><block wx:if="{{item.name=='audio'}}"><audio class="{{[item.attrs.class]}}" style="{{(item.attrs.style||'')}}" src="{{controls[item.attrs.id]?item.attrs.source[controls[item.attrs.id].index]:item.attrs.src}}" id="{{item.attrs.id}}" loop="{{item.attrs.loop}}" controls="{{item.attrs.controls}}" poster="{{item.attrs.poster}}" name="{{item.attrs.name}}" author="{{item.attrs.author}}" data-source="{{item.attrs.source}}" data-event-opts="{{[['error',[['audioError',['$event']]]]]}}" binderror="__e"></audio></block><block wx:else><block wx:if="{{item.name=='a'}}"><view class="{{['_a '+(item.attrs.class||'')]}}" style="{{(item.attrs.style||'')}}" data-attrs="{{item.attrs}}" hover-class="navigator-hover" hover-start-time="{{25}}" hover-stay-time="{{300}}" data-event-opts="{{[['tap',[['tapEvent',['$event']]]]]}}" bindtap="__e"><trees vue-id="{{'26db2430-2-'+index}}" nodes="{{item.children}}" imgMode="{{imgMode}}" bind:__l="__l"></trees></view></block><block wx:else><block wx:if="{{item.name=='ad'}}"><ad class="{{[item.attrs.class||'']}}" style="{{(item.attrs.style||'')}}" unit-id="{{item.attrs['unit-id']}}" data-event-opts="{{[['error',[['adError',['$event']]]]]}}" binderror="__e"></ad></block><block wx:else><rich-text class="{{['__'+item.name]}}" style="{{(''+handler.getStyle(item.attrs.style,'block'))}}" id="{{item.attrs.id}}" nodes="{{handler.setStyle(item)}}"></rich-text></block></block></block></block></block></block></block></block></block></block><block wx:else><trees class="{{[item.attrs.id+' _'+item.name+' '+(item.attrs.class||'')]}}" style="{{(item.attrs.style||'')}}" vue-id="{{'26db2430-3-'+index}}" nodes="{{item.children}}" imgMode="{{imgMode}}" loadVideo="{{loadVideo}}" bind:__l="__l"></trees></block></block></block></view>
|
||||
28
front/components/jyf-Parser/trees.wxss
Normal file
28
front/components/jyf-Parser/trees.wxss
Normal file
@@ -0,0 +1,28 @@
|
||||
.navigator-hover{opacity:.7;text-decoration:underline}:host{display:inherit;float:inherit}._b,
|
||||
._strong{font-weight:700}._big{font-size:1.2em}._small{font-size:.8em}._blockquote,
|
||||
._div,
|
||||
._p{display:block}._code{font-family:monospace}._del{text-decoration:line-through}._em,
|
||||
._i{font-style:italic}._h1{font-size:2em}._h2{font-size:1.5em}._h3{font-size:1.17em}._h5{font-size:.67em}._h1,
|
||||
._h2,
|
||||
._h3,
|
||||
._h4,
|
||||
._h5,
|
||||
._h6{font-weight:700}._ins{text-decoration:underline}._q::before{content:'"'}._q::after{content:'"'}._a,
|
||||
._abbr,
|
||||
._b,
|
||||
._big,
|
||||
._small,
|
||||
._code,
|
||||
._del,
|
||||
._em,
|
||||
._i,
|
||||
._ins,
|
||||
._label,
|
||||
._q,
|
||||
._span,
|
||||
._strong{display:inline}.__sub,
|
||||
.__sup,
|
||||
.__bdo,
|
||||
.__bdi,
|
||||
.__ruby,
|
||||
.__rt{display:inline-block!important}._video{background-color:#000;width:300px;height:225px;display:inline-block;position:relative}._video::after{content:"";border-width:15px 0 15px 30px;border-style:solid;border-color:transparent transparent transparent #fff;position:absolute;left:50%;top:50%;margin:-15px 0 0 -15px}
|
||||
Reference in New Issue
Block a user