init comi
This commit is contained in:
parent
2eae5429de
commit
7af2bb790f
|
@ -0,0 +1,39 @@
|
|||
//app.js
|
||||
App({
|
||||
onLaunch: function () {
|
||||
// 展示本地存储能力
|
||||
var logs = wx.getStorageSync('logs') || []
|
||||
logs.unshift(Date.now())
|
||||
wx.setStorageSync('logs', logs)
|
||||
|
||||
// 登录
|
||||
wx.login({
|
||||
success: res => {
|
||||
// 发送 res.code 到后台换取 openId, sessionKey, unionId
|
||||
}
|
||||
})
|
||||
// 获取用户信息
|
||||
wx.getSetting({
|
||||
success: res => {
|
||||
if (res.authSetting['scope.userInfo']) {
|
||||
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
|
||||
wx.getUserInfo({
|
||||
success: res => {
|
||||
// 可以将 res 发送给后台解码出 unionId
|
||||
this.globalData.userInfo = res.userInfo
|
||||
|
||||
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
||||
// 所以此处加入 callback 以防止这种情况
|
||||
if (this.userInfoReadyCallback) {
|
||||
this.userInfoReadyCallback(res)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
globalData: {
|
||||
userInfo: null
|
||||
}
|
||||
})
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"pages":[
|
||||
"pages/index/index",
|
||||
"pages/logs/logs"
|
||||
],
|
||||
"window":{
|
||||
"backgroundTextStyle":"light",
|
||||
"navigationBarBackgroundColor": "#fff",
|
||||
"navigationBarTitleText": "WeChat",
|
||||
"navigationBarTextStyle":"black"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
/**app.wxss**/
|
||||
.container {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 200rpx 0;
|
||||
box-sizing: border-box;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
|
||||
var WxParse = require('./wxParse.js');
|
||||
|
||||
module.exports = function comi(md, scope) {
|
||||
|
||||
WxParse.wxParse('article', 'md', md, scope, 5);
|
||||
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
|
||||
<import src="./wxParse.wxml"/>
|
||||
|
||||
<template is="wxParse" data="{{wxParseData:article.nodes}}"/>
|
|
@ -0,0 +1,2 @@
|
|||
@import './wxParse.wxss';
|
||||
@import './prism.wxss';
|
|
@ -0,0 +1,303 @@
|
|||
/**
|
||||
* html2Json 改造来自: https://github.com/Jxck/html2json
|
||||
*
|
||||
*
|
||||
* author: Di (微信小程序开发工程师)
|
||||
* organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
|
||||
* 垂直微信小程序开发交流社区
|
||||
*
|
||||
* github地址: https://github.com/icindy/wxParse
|
||||
*
|
||||
* for: 微信小程序富文本解析
|
||||
* detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
|
||||
*/
|
||||
|
||||
var __placeImgeUrlHttps = "https";
|
||||
var __emojisReg = '';
|
||||
var __emojisBaseSrc = '';
|
||||
var __emojis = {};
|
||||
var wxDiscode = require('./wxDiscode.js');
|
||||
var HTMLParser = require('./htmlparser.js');
|
||||
// Empty Elements - HTML 5
|
||||
var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");
|
||||
// Block Elements - HTML 5
|
||||
var block = makeMap("br,a,code,address,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video");
|
||||
|
||||
// Inline Elements - HTML 5
|
||||
var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
|
||||
|
||||
// Elements that you can, intentionally, leave open
|
||||
// (and which close themselves)
|
||||
var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
|
||||
|
||||
// Attributes that have their values filled in disabled="disabled"
|
||||
var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
|
||||
|
||||
// Special Elements (can contain anything)
|
||||
var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block");
|
||||
function makeMap(str) {
|
||||
var obj = {}, items = str.split(",");
|
||||
for (var i = 0; i < items.length; i++)
|
||||
obj[items[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
function q(v) {
|
||||
return '"' + v + '"';
|
||||
}
|
||||
|
||||
function removeDOCTYPE(html) {
|
||||
return html
|
||||
.replace(/<\?xml.*\?>\n/, '')
|
||||
.replace(/<.*!doctype.*\>\n/, '')
|
||||
.replace(/<.*!DOCTYPE.*\>\n/, '');
|
||||
}
|
||||
|
||||
function trimHtml(html) {
|
||||
return html
|
||||
//.replace(/\r?\n+/g, '')
|
||||
.replace(/<!--.*?-->/ig, '')
|
||||
.replace(/\/\*.*?\*\//ig, '')
|
||||
.replace(/[ ]+</ig, '<')
|
||||
}
|
||||
|
||||
|
||||
function html2json(html, bindName) {
|
||||
//处理字符串
|
||||
html = removeDOCTYPE(html);
|
||||
html = trimHtml(html);
|
||||
html = wxDiscode.strDiscode(html);
|
||||
//生成node节点
|
||||
var bufArray = [];
|
||||
var results = {
|
||||
node: bindName,
|
||||
nodes: [],
|
||||
images:[],
|
||||
imageUrls:[]
|
||||
};
|
||||
var index = 0;
|
||||
HTMLParser(html, {
|
||||
start: function (tag, attrs, unary) {
|
||||
//debug(tag, attrs, unary);
|
||||
// node for this element
|
||||
var node = {
|
||||
node: 'element',
|
||||
tag: tag,
|
||||
};
|
||||
|
||||
if (bufArray.length === 0) {
|
||||
node.index = index.toString()
|
||||
index += 1
|
||||
} else {
|
||||
var parent = bufArray[0];
|
||||
if (parent.nodes === undefined) {
|
||||
parent.nodes = [];
|
||||
}
|
||||
node.index = parent.index + '.' + parent.nodes.length
|
||||
}
|
||||
|
||||
if (block[tag]) {
|
||||
node.tagType = "block";
|
||||
} else if (inline[tag]) {
|
||||
node.tagType = "inline";
|
||||
} else if (closeSelf[tag]) {
|
||||
node.tagType = "closeSelf";
|
||||
}
|
||||
|
||||
if (attrs.length !== 0) {
|
||||
node.attr = attrs.reduce(function (pre, attr) {
|
||||
var name = attr.name;
|
||||
var value = attr.value;
|
||||
if (name == 'class') {
|
||||
console.dir(value);
|
||||
// value = value.join("")
|
||||
node.classStr = value;
|
||||
}
|
||||
// has multi attibutes
|
||||
// make it array of attribute
|
||||
if (name == 'style') {
|
||||
console.dir(value);
|
||||
// value = value.join("")
|
||||
node.styleStr = value;
|
||||
}
|
||||
if (value.match(/ /)) {
|
||||
value = value.split(' ');
|
||||
}
|
||||
|
||||
|
||||
// if attr already exists
|
||||
// merge it
|
||||
if (pre[name]) {
|
||||
if (Array.isArray(pre[name])) {
|
||||
// already array, push to last
|
||||
pre[name].push(value);
|
||||
} else {
|
||||
// single value, make it array
|
||||
pre[name] = [pre[name], value];
|
||||
}
|
||||
} else {
|
||||
// not exist, put it
|
||||
pre[name] = value;
|
||||
}
|
||||
|
||||
return pre;
|
||||
}, {});
|
||||
}
|
||||
|
||||
//对img添加额外数据
|
||||
if (node.tag === 'img') {
|
||||
node.imgIndex = results.images.length;
|
||||
var imgUrl = node.attr.src;
|
||||
if (imgUrl[0] == '') {
|
||||
imgUrl.splice(0, 1);
|
||||
}
|
||||
imgUrl = wxDiscode.urlToHttpUrl(imgUrl, __placeImgeUrlHttps);
|
||||
node.attr.src = imgUrl;
|
||||
node.from = bindName;
|
||||
results.images.push(node);
|
||||
results.imageUrls.push(imgUrl);
|
||||
}
|
||||
|
||||
// 处理font标签样式属性
|
||||
if (node.tag === 'font') {
|
||||
var fontSize = ['x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', '-webkit-xxx-large'];
|
||||
var styleAttrs = {
|
||||
'color': 'color',
|
||||
'face': 'font-family',
|
||||
'size': 'font-size'
|
||||
};
|
||||
if (!node.attr.style) node.attr.style = [];
|
||||
if (!node.styleStr) node.styleStr = '';
|
||||
for (var key in styleAttrs) {
|
||||
if (node.attr[key]) {
|
||||
var value = key === 'size' ? fontSize[node.attr[key]-1] : node.attr[key];
|
||||
node.attr.style.push(styleAttrs[key]);
|
||||
node.attr.style.push(value);
|
||||
node.styleStr += styleAttrs[key] + ': ' + value + ';';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//临时记录source资源
|
||||
if(node.tag === 'source'){
|
||||
results.source = node.attr.src;
|
||||
}
|
||||
|
||||
if (unary) {
|
||||
// if this tag doesn't have end tag
|
||||
// like <img src="hoge.png"/>
|
||||
// add to parents
|
||||
var parent = bufArray[0] || results;
|
||||
if (parent.nodes === undefined) {
|
||||
parent.nodes = [];
|
||||
}
|
||||
parent.nodes.push(node);
|
||||
} else {
|
||||
bufArray.unshift(node);
|
||||
}
|
||||
},
|
||||
end: function (tag) {
|
||||
//debug(tag);
|
||||
// merge into parent tag
|
||||
var node = bufArray.shift();
|
||||
if (node.tag !== tag) console.error('invalid state: mismatch end tag');
|
||||
|
||||
//当有缓存source资源时于于video补上src资源
|
||||
if(node.tag === 'video' && results.source){
|
||||
node.attr.src = results.source;
|
||||
delete results.source;
|
||||
}
|
||||
|
||||
if (bufArray.length === 0) {
|
||||
results.nodes.push(node);
|
||||
} else {
|
||||
var parent = bufArray[0];
|
||||
if (parent.nodes === undefined) {
|
||||
parent.nodes = [];
|
||||
}
|
||||
parent.nodes.push(node);
|
||||
}
|
||||
},
|
||||
chars: function (text) {
|
||||
//debug(text);
|
||||
var node = {
|
||||
node: 'text',
|
||||
text: text,
|
||||
textArray:transEmojiStr(text)
|
||||
};
|
||||
|
||||
if (bufArray.length === 0) {
|
||||
node.index = index.toString()
|
||||
index += 1
|
||||
results.nodes.push(node);
|
||||
} else {
|
||||
var parent = bufArray[0];
|
||||
if (parent.nodes === undefined) {
|
||||
parent.nodes = [];
|
||||
}
|
||||
node.index = parent.index + '.' + parent.nodes.length
|
||||
parent.nodes.push(node);
|
||||
}
|
||||
},
|
||||
comment: function (text) {
|
||||
//debug(text);
|
||||
// var node = {
|
||||
// node: 'comment',
|
||||
// text: text,
|
||||
// };
|
||||
// var parent = bufArray[0];
|
||||
// if (parent.nodes === undefined) {
|
||||
// parent.nodes = [];
|
||||
// }
|
||||
// parent.nodes.push(node);
|
||||
},
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
function transEmojiStr(str){
|
||||
// var eReg = new RegExp("["+__reg+' '+"]");
|
||||
// str = str.replace(/\[([^\[\]]+)\]/g,':$1:')
|
||||
|
||||
var emojiObjs = [];
|
||||
//如果正则表达式为空
|
||||
if(__emojisReg.length == 0 || !__emojis){
|
||||
var emojiObj = {}
|
||||
emojiObj.node = "text";
|
||||
emojiObj.text = str;
|
||||
array = [emojiObj];
|
||||
return array;
|
||||
}
|
||||
//这个地方需要调整
|
||||
str = str.replace(/\[([^\[\]]+)\]/g,':$1:')
|
||||
var eReg = new RegExp("[:]");
|
||||
var array = str.split(eReg);
|
||||
for(var i = 0; i < array.length; i++){
|
||||
var ele = array[i];
|
||||
var emojiObj = {};
|
||||
if(__emojis[ele]){
|
||||
emojiObj.node = "element";
|
||||
emojiObj.tag = "emoji";
|
||||
emojiObj.text = __emojis[ele];
|
||||
emojiObj.baseSrc= __emojisBaseSrc;
|
||||
}else{
|
||||
emojiObj.node = "text";
|
||||
emojiObj.text = ele;
|
||||
}
|
||||
emojiObjs.push(emojiObj);
|
||||
}
|
||||
|
||||
return emojiObjs;
|
||||
}
|
||||
|
||||
function emojisInit(reg='',baseSrc="/wxParse/emojis/",emojis){
|
||||
__emojisReg = reg;
|
||||
__emojisBaseSrc=baseSrc;
|
||||
__emojis=emojis;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
html2json: html2json,
|
||||
emojisInit:emojisInit
|
||||
};
|
||||
|
|
@ -0,0 +1,192 @@
|
|||
/**
|
||||
*
|
||||
* htmlParser改造自: https://github.com/blowsie/Pure-JavaScript-HTML5-Parser
|
||||
*
|
||||
* author: Di (微信小程序开发工程师)
|
||||
* organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
|
||||
* 垂直微信小程序开发交流社区
|
||||
*
|
||||
* github地址: https://github.com/icindy/wxParse
|
||||
*
|
||||
* for: 微信小程序富文本解析
|
||||
* detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
|
||||
*/
|
||||
// Regular Expressions for parsing tags and attributes
|
||||
var startTag = /^<([-A-Za-z0-9_]+)((?:\s+[a-zA-Z_:][-a-zA-Z0-9_:.]*(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
|
||||
endTag = /^<\/([-A-Za-z0-9_]+)[^>]*>/,
|
||||
attr = /([a-zA-Z_:][-a-zA-Z0-9_:.]*)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
|
||||
|
||||
// Empty Elements - HTML 5
|
||||
var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,link,meta,param,embed,command,keygen,source,track,wbr");
|
||||
|
||||
// Block Elements - HTML 5
|
||||
var block = makeMap("a,address,code,article,applet,aside,audio,blockquote,button,canvas,center,dd,del,dir,div,dl,dt,fieldset,figcaption,figure,footer,form,frameset,h1,h2,h3,h4,h5,h6,header,hgroup,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,output,p,pre,section,script,table,tbody,td,tfoot,th,thead,tr,ul,video");
|
||||
|
||||
// Inline Elements - HTML 5
|
||||
var inline = makeMap("abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
|
||||
|
||||
// Elements that you can, intentionally, leave open
|
||||
// (and which close themselves)
|
||||
var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
|
||||
|
||||
// Attributes that have their values filled in disabled="disabled"
|
||||
var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
|
||||
|
||||
// Special Elements (can contain anything)
|
||||
var special = makeMap("wxxxcode-style,script,style,view,scroll-view,block");
|
||||
|
||||
function HTMLParser(html, handler) {
|
||||
var index, chars, match, stack = [], last = html;
|
||||
stack.last = function () {
|
||||
return this[this.length - 1];
|
||||
};
|
||||
|
||||
while (html) {
|
||||
chars = true;
|
||||
|
||||
// Make sure we're not in a script or style element
|
||||
if (!stack.last() || !special[stack.last()]) {
|
||||
|
||||
// Comment
|
||||
if (html.indexOf("<!--") == 0) {
|
||||
index = html.indexOf("-->");
|
||||
|
||||
if (index >= 0) {
|
||||
if (handler.comment)
|
||||
handler.comment(html.substring(4, index));
|
||||
html = html.substring(index + 3);
|
||||
chars = false;
|
||||
}
|
||||
|
||||
// end tag
|
||||
} else if (html.indexOf("</") == 0) {
|
||||
match = html.match(endTag);
|
||||
|
||||
if (match) {
|
||||
html = html.substring(match[0].length);
|
||||
match[0].replace(endTag, parseEndTag);
|
||||
chars = false;
|
||||
}
|
||||
|
||||
// start tag
|
||||
} else if (html.indexOf("<") == 0) {
|
||||
match = html.match(startTag);
|
||||
|
||||
if (match) {
|
||||
html = html.substring(match[0].length);
|
||||
match[0].replace(startTag, parseStartTag);
|
||||
chars = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (chars) {
|
||||
index = html.indexOf("<");
|
||||
var text = ''
|
||||
while (index === 0) {
|
||||
text += "<";
|
||||
html = html.substring(1);
|
||||
index = html.indexOf("<");
|
||||
}
|
||||
text += index < 0 ? html : html.substring(0, index);
|
||||
html = index < 0 ? "" : html.substring(index);
|
||||
|
||||
if (handler.chars)
|
||||
handler.chars(text);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
html = html.replace(new RegExp("([\\s\\S]*?)<\/" + stack.last() + "[^>]*>"), function (all, text) {
|
||||
text = text.replace(/<!--([\s\S]*?)-->|<!\[CDATA\[([\s\S]*?)]]>/g, "$1$2");
|
||||
if (handler.chars)
|
||||
handler.chars(text);
|
||||
|
||||
return "";
|
||||
});
|
||||
|
||||
|
||||
parseEndTag("", stack.last());
|
||||
}
|
||||
|
||||
if (html == last)
|
||||
throw "Parse Error: " + html;
|
||||
last = html;
|
||||
}
|
||||
|
||||
// Clean up any remaining tags
|
||||
parseEndTag();
|
||||
|
||||
function parseStartTag(tag, tagName, rest, unary) {
|
||||
tagName = tagName.toLowerCase();
|
||||
|
||||
if (block[tagName]) {
|
||||
while (stack.last() && inline[stack.last()]) {
|
||||
parseEndTag("", stack.last());
|
||||
}
|
||||
}
|
||||
|
||||
if (closeSelf[tagName] && stack.last() == tagName) {
|
||||
parseEndTag("", tagName);
|
||||
}
|
||||
|
||||
unary = empty[tagName] || !!unary;
|
||||
|
||||
if (!unary)
|
||||
stack.push(tagName);
|
||||
|
||||
if (handler.start) {
|
||||
var attrs = [];
|
||||
|
||||
rest.replace(attr, function (match, name) {
|
||||
var value = arguments[2] ? arguments[2] :
|
||||
arguments[3] ? arguments[3] :
|
||||
arguments[4] ? arguments[4] :
|
||||
fillAttrs[name] ? name : "";
|
||||
|
||||
attrs.push({
|
||||
name: name,
|
||||
value: value,
|
||||
escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //"
|
||||
});
|
||||
});
|
||||
|
||||
if (handler.start) {
|
||||
handler.start(tagName, attrs, unary);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function parseEndTag(tag, tagName) {
|
||||
// If no tag name is provided, clean shop
|
||||
if (!tagName)
|
||||
var pos = 0;
|
||||
|
||||
// Find the closest opened tag of the same type
|
||||
else {
|
||||
tagName = tagName.toLowerCase();
|
||||
for (var pos = stack.length - 1; pos >= 0; pos--)
|
||||
if (stack[pos] == tagName)
|
||||
break;
|
||||
}
|
||||
if (pos >= 0) {
|
||||
// Close all the open elements, up the stack
|
||||
for (var i = stack.length - 1; i >= pos; i--)
|
||||
if (handler.end)
|
||||
handler.end(stack[i]);
|
||||
|
||||
// Remove the open elements from the stack
|
||||
stack.length = pos;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
function makeMap(str) {
|
||||
var obj = {}, items = str.split(",");
|
||||
for (var i = 0; i < items.length; i++)
|
||||
obj[items[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
module.exports = HTMLParser;
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,220 @@
|
|||
|
||||
/* PrismJS 1.16.0
|
||||
https://prismjs.com/download.html#themes=prism-okaidia&languages=markup+css+clike+javascript+bash+json+typescript+jsx+tsx&plugins=line-highlight+line-numbers */
|
||||
/**
|
||||
* okaidia theme for JavaScript, CSS and HTML
|
||||
* Loosely based on Monokai textmate theme by http://www.monokai.nl/
|
||||
* @author ocodia
|
||||
*/
|
||||
|
||||
.code[class*="language-"],
|
||||
.pre[class*="language-"] {
|
||||
color: #f8f8f2;
|
||||
background: none;
|
||||
text-shadow: 0 1px rgba(0, 0, 0, 0.3);
|
||||
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
font-size: 25rpx;
|
||||
text-align: left;
|
||||
white-space: pre;
|
||||
word-spacing: normal;
|
||||
word-break: normal;
|
||||
word-wrap: normal;
|
||||
line-height: 1.5;
|
||||
|
||||
-moz-tab-size: 4;
|
||||
-o-tab-size: 4;
|
||||
tab-size: 4;
|
||||
|
||||
-webkit-hyphens: none;
|
||||
-moz-hyphens: none;
|
||||
-ms-hyphens: none;
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
/* Code blocks */
|
||||
.pre[class*="language-"] {
|
||||
padding: 1em;
|
||||
margin: .5em 0;
|
||||
overflow: auto;
|
||||
border-radius: 0.3em;
|
||||
}
|
||||
|
||||
:not(.pre) > .code[class*="language-"],
|
||||
.pre[class*="language-"] {
|
||||
background: #272822;
|
||||
}
|
||||
|
||||
/* Inline code */
|
||||
:not(.pre) > .code[class*="language-"] {
|
||||
padding: .1em;
|
||||
border-radius: .3em;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.token.comment,
|
||||
.token.prolog,
|
||||
.token.doctype,
|
||||
.token.cdata {
|
||||
color: slategray;
|
||||
}
|
||||
|
||||
.token.punctuation {
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
.namespace {
|
||||
opacity: .7;
|
||||
}
|
||||
|
||||
.token.property,
|
||||
.token.tag,
|
||||
.token.constant,
|
||||
.token.symbol,
|
||||
.token.deleted {
|
||||
color: #f92672;
|
||||
}
|
||||
|
||||
.token.boolean,
|
||||
.token.number {
|
||||
color: #ae81ff;
|
||||
}
|
||||
|
||||
.token.selector,
|
||||
.token.attr-name,
|
||||
.token.string,
|
||||
.token.char,
|
||||
.token.builtin,
|
||||
.token.inserted {
|
||||
color: #a6e22e;
|
||||
}
|
||||
|
||||
.token.operator,
|
||||
.token.entity,
|
||||
.token.url,
|
||||
.language-css .token.string,
|
||||
.style .token.string,
|
||||
.token.variable {
|
||||
color: #f8f8f2;
|
||||
}
|
||||
|
||||
.token.atrule,
|
||||
.token.attr-value,
|
||||
.token.function,
|
||||
.token.class-name {
|
||||
color: #e6db74;
|
||||
}
|
||||
|
||||
.token.keyword {
|
||||
color: #66d9ef;
|
||||
}
|
||||
|
||||
.token.regex,
|
||||
.token.important {
|
||||
color: #fd971f;
|
||||
}
|
||||
|
||||
.token.important,
|
||||
.token.bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
.token.italic {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.token.entity {
|
||||
cursor: help;
|
||||
}
|
||||
|
||||
.pre[data-line] {
|
||||
position: relative;
|
||||
padding: 1em 0 1em 3em;
|
||||
}
|
||||
|
||||
.line-highlight {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: inherit 0;
|
||||
margin-top: 1em; /* Same as .prism’s padding-top */
|
||||
|
||||
background: hsla(24, 20%, 50%,.08);
|
||||
background: linear-gradient(to right, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
|
||||
|
||||
pointer-events: none;
|
||||
|
||||
line-height: inherit;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.line-highlight:before,
|
||||
.line-highlight[data-end]:after {
|
||||
content: attr(data-start);
|
||||
position: absolute;
|
||||
top: .4em;
|
||||
left: .6em;
|
||||
min-width: 1em;
|
||||
padding: 0 .5em;
|
||||
background-color: hsla(24, 20%, 50%,.4);
|
||||
color: hsl(24, 20%, 95%);
|
||||
font: bold 65%/1.5 sans-serif;
|
||||
text-align: center;
|
||||
vertical-align: .3em;
|
||||
border-radius: 999px;
|
||||
text-shadow: none;
|
||||
box-shadow: 0 1px white;
|
||||
}
|
||||
|
||||
.line-highlight[data-end]:after {
|
||||
content: attr(data-end);
|
||||
top: auto;
|
||||
bottom: .4em;
|
||||
}
|
||||
|
||||
.line-numbers .line-highlight:before,
|
||||
.line-numbers .line-highlight:after {
|
||||
content: none;
|
||||
}
|
||||
|
||||
.pre[class*="language-"].line-numbers {
|
||||
position: relative;
|
||||
padding-left: 3.8em;
|
||||
counter-reset: linenumber;
|
||||
}
|
||||
|
||||
.pre[class*="language-"].line-numbers > .code {
|
||||
position: relative;
|
||||
white-space: inherit;
|
||||
}
|
||||
|
||||
.line-numbers .line-numbers-rows {
|
||||
position: absolute;
|
||||
pointer-events: none;
|
||||
top: 0;
|
||||
font-size: 100%;
|
||||
left: -3.8em;
|
||||
width: 3em; /* works for line-numbers below 1000 lines */
|
||||
letter-spacing: -1px;
|
||||
border-right: 1px solid #999;
|
||||
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
|
||||
}
|
||||
|
||||
.line-numbers-rows > span {
|
||||
pointer-events: none;
|
||||
display: block;
|
||||
counter-increment: linenumber;
|
||||
}
|
||||
|
||||
.line-numbers-rows > span:before {
|
||||
content: counter(linenumber);
|
||||
color: #999;
|
||||
display: block;
|
||||
padding-right: 0.8em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,209 @@
|
|||
// HTML 支持的数学符号
|
||||
function strNumDiscode(str){
|
||||
str = str.replace(/∀/g, '∀');
|
||||
str = str.replace(/∂/g, '∂');
|
||||
str = str.replace(/&exists;/g, '∃');
|
||||
str = str.replace(/∅/g, '∅');
|
||||
str = str.replace(/∇/g, '∇');
|
||||
str = str.replace(/∈/g, '∈');
|
||||
str = str.replace(/∉/g, '∉');
|
||||
str = str.replace(/∋/g, '∋');
|
||||
str = str.replace(/∏/g, '∏');
|
||||
str = str.replace(/∑/g, '∑');
|
||||
str = str.replace(/−/g, '−');
|
||||
str = str.replace(/∗/g, '∗');
|
||||
str = str.replace(/√/g, '√');
|
||||
str = str.replace(/∝/g, '∝');
|
||||
str = str.replace(/∞/g, '∞');
|
||||
str = str.replace(/∠/g, '∠');
|
||||
str = str.replace(/∧/g, '∧');
|
||||
str = str.replace(/∨/g, '∨');
|
||||
str = str.replace(/∩/g, '∩');
|
||||
str = str.replace(/∩/g, '∪');
|
||||
str = str.replace(/∫/g, '∫');
|
||||
str = str.replace(/∴/g, '∴');
|
||||
str = str.replace(/∼/g, '∼');
|
||||
str = str.replace(/≅/g, '≅');
|
||||
str = str.replace(/≈/g, '≈');
|
||||
str = str.replace(/≠/g, '≠');
|
||||
str = str.replace(/≤/g, '≤');
|
||||
str = str.replace(/≥/g, '≥');
|
||||
str = str.replace(/⊂/g, '⊂');
|
||||
str = str.replace(/⊃/g, '⊃');
|
||||
str = str.replace(/⊄/g, '⊄');
|
||||
str = str.replace(/⊆/g, '⊆');
|
||||
str = str.replace(/⊇/g, '⊇');
|
||||
str = str.replace(/⊕/g, '⊕');
|
||||
str = str.replace(/⊗/g, '⊗');
|
||||
str = str.replace(/⊥/g, '⊥');
|
||||
str = str.replace(/⋅/g, '⋅');
|
||||
return str;
|
||||
}
|
||||
|
||||
//HTML 支持的希腊字母
|
||||
function strGreeceDiscode(str){
|
||||
str = str.replace(/Α/g, 'Α');
|
||||
str = str.replace(/Β/g, 'Β');
|
||||
str = str.replace(/Γ/g, 'Γ');
|
||||
str = str.replace(/Δ/g, 'Δ');
|
||||
str = str.replace(/Ε/g, 'Ε');
|
||||
str = str.replace(/Ζ/g, 'Ζ');
|
||||
str = str.replace(/Η/g, 'Η');
|
||||
str = str.replace(/Θ/g, 'Θ');
|
||||
str = str.replace(/Ι/g, 'Ι');
|
||||
str = str.replace(/Κ/g, 'Κ');
|
||||
str = str.replace(/Λ/g, 'Λ');
|
||||
str = str.replace(/Μ/g, 'Μ');
|
||||
str = str.replace(/Ν/g, 'Ν');
|
||||
str = str.replace(/Ξ/g, 'Ν');
|
||||
str = str.replace(/Ο/g, 'Ο');
|
||||
str = str.replace(/Π/g, 'Π');
|
||||
str = str.replace(/Ρ/g, 'Ρ');
|
||||
str = str.replace(/Σ/g, 'Σ');
|
||||
str = str.replace(/Τ/g, 'Τ');
|
||||
str = str.replace(/Υ/g, 'Υ');
|
||||
str = str.replace(/Φ/g, 'Φ');
|
||||
str = str.replace(/Χ/g, 'Χ');
|
||||
str = str.replace(/Ψ/g, 'Ψ');
|
||||
str = str.replace(/Ω/g, 'Ω');
|
||||
|
||||
str = str.replace(/α/g, 'α');
|
||||
str = str.replace(/β/g, 'β');
|
||||
str = str.replace(/γ/g, 'γ');
|
||||
str = str.replace(/δ/g, 'δ');
|
||||
str = str.replace(/ε/g, 'ε');
|
||||
str = str.replace(/ζ/g, 'ζ');
|
||||
str = str.replace(/η/g, 'η');
|
||||
str = str.replace(/θ/g, 'θ');
|
||||
str = str.replace(/ι/g, 'ι');
|
||||
str = str.replace(/κ/g, 'κ');
|
||||
str = str.replace(/λ/g, 'λ');
|
||||
str = str.replace(/μ/g, 'μ');
|
||||
str = str.replace(/ν/g, 'ν');
|
||||
str = str.replace(/ξ/g, 'ξ');
|
||||
str = str.replace(/ο/g, 'ο');
|
||||
str = str.replace(/π/g, 'π');
|
||||
str = str.replace(/ρ/g, 'ρ');
|
||||
str = str.replace(/ς/g, 'ς');
|
||||
str = str.replace(/σ/g, 'σ');
|
||||
str = str.replace(/τ/g, 'τ');
|
||||
str = str.replace(/υ/g, 'υ');
|
||||
str = str.replace(/φ/g, 'φ');
|
||||
str = str.replace(/χ/g, 'χ');
|
||||
str = str.replace(/ψ/g, 'ψ');
|
||||
str = str.replace(/ω/g, 'ω');
|
||||
str = str.replace(/ϑ/g, 'ϑ');
|
||||
str = str.replace(/ϒ/g, 'ϒ');
|
||||
str = str.replace(/ϖ/g, 'ϖ');
|
||||
str = str.replace(/·/g, '·');
|
||||
return str;
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
function strcharacterDiscode(str){
|
||||
// 加入常用解析
|
||||
str = str.replace(/↵/g, '\n');
|
||||
str = str.replace(/ /g, '\xa0');
|
||||
//str = str.replace(/ /g, ' ');
|
||||
str = str.replace(/"/g, "'");
|
||||
str = str.replace(/&/g, '&');
|
||||
// str = str.replace(/</g, '‹');
|
||||
// str = str.replace(/>/g, '›');
|
||||
|
||||
str = str.replace(/</g, '<');
|
||||
str = str.replace(/>/g, '>');
|
||||
str = str.replace(/•/g, '•');
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
// HTML 支持的其他实体
|
||||
function strOtherDiscode(str){
|
||||
str = str.replace(/Œ/g, 'Œ');
|
||||
str = str.replace(/œ/g, 'œ');
|
||||
str = str.replace(/Š/g, 'Š');
|
||||
str = str.replace(/š/g, 'š');
|
||||
str = str.replace(/Ÿ/g, 'Ÿ');
|
||||
str = str.replace(/ƒ/g, 'ƒ');
|
||||
str = str.replace(/ˆ/g, 'ˆ');
|
||||
str = str.replace(/˜/g, '˜');
|
||||
str = str.replace(/ /g, '');
|
||||
str = str.replace(/ /g, '');
|
||||
str = str.replace(/ /g, '');
|
||||
str = str.replace(/‌/g, '');
|
||||
str = str.replace(/‍/g, '');
|
||||
str = str.replace(/‎/g, '');
|
||||
str = str.replace(/‏/g, '');
|
||||
str = str.replace(/–/g, '–');
|
||||
str = str.replace(/—/g, '—');
|
||||
str = str.replace(/‘/g, '‘');
|
||||
str = str.replace(/’/g, '’');
|
||||
str = str.replace(/‚/g, '‚');
|
||||
str = str.replace(/“/g, '“');
|
||||
str = str.replace(/”/g, '”');
|
||||
str = str.replace(/„/g, '„');
|
||||
str = str.replace(/†/g, '†');
|
||||
str = str.replace(/‡/g, '‡');
|
||||
str = str.replace(/•/g, '•');
|
||||
str = str.replace(/…/g, '…');
|
||||
str = str.replace(/‰/g, '‰');
|
||||
str = str.replace(/′/g, '′');
|
||||
str = str.replace(/″/g, '″');
|
||||
str = str.replace(/‹/g, '‹');
|
||||
str = str.replace(/›/g, '›');
|
||||
str = str.replace(/‾/g, '‾');
|
||||
str = str.replace(/€/g, '€');
|
||||
str = str.replace(/™/g, '™');
|
||||
|
||||
str = str.replace(/←/g, '←');
|
||||
str = str.replace(/↑/g, '↑');
|
||||
str = str.replace(/→/g, '→');
|
||||
str = str.replace(/↓/g, '↓');
|
||||
str = str.replace(/↔/g, '↔');
|
||||
str = str.replace(/↵/g, '↵');
|
||||
str = str.replace(/⌈/g, '⌈');
|
||||
str = str.replace(/⌉/g, '⌉');
|
||||
|
||||
str = str.replace(/⌊/g, '⌊');
|
||||
str = str.replace(/⌋/g, '⌋');
|
||||
str = str.replace(/◊/g, '◊');
|
||||
str = str.replace(/♠/g, '♠');
|
||||
str = str.replace(/♣/g, '♣');
|
||||
str = str.replace(/♥/g, '♥');
|
||||
|
||||
str = str.replace(/♦/g, '♦');
|
||||
str = str.replace(/'/g, '\'');
|
||||
return str;
|
||||
}
|
||||
|
||||
function strMoreDiscode(str){
|
||||
// str = str.replace(/\r\n/g,"");
|
||||
// str = str.replace(/\n/g,"");
|
||||
|
||||
str = str.replace(/code/g,"wxxxcode-style");
|
||||
return str;
|
||||
}
|
||||
|
||||
function strDiscode(str){
|
||||
str = strNumDiscode(str);
|
||||
str = strGreeceDiscode(str);
|
||||
str = strcharacterDiscode(str);
|
||||
str = strOtherDiscode(str);
|
||||
str = strMoreDiscode(str);
|
||||
return str;
|
||||
}
|
||||
function urlToHttpUrl(url,rep){
|
||||
|
||||
var patt1 = new RegExp("^//");
|
||||
var result = patt1.test(url);
|
||||
if(result){
|
||||
url = rep+":"+url;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
strDiscode:strDiscode,
|
||||
urlToHttpUrl:urlToHttpUrl
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
/**
|
||||
* author: Di (微信小程序开发工程师)
|
||||
* organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
|
||||
* 垂直微信小程序开发交流社区
|
||||
*
|
||||
* github地址: https://github.com/icindy/wxParse
|
||||
*
|
||||
* for: 微信小程序富文本解析
|
||||
* detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
|
||||
*/
|
||||
//根据这个修改 https://blog.csdn.net/qq_42833001/article/details/84659474
|
||||
/**
|
||||
* utils函数引入
|
||||
**/
|
||||
import Remarkable from './remarkable'
|
||||
import HtmlToJson from './html2json.js';
|
||||
import prism from './prism'
|
||||
/**
|
||||
* 配置及公有属性
|
||||
**/
|
||||
var realWindowWidth = 0;
|
||||
var realWindowHeight = 0;
|
||||
wx.getSystemInfo({
|
||||
success: function (res) {
|
||||
realWindowWidth = res.windowWidth
|
||||
realWindowHeight = res.windowHeight
|
||||
}
|
||||
})
|
||||
/**
|
||||
* 主函数入口区
|
||||
**/
|
||||
function wxParse(bindName = 'wxParseData', type='html', data='<div class="color:red;">数据不能为空</div>', target,imagePadding) {
|
||||
var that = target;
|
||||
var transData = {};//存放转化后的数据
|
||||
if (type == 'html') {
|
||||
transData = HtmlToJson.html2json(data, bindName);
|
||||
//console.log(JSON.stringify(transData, ' ', ' '));
|
||||
} else if (type == 'md' || type == 'markdown') {
|
||||
var converter = new Remarkable()
|
||||
var html = converter.render(data)
|
||||
transData = HtmlToJson.html2json(html, bindName);
|
||||
//console.log(JSON.stringify(transData, ' ', ' '));
|
||||
}
|
||||
transData.view = {};
|
||||
transData.view.imagePadding = 0;
|
||||
if(typeof(imagePadding) != 'undefined'){
|
||||
transData.view.imagePadding = imagePadding
|
||||
}
|
||||
var bindData = {};
|
||||
bindData[bindName] = transData;
|
||||
|
||||
transPre(transData)
|
||||
|
||||
that.setData(bindData)
|
||||
that.wxParseImgLoad = wxParseImgLoad;
|
||||
that.wxParseImgTap = wxParseImgTap;
|
||||
}
|
||||
|
||||
function transPre(transData){
|
||||
transData.nodes.forEach((node,index)=>{
|
||||
if(node.tag == 'pre'){
|
||||
var lan = 'markup'
|
||||
if(node.nodes[0].classStr){
|
||||
lan =node.nodes[0].classStr.split(' ')[0].replace('language-', '')
|
||||
}
|
||||
var tks = prism.tokens( node.nodes[0].nodes[0].text, prism.languages[lan], lan)
|
||||
transData.nodes[index].tks = tks
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 图片点击事件
|
||||
function wxParseImgTap(e) {
|
||||
var that = this;
|
||||
var nowImgUrl = e.target.dataset.src;
|
||||
var tagFrom = e.target.dataset.from;
|
||||
if (typeof (tagFrom) != 'undefined' && tagFrom.length > 0) {
|
||||
wx.previewImage({
|
||||
current: nowImgUrl, // 当前显示图片的http链接
|
||||
urls: that.data[tagFrom].imageUrls // 需要预览的图片http链接列表
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 图片视觉宽高计算函数区
|
||||
**/
|
||||
function wxParseImgLoad(e) {
|
||||
var that = this;
|
||||
var tagFrom = e.target.dataset.from;
|
||||
var idx = e.target.dataset.idx;
|
||||
if (typeof (tagFrom) != 'undefined' && tagFrom.length > 0) {
|
||||
calMoreImageInfo(e, idx, that, tagFrom)
|
||||
}
|
||||
}
|
||||
// 假循环获取计算图片视觉最佳宽高
|
||||
function calMoreImageInfo(e, idx, that, bindName) {
|
||||
var temData = that.data[bindName];
|
||||
if (!temData || temData.images.length == 0) {
|
||||
return;
|
||||
}
|
||||
var temImages = temData.images;
|
||||
//因为无法获取view宽度 需要自定义padding进行计算,稍后处理
|
||||
var recal = wxAutoImageCal(e.detail.width, e.detail.height,that,bindName);
|
||||
// temImages[idx].width = recal.imageWidth;
|
||||
// temImages[idx].height = recal.imageheight;
|
||||
// temData.images = temImages;
|
||||
// var bindData = {};
|
||||
// bindData[bindName] = temData;
|
||||
// that.setData(bindData);
|
||||
var index = temImages[idx].index
|
||||
var key = `${bindName}`
|
||||
for (var i of index.split('.')) key+=`.nodes[${i}]`
|
||||
var keyW = key + '.width'
|
||||
var keyH = key + '.height'
|
||||
that.setData({
|
||||
[keyW]: recal.imageWidth,
|
||||
[keyH]: recal.imageheight,
|
||||
})
|
||||
}
|
||||
|
||||
// 计算视觉优先的图片宽高
|
||||
function wxAutoImageCal(originalWidth, originalHeight,that,bindName) {
|
||||
//获取图片的原始长宽
|
||||
var windowWidth = 0, windowHeight = 0;
|
||||
var autoWidth = 0, autoHeight = 0;
|
||||
var results = {};
|
||||
var padding = that.data[bindName].view.imagePadding;
|
||||
windowWidth = realWindowWidth-2*padding;
|
||||
windowHeight = realWindowHeight;
|
||||
//判断按照那种方式进行缩放
|
||||
// console.log("windowWidth" + windowWidth);
|
||||
if (originalWidth > windowWidth) {//在图片width大于手机屏幕width时候
|
||||
autoWidth = windowWidth;
|
||||
// console.log("autoWidth" + autoWidth);
|
||||
autoHeight = (autoWidth * originalHeight) / originalWidth;
|
||||
// console.log("autoHeight" + autoHeight);
|
||||
results.imageWidth = autoWidth;
|
||||
results.imageheight = autoHeight;
|
||||
} else {//否则展示原来的数据
|
||||
results.imageWidth = originalWidth;
|
||||
results.imageheight = originalHeight;
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
function wxParseTemArray(temArrayName,bindNameReg,total,that){
|
||||
var array = [];
|
||||
var temData = that.data;
|
||||
var obj = null;
|
||||
for(var i = 0; i < total; i++){
|
||||
var simArr = temData[bindNameReg+i].nodes;
|
||||
array.push(simArr);
|
||||
}
|
||||
|
||||
temArrayName = temArrayName || 'wxParseTemArray';
|
||||
obj = JSON.parse('{"'+ temArrayName +'":""}');
|
||||
obj[temArrayName] = array;
|
||||
that.setData(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置emojis
|
||||
*
|
||||
*/
|
||||
|
||||
function emojisInit(reg='',baseSrc="/wxParse/emojis/",emojis){
|
||||
HtmlToJson.emojisInit(reg,baseSrc,emojis);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
wxParse: wxParse,
|
||||
wxParseTemArray:wxParseTemArray,
|
||||
emojisInit:emojisInit
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,992 @@
|
|||
<!--**
|
||||
* author: Di (微信小程序开发工程师)
|
||||
* organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
|
||||
* 垂直微信小程序开发交流社区
|
||||
*
|
||||
* github地址: https://github.com/icindy/wxParse
|
||||
*
|
||||
* for: 微信小程序富文本解析
|
||||
* detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
|
||||
*/-->
|
||||
|
||||
<!--基础元素-->
|
||||
<template name="wxParseVideo">
|
||||
<!--增加video标签支持,并循环添加-->
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<video class="{{item.classStr}} wxParse-{{item.tag}}-video" src="{{item.attr.src}}"></video>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<template name="wxParseImg">
|
||||
<image class="{{item.classStr}} wxParse-{{item.tag}}" data-from="{{item.from}}" data-src="{{item.attr.src}}" data-idx="{{item.imgIndex}}" src="{{item.attr.src}}" mode="aspectFit" bindload="wxParseImgLoad" bindtap="wxParseImgTap" mode="widthFix" style="width:{{item.width}}px;"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<!-- 千万 不要格式化下面的 wxml,不然 text 嵌套 text 导致换行全部出来了 -->
|
||||
<template name="wxParseCode">
|
||||
<view class="pre language-jsx">
|
||||
<view class="code">
|
||||
<block wx:for="{{item.tks}}" wx:for-item="tk">
|
||||
<block wx:if="{{tk.deep}}"><text class="{{'token ' + tk.type}}"><block wx:for="{{tk.content}}" wx:for-item="stk"><block wx:if="{{stk.deep}}"><text class="{{'token ' + sstk.type}}" wx:for="{{stk.content}}" wx:for-item="sstk">{{sstk.content || sstk}}</text>
|
||||
</block>
|
||||
<block wx:else><text class="{{'token ' + stk.type}}">{{stk.content || stk}}</text>
|
||||
</block>
|
||||
</block>
|
||||
</text>
|
||||
</block>
|
||||
<block wx:else><text class="{{'token ' + tk.type}}">{{tk.content || tk}}</text>
|
||||
</block>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
<template name="WxEmojiView">
|
||||
<text class="WxEmojiView wxParse-inline" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.textArray}}" wx:key="">
|
||||
<block class="{{item.text == '\\n' ? 'wxParse-hide':''}}" wx:if="{{item.node == 'text'}}">{{item.text}}</block>
|
||||
<block wx:elif="{{item.node == 'element'}}">
|
||||
<image class="wxEmoji" src="{{item.baseSrc}}{{item.text}}" />
|
||||
</block>
|
||||
</block>
|
||||
</text>
|
||||
</template>
|
||||
|
||||
<template name="WxParseBr">
|
||||
<text>\n</text>
|
||||
</template>
|
||||
<!--入口模版-->
|
||||
|
||||
<template name="wxParse">
|
||||
<block wx:for="{{wxParseData}}" wx:key="">
|
||||
<template is="wxParse0" data="{{item}}" />
|
||||
</block>
|
||||
</template>
|
||||
|
||||
|
||||
<!--循环模版-->
|
||||
<template name="wxParse0">
|
||||
<!--<template is="wxParse1" data="{{item}}" />-->
|
||||
<!--判断是否是标签节点-->
|
||||
<block wx:if="{{item.node == 'element'}}">
|
||||
<block wx:if="{{item.tag == 'button'}}">
|
||||
<button type="default" size="mini">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse1" data="{{item}}" />
|
||||
</block>
|
||||
</button>
|
||||
</block>
|
||||
<!--li类型-->
|
||||
<block wx:elif="{{item.tag == 'li'}}">
|
||||
<view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}">
|
||||
<view class="{{item.classStr}} wxParse-li-inner">
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<view class="{{item.classStr}} wxParse-li-circle"></view>
|
||||
</view>
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse1" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--video类型-->
|
||||
<block wx:elif="{{item.tag == 'video'}}">
|
||||
<template is="wxParseVideo" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--img类型-->
|
||||
<block wx:elif="{{item.tag == 'img'}}">
|
||||
<template is="wxParseImg" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--a类型-->
|
||||
<block wx:elif="{{item.tag == 'a'}}">
|
||||
<view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse1" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
<block wx:elif="{{item.tag == 'table'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse1" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{item.tag == 'br'}}">
|
||||
<template is="WxParseBr"></template>
|
||||
</block>
|
||||
<!--其他块级标签-->
|
||||
<block wx:elif="{{item.tagType == 'block'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:if="{{item.tag == 'pre'}}">
|
||||
<template is="wxParseCode" data="{{item}}" />
|
||||
</block>
|
||||
<block wx:elif="{{item.tag != 'pre'}}" >
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse1" data="{{item}}" />
|
||||
</block>
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--内联标签-->
|
||||
<view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse1" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
|
||||
<!--判断是否是文本节点-->
|
||||
<block wx:elif="{{item.node == 'text'}}">
|
||||
<!--如果是,直接进行-->
|
||||
<template is="WxEmojiView" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
|
||||
<!--循环模版-->
|
||||
<template name="wxParse1">
|
||||
<!--<template is="wxParse2" data="{{item}}" />-->
|
||||
<!--判断是否是标签节点-->
|
||||
<block wx:if="{{item.node == 'element'}}">
|
||||
<block wx:if="{{item.tag == 'button'}}">
|
||||
<button type="default" size="mini">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse2" data="{{item}}" />
|
||||
</block>
|
||||
</button>
|
||||
</block>
|
||||
<!--li类型-->
|
||||
<block wx:elif="{{item.tag == 'li'}}">
|
||||
<view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}">
|
||||
<view class="{{item.classStr}} wxParse-li-inner">
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<view class="{{item.classStr}} wxParse-li-circle"></view>
|
||||
</view>
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse2" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--video类型-->
|
||||
<block wx:elif="{{item.tag == 'video'}}">
|
||||
<template is="wxParseVideo" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--img类型-->
|
||||
<block wx:elif="{{item.tag == 'img'}}">
|
||||
<template is="wxParseImg" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--a类型-->
|
||||
<block wx:elif="{{item.tag == 'a'}}">
|
||||
<view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse2" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{item.tag == 'br'}}">
|
||||
<template is="WxParseBr"></template>
|
||||
</block>
|
||||
<!--其他块级标签-->
|
||||
<block wx:elif="{{item.tagType == 'block'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse2" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--内联标签-->
|
||||
<view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse2" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
|
||||
<!--判断是否是文本节点-->
|
||||
<block wx:elif="{{item.node == 'text'}}">
|
||||
<!--如果是,直接进行-->
|
||||
<template is="WxEmojiView" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
</template>
|
||||
|
||||
|
||||
<!--循环模版-->
|
||||
<template name="wxParse2">
|
||||
<!--<template is="wxParse3" data="{{item}}" />-->
|
||||
<!--判断是否是标签节点-->
|
||||
<block wx:if="{{item.node == 'element'}}">
|
||||
<block wx:if="{{item.tag == 'button'}}">
|
||||
<button type="default" size="mini">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse3" data="{{item}}" />
|
||||
</block>
|
||||
</button>
|
||||
</block>
|
||||
<!--li类型-->
|
||||
<block wx:elif="{{item.tag == 'li'}}">
|
||||
<view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}">
|
||||
<view class="{{item.classStr}} wxParse-li-inner">
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<view class="{{item.classStr}} wxParse-li-circle"></view>
|
||||
</view>
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse3" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--video类型-->
|
||||
<block wx:elif="{{item.tag == 'video'}}">
|
||||
<template is="wxParseVideo" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--img类型-->
|
||||
<block wx:elif="{{item.tag == 'img'}}">
|
||||
<template is="wxParseImg" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--a类型-->
|
||||
<block wx:elif="{{item.tag == 'a'}}">
|
||||
<view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse3" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{item.tag == 'br'}}">
|
||||
<template is="WxParseBr"></template>
|
||||
</block>
|
||||
<!--其他块级标签-->
|
||||
<block wx:elif="{{item.tagType == 'block'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse3" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--内联标签-->
|
||||
<view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse3" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
|
||||
<!--判断是否是文本节点-->
|
||||
<block wx:elif="{{item.node == 'text'}}">
|
||||
<!--如果是,直接进行-->
|
||||
<template is="WxEmojiView" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
</template>
|
||||
|
||||
<!--循环模版-->
|
||||
<template name="wxParse3">
|
||||
<!--<template is="wxParse4" data="{{item}}" />-->
|
||||
<!--判断是否是标签节点-->
|
||||
<block wx:if="{{item.node == 'element'}}">
|
||||
<block wx:if="{{item.tag == 'button'}}">
|
||||
<button type="default" size="mini">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse4" data="{{item}}" />
|
||||
</block>
|
||||
</button>
|
||||
</block>
|
||||
<!--li类型-->
|
||||
<block wx:elif="{{item.tag == 'li'}}">
|
||||
<view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}">
|
||||
<view class="{{item.classStr}} wxParse-li-inner">
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<view class="{{item.classStr}} wxParse-li-circle"></view>
|
||||
</view>
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse4" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--video类型-->
|
||||
<block wx:elif="{{item.tag == 'video'}}">
|
||||
<template is="wxParseVideo" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--img类型-->
|
||||
<block wx:elif="{{item.tag == 'img'}}">
|
||||
<template is="wxParseImg" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--a类型-->
|
||||
<block wx:elif="{{item.tag == 'a'}}">
|
||||
<view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse4" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{item.tag == 'br'}}">
|
||||
<template is="WxParseBr"></template>
|
||||
</block>
|
||||
<!--其他块级标签-->
|
||||
<block wx:elif="{{item.tagType == 'block'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse4" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--内联标签-->
|
||||
<view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse4" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
|
||||
<!--判断是否是文本节点-->
|
||||
<block wx:elif="{{item.node == 'text'}}">
|
||||
<!--如果是,直接进行-->
|
||||
<template is="WxEmojiView" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
</template>
|
||||
|
||||
<!--循环模版-->
|
||||
<template name="wxParse4">
|
||||
<!--<template is="wxParse5" data="{{item}}" />-->
|
||||
<!--判断是否是标签节点-->
|
||||
<block wx:if="{{item.node == 'element'}}">
|
||||
<block wx:if="{{item.tag == 'button'}}">
|
||||
<button type="default" size="mini">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse5" data="{{item}}" />
|
||||
</block>
|
||||
</button>
|
||||
</block>
|
||||
<!--li类型-->
|
||||
<block wx:elif="{{item.tag == 'li'}}">
|
||||
<view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}">
|
||||
<view class="{{item.classStr}} wxParse-li-inner">
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<view class="{{item.classStr}} wxParse-li-circle"></view>
|
||||
</view>
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse5" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--video类型-->
|
||||
<block wx:elif="{{item.tag == 'video'}}">
|
||||
<template is="wxParseVideo" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--img类型-->
|
||||
<block wx:elif="{{item.tag == 'img'}}">
|
||||
<template is="wxParseImg" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--a类型-->
|
||||
<block wx:elif="{{item.tag == 'a'}}">
|
||||
<view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse5" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{item.tag == 'br'}}">
|
||||
<template is="WxParseBr"></template>
|
||||
</block>
|
||||
<!--其他块级标签-->
|
||||
<block wx:elif="{{item.tagType == 'block'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse5" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--内联标签-->
|
||||
<view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse5" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
|
||||
<!--判断是否是文本节点-->
|
||||
<block wx:elif="{{item.node == 'text'}}">
|
||||
<!--如果是,直接进行-->
|
||||
<template is="WxEmojiView" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
</template>
|
||||
|
||||
<!--循环模版-->
|
||||
<template name="wxParse5">
|
||||
<!--<template is="wxParse6" data="{{item}}" />-->
|
||||
<!--判断是否是标签节点-->
|
||||
<block wx:if="{{item.node == 'element'}}">
|
||||
<block wx:if="{{item.tag == 'button'}}">
|
||||
<button type="default" size="mini">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse6" data="{{item}}" />
|
||||
</block>
|
||||
</button>
|
||||
</block>
|
||||
<!--li类型-->
|
||||
<block wx:elif="{{item.tag == 'li'}}">
|
||||
<view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}">
|
||||
<view class="{{item.classStr}} wxParse-li-inner">
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<view class="{{item.classStr}} wxParse-li-circle"></view>
|
||||
</view>
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse6" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--video类型-->
|
||||
<block wx:elif="{{item.tag == 'video'}}">
|
||||
<template is="wxParseVideo" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--img类型-->
|
||||
<block wx:elif="{{item.tag == 'img'}}">
|
||||
<template is="wxParseImg" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--a类型-->
|
||||
<block wx:elif="{{item.tag == 'a'}}">
|
||||
<view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse6" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{item.tag == 'br'}}">
|
||||
<template is="WxParseBr"></template>
|
||||
</block>
|
||||
<!--其他块级标签-->
|
||||
<block wx:elif="{{item.tagType == 'block'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse6" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--内联标签-->
|
||||
<view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse6" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
|
||||
<!--判断是否是文本节点-->
|
||||
<block wx:elif="{{item.node == 'text'}}">
|
||||
<!--如果是,直接进行-->
|
||||
<template is="WxEmojiView" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
</template>
|
||||
|
||||
<!--循环模版-->
|
||||
<template name="wxParse6">
|
||||
<!--<template is="wxParse7" data="{{item}}" />-->
|
||||
<!--判断是否是标签节点-->
|
||||
<block wx:if="{{item.node == 'element'}}">
|
||||
<block wx:if="{{item.tag == 'button'}}">
|
||||
<button type="default" size="mini">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse7" data="{{item}}" />
|
||||
</block>
|
||||
</button>
|
||||
</block>
|
||||
<!--li类型-->
|
||||
<block wx:elif="{{item.tag == 'li'}}">
|
||||
<view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}">
|
||||
<view class="{{item.classStr}} wxParse-li-inner">
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<view class="{{item.classStr}} wxParse-li-circle"></view>
|
||||
</view>
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse7" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--video类型-->
|
||||
<block wx:elif="{{item.tag == 'video'}}">
|
||||
<template is="wxParseVideo" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--img类型-->
|
||||
<block wx:elif="{{item.tag == 'img'}}">
|
||||
<template is="wxParseImg" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--a类型-->
|
||||
<block wx:elif="{{item.tag == 'a'}}">
|
||||
<view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse7" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{item.tag == 'br'}}">
|
||||
<template is="WxParseBr"></template>
|
||||
</block>
|
||||
<!--其他块级标签-->
|
||||
<block wx:elif="{{item.tagType == 'block'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse7" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--内联标签-->
|
||||
<view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse7" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
|
||||
<!--判断是否是文本节点-->
|
||||
<block wx:elif="{{item.node == 'text'}}">
|
||||
<!--如果是,直接进行-->
|
||||
<template is="WxEmojiView" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
</template>
|
||||
<!--循环模版-->
|
||||
<template name="wxParse7">
|
||||
<!--<template is="wxParse8" data="{{item}}" />-->
|
||||
<!--判断是否是标签节点-->
|
||||
<block wx:if="{{item.node == 'element'}}">
|
||||
<block wx:if="{{item.tag == 'button'}}">
|
||||
<button type="default" size="mini">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse8" data="{{item}}" />
|
||||
</block>
|
||||
</button>
|
||||
</block>
|
||||
<!--li类型-->
|
||||
<block wx:elif="{{item.tag == 'li'}}">
|
||||
<view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}">
|
||||
<view class="{{item.classStr}} wxParse-li-inner">
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<view class="{{item.classStr}} wxParse-li-circle"></view>
|
||||
</view>
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse8" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--video类型-->
|
||||
<block wx:elif="{{item.tag == 'video'}}">
|
||||
<template is="wxParseVideo" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--img类型-->
|
||||
<block wx:elif="{{item.tag == 'img'}}">
|
||||
<template is="wxParseImg" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--a类型-->
|
||||
<block wx:elif="{{item.tag == 'a'}}">
|
||||
<view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse8" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{item.tag == 'br'}}">
|
||||
<template is="WxParseBr"></template>
|
||||
</block>
|
||||
<!--其他块级标签-->
|
||||
<block wx:elif="{{item.tagType == 'block'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse8" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--内联标签-->
|
||||
<view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse8" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
|
||||
<!--判断是否是文本节点-->
|
||||
<block wx:elif="{{item.node == 'text'}}">
|
||||
<!--如果是,直接进行-->
|
||||
<template is="WxEmojiView" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
</template>
|
||||
|
||||
<!--循环模版-->
|
||||
<template name="wxParse8">
|
||||
<!--<template is="wxParse9" data="{{item}}" />-->
|
||||
<!--判断是否是标签节点-->
|
||||
<block wx:if="{{item.node == 'element'}}">
|
||||
<block wx:if="{{item.tag == 'button'}}">
|
||||
<button type="default" size="mini">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse9" data="{{item}}" />
|
||||
</block>
|
||||
</button>
|
||||
</block>
|
||||
<!--li类型-->
|
||||
<block wx:elif="{{item.tag == 'li'}}">
|
||||
<view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}">
|
||||
<view class="{{item.classStr}} wxParse-li-inner">
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<view class="{{item.classStr}} wxParse-li-circle"></view>
|
||||
</view>
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse9" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--video类型-->
|
||||
<block wx:elif="{{item.tag == 'video'}}">
|
||||
<template is="wxParseVideo" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--img类型-->
|
||||
<block wx:elif="{{item.tag == 'img'}}">
|
||||
<template is="wxParseImg" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--a类型-->
|
||||
<block wx:elif="{{item.tag == 'a'}}">
|
||||
<view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse9" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{item.tag == 'br'}}">
|
||||
<template is="WxParseBr"></template>
|
||||
</block>
|
||||
<!--其他块级标签-->
|
||||
<block wx:elif="{{item.tagType == 'block'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse9" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--内联标签-->
|
||||
<view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse9" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
|
||||
<!--判断是否是文本节点-->
|
||||
<block wx:elif="{{item.node == 'text'}}">
|
||||
<!--如果是,直接进行-->
|
||||
<template is="WxEmojiView" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
</template>
|
||||
|
||||
<!--循环模版-->
|
||||
<template name="wxParse9">
|
||||
<!--<template is="wxParse10" data="{{item}}" />-->
|
||||
<!--判断是否是标签节点-->
|
||||
<block wx:if="{{item.node == 'element'}}">
|
||||
<block wx:if="{{item.tag == 'button'}}">
|
||||
<button type="default" size="mini">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse10" data="{{item}}" />
|
||||
</block>
|
||||
</button>
|
||||
</block>
|
||||
<!--li类型-->
|
||||
<block wx:elif="{{item.tag == 'li'}}">
|
||||
<view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}">
|
||||
<view class="{{item.classStr}} wxParse-li-inner">
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<view class="{{item.classStr}} wxParse-li-circle"></view>
|
||||
</view>
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse10" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--video类型-->
|
||||
<block wx:elif="{{item.tag == 'video'}}">
|
||||
<template is="wxParseVideo" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--img类型-->
|
||||
<block wx:elif="{{item.tag == 'img'}}">
|
||||
<template is="wxParseImg" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--a类型-->
|
||||
<block wx:elif="{{item.tag == 'a'}}">
|
||||
<view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse10" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{item.tag == 'br'}}">
|
||||
<template is="WxParseBr"></template>
|
||||
</block>
|
||||
<!--其他块级标签-->
|
||||
<block wx:elif="{{item.tagType == 'block'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse10" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--内联标签-->
|
||||
<view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse10" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
|
||||
<!--判断是否是文本节点-->
|
||||
<block wx:elif="{{item.node == 'text'}}">
|
||||
<!--如果是,直接进行-->
|
||||
<template is="WxEmojiView" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
</template>
|
||||
|
||||
<!--循环模版-->
|
||||
<template name="wxParse10">
|
||||
<!--<template is="wxParse11" data="{{item}}" />-->
|
||||
<!--判断是否是标签节点-->
|
||||
<block wx:if="{{item.node == 'element'}}">
|
||||
<block wx:if="{{item.tag == 'button'}}">
|
||||
<button type="default" size="mini">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse11" data="{{item}}" />
|
||||
</block>
|
||||
</button>
|
||||
</block>
|
||||
<!--li类型-->
|
||||
<block wx:elif="{{item.tag == 'li'}}">
|
||||
<view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}">
|
||||
<view class="{{item.classStr}} wxParse-li-inner">
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<view class="{{item.classStr}} wxParse-li-circle"></view>
|
||||
</view>
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse11" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--video类型-->
|
||||
<block wx:elif="{{item.tag == 'video'}}">
|
||||
<template is="wxParseVideo" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--img类型-->
|
||||
<block wx:elif="{{item.tag == 'img'}}">
|
||||
<template is="wxParseImg" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--a类型-->
|
||||
<block wx:elif="{{item.tag == 'a'}}">
|
||||
<view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse11" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{item.tag == 'br'}}">
|
||||
<template is="WxParseBr"></template>
|
||||
</block>
|
||||
<!--其他块级标签-->
|
||||
<block wx:elif="{{item.tagType == 'block'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse11" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--内联标签-->
|
||||
<view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse11" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
|
||||
<!--判断是否是文本节点-->
|
||||
<block wx:elif="{{item.node == 'text'}}">
|
||||
<!--如果是,直接进行-->
|
||||
<template is="WxEmojiView" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
</template>
|
||||
|
||||
<!--循环模版-->
|
||||
<template name="wxParse11">
|
||||
<!--<template is="wxParse12" data="{{item}}" />-->
|
||||
<!--判断是否是标签节点-->
|
||||
<block wx:if="{{item.node == 'element'}}">
|
||||
<block wx:if="{{item.tag == 'button'}}">
|
||||
<button type="default" size="mini">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse12" data="{{item}}" />
|
||||
</block>
|
||||
</button>
|
||||
</block>
|
||||
<!--li类型-->
|
||||
<block wx:elif="{{item.tag == 'li'}}">
|
||||
<view class="{{item.classStr}} wxParse-li" style="{{item.styleStr}}">
|
||||
<view class="{{item.classStr}} wxParse-li-inner">
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<view class="{{item.classStr}} wxParse-li-circle"></view>
|
||||
</view>
|
||||
<view class="{{item.classStr}} wxParse-li-text">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse12" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--video类型-->
|
||||
<block wx:elif="{{item.tag == 'video'}}">
|
||||
<template is="wxParseVideo" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--img类型-->
|
||||
<block wx:elif="{{item.tag == 'img'}}">
|
||||
<template is="wxParseImg" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
<!--a类型-->
|
||||
<block wx:elif="{{item.tag == 'a'}}">
|
||||
<view bindtap="wxParseTagATap" class="wxParse-inline {{item.classStr}} wxParse-{{item.tag}}" data-src="{{item.attr.href}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse12" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<block wx:elif="{{item.tag == 'br'}}">
|
||||
<template is="WxParseBr"></template>
|
||||
</block>
|
||||
<!--其他块级标签-->
|
||||
<block wx:elif="{{item.tagType == 'block'}}">
|
||||
<view class="{{item.classStr}} wxParse-{{item.tag}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse12" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<!--内联标签-->
|
||||
<view wx:else class="{{item.classStr}} wxParse-{{item.tag}} wxParse-{{item.tagType}}" style="{{item.styleStr}}">
|
||||
<block wx:for="{{item.nodes}}" wx:for-item="item" wx:key="">
|
||||
<template is="wxParse12" data="{{item}}" />
|
||||
</block>
|
||||
</view>
|
||||
|
||||
</block>
|
||||
|
||||
<!--判断是否是文本节点-->
|
||||
<block wx:elif="{{item.node == 'text'}}">
|
||||
<!--如果是,直接进行-->
|
||||
<template is="WxEmojiView" data="{{item}}" />
|
||||
</block>
|
||||
|
||||
</template>
|
|
@ -0,0 +1,206 @@
|
|||
|
||||
/**
|
||||
* author: Di (微信小程序开发工程师)
|
||||
* organization: WeAppDev(微信小程序开发论坛)(http://weappdev.com)
|
||||
* 垂直微信小程序开发交流社区
|
||||
*
|
||||
* github地址: https://github.com/icindy/wxParse
|
||||
*
|
||||
* for: 微信小程序富文本解析
|
||||
* detail : http://weappdev.com/t/wxparse-alpha0-1-html-markdown/184
|
||||
*/
|
||||
|
||||
.wxParse{
|
||||
margin: 0 5px;
|
||||
font-family: Helvetica,sans-serif;
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
line-height: 1.8;
|
||||
}
|
||||
view{
|
||||
word-break:break-all; overflow:auto;
|
||||
}
|
||||
.wxParse-inline{
|
||||
display: inline;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
/*//标题 */
|
||||
.wxParse-div{margin: 0;padding: 0;}
|
||||
.wxParse-h1{ font-size:2em; margin: .67em 0 }
|
||||
.wxParse-h2{ font-size:1.5em; margin: .75em 0 }
|
||||
.wxParse-h3{ font-size:1.17em; margin: .83em 0 }
|
||||
.wxParse-h4{ margin: 1.12em 0}
|
||||
.wxParse-h5 { font-size:.83em; margin: 1.5em 0 }
|
||||
.wxParse-h6{ font-size:.75em; margin: 1.67em 0 }
|
||||
|
||||
.wxParse-h1 {
|
||||
font-size: 18px;
|
||||
font-weight: 400;
|
||||
margin-bottom: .9em;
|
||||
}
|
||||
.wxParse-h2 {
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
margin-bottom: .34em;
|
||||
}
|
||||
.wxParse-h3 {
|
||||
font-weight: 400;
|
||||
font-size: 15px;
|
||||
margin-bottom: .34em;
|
||||
}
|
||||
.wxParse-h4 {
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
margin-bottom: .24em;
|
||||
}
|
||||
.wxParse-h5 {
|
||||
font-weight: 400;
|
||||
font-size: 13px;
|
||||
margin-bottom: .14em;
|
||||
}
|
||||
.wxParse-h6 {
|
||||
font-weight: 400;
|
||||
font-size: 12px;
|
||||
margin-bottom: .04em;
|
||||
}
|
||||
|
||||
.wxParse-h1, .wxParse-h2, .wxParse-h3, .wxParse-h4, .wxParse-h5, .wxParse-h6, .wxParse-b, .wxParse-strong { font-weight: bolder }
|
||||
|
||||
.wxParse-i,.wxParse-cite,.wxParse-em,.wxParse-var,.wxParse-address{font-style:italic}
|
||||
.wxParse-pre,.wxParse-tt,.wxParse-code,.wxParse-kbd,.wxParse-samp{font-family:monospace}
|
||||
.wxParse-pre{white-space:pre}
|
||||
.wxParse-big{font-size:1.17em}
|
||||
.wxParse-small,.wxParse-sub,.wxParse-sup{font-size:.83em}
|
||||
.wxParse-sub{vertical-align:sub}
|
||||
.wxParse-sup{vertical-align:super}
|
||||
.wxParse-s,.wxParse-strike,.wxParse-del{text-decoration:line-through}
|
||||
/*wxparse-自定义个性化的css样式*/
|
||||
/*增加video的css样式*/
|
||||
.wxParse-strong,.wxParse-s{display: inline}
|
||||
.wxParse-a{
|
||||
color: deepskyblue;
|
||||
word-break:break-all;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
.wxParse-video{
|
||||
text-align: center;
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.wxParse-video-video{
|
||||
width:100%;
|
||||
}
|
||||
|
||||
.wxParse-img{
|
||||
/*background-color: #efefef;*/
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.wxParse-blockquote {
|
||||
margin: 0;
|
||||
padding:10px 0 10px 5px;
|
||||
font-family:Courier, Calibri,"宋体";
|
||||
background:#f5f5f5;
|
||||
border-left: 3px solid #dbdbdb;
|
||||
}
|
||||
|
||||
.wxParse-code,.wxParse-wxxxcode-style{
|
||||
display: inline;
|
||||
background:#f5f5f5;
|
||||
}
|
||||
.wxParse-ul{
|
||||
margin: 20rpx 10rpx;
|
||||
}
|
||||
|
||||
.wxParse-li,.wxParse-li-inner{
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
margin: 10rpx 0;
|
||||
}
|
||||
.wxParse-li-text{
|
||||
|
||||
align-items: center;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.wxParse-li-circle{
|
||||
display: inline-flex;
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
background-color: #333;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.wxParse-li-square{
|
||||
display: inline-flex;
|
||||
width: 10rpx;
|
||||
height: 10rpx;
|
||||
background-color: #333;
|
||||
margin-right: 5px;
|
||||
}
|
||||
.wxParse-li-ring{
|
||||
display: inline-flex;
|
||||
width: 10rpx;
|
||||
height: 10rpx;
|
||||
border: 2rpx solid #333;
|
||||
border-radius: 50%;
|
||||
background-color: #fff;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
/*.wxParse-table{
|
||||
width: 100%;
|
||||
height: 400px;
|
||||
}
|
||||
.wxParse-thead,.wxParse-tfoot,.wxParse-tr{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.wxParse-th,.wxParse-td{
|
||||
display: flex;
|
||||
width: 580px;
|
||||
overflow: auto;
|
||||
}*/
|
||||
|
||||
.wxParse-u {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.wxParse-hide{
|
||||
display: none;
|
||||
}
|
||||
.WxEmojiView{
|
||||
align-items: center;
|
||||
}
|
||||
.wxEmoji{
|
||||
width: 16px;
|
||||
height:16px;
|
||||
}
|
||||
.wxParse-tr{
|
||||
display: flex;
|
||||
border-right:1px solid #e0e0e0;
|
||||
border-bottom:1px solid #e0e0e0;
|
||||
border-top:1px solid #e0e0e0;
|
||||
}
|
||||
.wxParse-th,
|
||||
.wxParse-td{
|
||||
flex:1;
|
||||
padding:5px;
|
||||
font-size:28rpx;
|
||||
border-left:1px solid #e0e0e0;
|
||||
word-break: break-all;
|
||||
}
|
||||
.wxParse-td:last{
|
||||
border-top:1px solid #e0e0e0;
|
||||
}
|
||||
.wxParse-th{
|
||||
background:#f0f0f0;
|
||||
border-top:1px solid #e0e0e0;
|
||||
}
|
||||
.wxParse-del{
|
||||
display: inline;
|
||||
}
|
||||
.wxParse-figure {
|
||||
overflow: hidden;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
var comi = require('../../comi/comi.js');
|
||||
|
||||
|
||||
Page({
|
||||
data: {
|
||||
motto: 'Hello World',
|
||||
userInfo: {},
|
||||
hasUserInfo: false,
|
||||
canIUse: wx.canIUse('button.open-type.getUserInfo')
|
||||
},
|
||||
//事件处理函数
|
||||
bindViewTap: function () {
|
||||
wx.navigateTo({
|
||||
url: '../logs/logs'
|
||||
})
|
||||
},
|
||||
onLoad: function () {
|
||||
var md =
|
||||
`
|
||||
## jsx
|
||||
\`\`\`jsx
|
||||
define('todo-list', function(props) {
|
||||
return (
|
||||
<ul>
|
||||
{props.items.map(item => (
|
||||
<li key={item.id}>{item.text}</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
})
|
||||
\`\`\`
|
||||
`;
|
||||
|
||||
comi(md, this)
|
||||
}
|
||||
})
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"usingComponents": {}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
<include src="../../comi/comi.wxml" />
|
|
@ -0,0 +1,23 @@
|
|||
@import "../../comi/comi.wxss";
|
||||
|
||||
/**index.wxss**/
|
||||
.userinfo {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.userinfo-avatar {
|
||||
width: 128rpx;
|
||||
height: 128rpx;
|
||||
margin: 20rpx;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.userinfo-nickname {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.usermotto {
|
||||
margin-top: 200px;
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
//logs.js
|
||||
const util = require('../../utils/util.js')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
logs: []
|
||||
},
|
||||
onLoad: function () {
|
||||
this.setData({
|
||||
logs: (wx.getStorageSync('logs') || []).map(log => {
|
||||
return util.formatTime(new Date(log))
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"navigationBarTitleText": "查看启动日志",
|
||||
"usingComponents": {}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<!--logs.wxml-->
|
||||
<view class="container log-list">
|
||||
<block wx:for="{{logs}}" wx:for-item="log">
|
||||
<text class="log-item">{{index + 1}}. {{log}}</text>
|
||||
</block>
|
||||
</view>
|
|
@ -0,0 +1,8 @@
|
|||
.log-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 40rpx;
|
||||
}
|
||||
.log-item {
|
||||
margin: 10rpx;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
{
|
||||
"description": "项目配置文件",
|
||||
"packOptions": {
|
||||
"ignore": []
|
||||
},
|
||||
"setting": {
|
||||
"urlCheck": true,
|
||||
"es6": true,
|
||||
"postcss": true,
|
||||
"minified": true,
|
||||
"newFeature": true,
|
||||
"autoAudits": false
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "2.6.4",
|
||||
"appid": "wxfaf6dad43f57c6bd",
|
||||
"projectname": "comi-mp",
|
||||
"debugOptions": {
|
||||
"hidedInDevtools": []
|
||||
},
|
||||
"isGameTourist": false,
|
||||
"condition": {
|
||||
"search": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"conversation": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
},
|
||||
"game": {
|
||||
"currentL": -1,
|
||||
"list": []
|
||||
},
|
||||
"miniprogram": {
|
||||
"current": -1,
|
||||
"list": []
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
const formatTime = date => {
|
||||
const year = date.getFullYear()
|
||||
const month = date.getMonth() + 1
|
||||
const day = date.getDate()
|
||||
const hour = date.getHours()
|
||||
const minute = date.getMinutes()
|
||||
const second = date.getSeconds()
|
||||
|
||||
return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')
|
||||
}
|
||||
|
||||
const formatNumber = n => {
|
||||
n = n.toString()
|
||||
return n[1] ? n : '0' + n
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatTime: formatTime
|
||||
}
|
Loading…
Reference in New Issue