feat:初始提交uni-app项目

This commit is contained in:
2026-01-14 18:19:33 +08:00
commit 0dcbd340e6
515 changed files with 38560 additions and 0 deletions

View File

@@ -0,0 +1 @@
"use strict";const e=require("../../../../common/vendor.js"),t=require("./parser.js"),n=[],i={name:"mp-html",data:()=>({nodes:[]}),props:{containerStyle:{type:String,default:""},content:{type:String,default:""},copyLink:{type:[Boolean,String],default:!0},domain:String,errorImg:{type:String,default:""},lazyLoad:{type:[Boolean,String],default:!1},loadingImg:{type:String,default:""},pauseVideo:{type:[Boolean,String],default:!0},previewImg:{type:[Boolean,String],default:!0},scrollTable:[Boolean,String],selectable:[Boolean,String],setTitle:{type:[Boolean,String],default:!0},showImgMenu:{type:[Boolean,String],default:!0},tagStyle:Object,useAnchor:[Boolean,Number]},emits:["load","ready","imgtap","linktap","play","error"],components:{node:()=>"./node/node.js"},watch:{content(e){this.setContent(e)}},created(){this.plugins=[];for(let e=n.length;e--;)this.plugins.push(new n[e](this))},mounted(){this.content&&!this.nodes.length&&this.setContent(this.content)},beforeDestroy(){this._hook("onDetached")},methods:{in(e,t,n){e&&t&&n&&(this._in={page:e,selector:t,scrollTop:n})},navigateTo(t,n){return new Promise(((i,o)=>{if(!this.useAnchor)return void o(Error("Anchor is disabled"));n=n||parseInt(this.useAnchor)||0;let s=" ";s=">>>";const r=e.index.createSelectorQuery().in(this._in?this._in.page:this).select((this._in?this._in.selector:"._root")+(t?`>>>#${t}`:"")).boundingClientRect();this._in?r.select(this._in.selector).scrollOffset().select(this._in.selector).boundingClientRect():r.selectViewport().scrollOffset(),r.exec((t=>{if(!t[0])return void o(Error("Label not found"));const s=t[1].scrollTop+t[0].top-(t[2]?t[2].top:0)+n;this._in?this._in.page[this._in.scrollTop]=s:e.index.pageScrollTo({scrollTop:s,duration:300}),i()}))}))},getText(e){let t="";return function e(n){for(let i=0;i<n.length;i++){const o=n[i];if("text"===o.type)t+=o.text.replace(/&amp;/g,"&");else if("br"===o.name)t+="\n";else{const n="p"===o.name||"div"===o.name||"tr"===o.name||"li"===o.name||"h"===o.name[0]&&o.name[1]>"0"&&o.name[1]<"7";n&&t&&"\n"!==t[t.length-1]&&(t+="\n"),o.children&&e(o.children),n&&"\n"!==t[t.length-1]?t+="\n":"td"!==o.name&&"th"!==o.name||(t+="\t")}}}(e||this.nodes),t},getRect(){return new Promise(((t,n)=>{e.index.createSelectorQuery().in(this).select("#_root").boundingClientRect().exec((e=>e[0]?t(e[0]):n(Error("Root label not found"))))}))},pauseMedia(){for(let e=(this._videos||[]).length;e--;)this._videos[e].pause()},setPlaybackRate(e){this.playbackRate=e;for(let t=(this._videos||[]).length;t--;)this._videos[t].playbackRate(e)},setContent(e,n){n&&this.imgList||(this.imgList=[]);const i=new t.Parser(this).parse(e);if(this.$set(this,"nodes",n?(this.nodes||[]).concat(i):i),this._videos=[],this.$nextTick((()=>{this._hook("onLoad"),this.$emit("load")})),this.lazyLoad||this.imgList._unloadimgs<this.imgList.length/2){let e=0;const t=n=>{n&&n.height||(n={}),n.height===e?this.$emit("ready",n):(e=n.height,setTimeout((()=>{this.getRect().then(t).catch(t)}),350))};this.getRect().then(t).catch(t)}else this.imgList._unloadimgs||this.getRect().then((e=>{this.$emit("ready",e)})).catch((()=>{this.$emit("ready",{})}))},_hook(e){for(let t=n.length;t--;)this.plugins[t][e]&&this.plugins[t][e]()}}};if(!Array){e.resolveComponent("node")()}const o=e._export_sfc(i,[["render",function(t,n,i,o,s,r){return e.e({a:!s.nodes[0]},s.nodes[0]?{b:e.p({childs:s.nodes,opts:[i.lazyLoad,i.loadingImg,i.errorImg,i.showImgMenu,i.selectable],name:"span"})}:{},{c:e.n((i.selectable?"_select ":"")+"_root"),d:e.s(i.containerStyle)})}]]);wx.createComponent(o);

View File

@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"node": "./node/node"
}
}

View File

@@ -0,0 +1 @@
<view id="_root" class="{{c}}" style="{{d}}"><slot wx:if="{{a}}"/><node wx:else u-i="5db0d42e-0" bind:__l="__l" u-p="{{b||''}}"/></view>

View File

@@ -0,0 +1 @@
._root{padding:1px 0;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch}._select{-webkit-user-select:text;user-select:text}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,6 @@
{
"component": true,
"usingComponents": {
"node": "./node"
}
}

View File

@@ -0,0 +1,31 @@
<wxs module="handler">
// 行内标签列表
var inlineTags = {
abbr: true,
b: true,
big: true,
code: true,
del: true,
em: true,
i: true,
ins: true,
label: true,
q: true,
small: true,
span: true,
strong: true,
sub: true,
sup: true
}
/**
* @description 判断是否为行内标签
*/
module.exports = {
isInline: function (tagName, style) {
return inlineTags[tagName] || (style || '').indexOf('display:inline') !== -1
}
}
</wxs>
<view id="{{b}}" class="{{c}}" style="{{d}}"><block wx:for="{{a}}" wx:for-item="n" wx:key="aI"><image wx:if="{{n.a}}" class="_img" style="{{n.b}}" src="{{n.c}}" mode="widthFix"/><rich-text wx:if="{{n.d}}" style="{{n.e}}" nodes="{{n.f}}" data-i="{{n.g}}" catchtap="{{n.h}}"/><image wx:elif="{{n.i}}" id="{{n.j}}" class="{{n.k}}" style="{{n.l}}" src="{{n.m}}" mode="{{n.n}}" lazy-load="{{n.o}}" webp="{{n.p}}" show-menu-by-longpress="{{n.q}}" image-menu-prevent="{{n.r}}" data-i="{{n.s}}" bindload="{{n.t}}" binderror="{{n.v}}" catchtap="{{n.w}}" bindlongpress="{{n.x}}"/><text wx:elif="{{n.y}}" user-select="{{n.A}}" decode>{{n.z}}</text><text wx:elif="{{n.B}}">\n</text><view wx:elif="{{n.C}}" id="{{n.F}}" class="{{n.G}}" hover-class="_hover" style="{{n.H}}" data-i="{{n.I}}" catchtap="{{n.J}}"><node wx:if="{{n.E}}" style="display:inherit" u-i="{{n.D}}" bind:__l="__l" u-p="{{n.E}}"/></view><video wx:elif="{{n.K}}" id="{{n.L}}" class="{{n.M}}" style="{{n.N}}" autoplay="{{n.O}}" controls="{{n.P}}" loop="{{n.Q}}" muted="{{n.R}}" object-fit="{{n.S}}" poster="{{n.T}}" src="{{n.U}}" data-i="{{n.V}}" bindplay="{{n.W}}" binderror="{{n.X}}"/><audio wx:elif="{{n.Y}}" id="{{n.Z}}" class="{{n.aa}}" style="{{n.ab}}" author="{{n.ac}}" controls="{{n.ad}}" loop="{{n.ae}}" name="{{n.af}}" poster="{{n.ag}}" src="{{n.ah}}" data-i="{{n.ai}}" bindplay="{{n.aj}}" binderror="{{n.ak}}"/><view wx:elif="{{n.al}}" id="{{n.aq}}" class="{{n.ar}}" style="{{n.as}}"><node wx:if="{{n.am}}" u-i="{{n.an}}" bind:__l="__l" u-p="{{n.ao}}"/><block wx:else><view wx:for="{{n.ap}}" wx:for-item="tbody" wx:key="e" class="{{tbody.f}}" style="{{tbody.g}}"><node wx:if="{{tbody.a}}" u-i="{{tbody.b}}" bind:__l="__l" u-p="{{tbody.c}}"/><block wx:else><block wx:for="{{tbody.d}}" wx:for-item="tr" wx:key="i"><view wx:if="{{tr.a}}" class="{{tr.d}}" style="{{tr.e}}"><node wx:if="{{tr.c}}" u-i="{{tr.b}}" bind:__l="__l" u-p="{{tr.c}}"/></view><view wx:else class="{{tr.g}}" style="{{tr.h}}"><view wx:for="{{tr.f}}" wx:for-item="td" wx:key="c" class="{{td.d}}" style="{{td.e}}"><node wx:if="{{td.b}}" u-i="{{td.a}}" bind:__l="__l" u-p="{{td.b}}"/></view></view></block></block></view></block></view><rich-text wx:elif="{{n.at}}" id="{{n.av}}" style="{{n.aw}}" preview="{{false}}" selectable="{{n.ax}}" user-select="{{n.ay}}" nodes="{{n.az}}"/><view wx:elif="{{n.aA}}" id="{{n.aC}}" class="{{n.aD}}" style="{{n.aE}}"><node wx:for="{{n.aB}}" wx:for-item="n2" wx:key="a" style="{{n2.b}}" u-i="{{n2.c}}" bind:__l="__l" u-p="{{n2.d}}"/></view><node wx:else style="{{n.aF}}" u-i="{{n.aG}}" bind:__l="__l" u-p="{{n.aH||''}}"/></block></view>

View File

@@ -0,0 +1 @@
._a{padding:1.5px 0;color:#366092;word-break:break-all}._hover{text-decoration:underline;opacity:.7}._img{max-width:100%;-webkit-touch-callout:none}._block{display:block}._b,._strong{font-weight:700}._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:.83em}._h6{font-size:.67em}._h1,._h2,._h3,._h4,._h5,._h6{display:block;font-weight:700}._image{height:1px}._ins{text-decoration:underline}._li{display:list-item}._ol{list-style-type:decimal}._ol,._ul{display:block;padding-left:40px;margin:1em 0}._q:before{content:'"'}._q:after{content:'"'}._sub{font-size:smaller;vertical-align:sub}._sup{font-size:smaller;vertical-align:super}._thead,._tbody,._tfoot{display:table-row-group}._tr{display:table-row}._td,._th{display:table-cell;vertical-align:middle}._th{font-weight:700;text-align:center}._ul{list-style-type:disc}._ul ._ul{margin:0;list-style-type:circle}._ul ._ul ._ul{list-style-type:square}._abbr,._b,._code,._del,._em,._i,._ins,._label,._q,._span,._strong,._sub,._sup{display:inline}

File diff suppressed because one or more lines are too long