This commit is contained in:
2026-09-24 16:25:22 +08:00
commit 7428184f01
1198 changed files with 314515 additions and 0 deletions
+45
View File
File diff suppressed because one or more lines are too long
+195
View File
@@ -0,0 +1,195 @@
var iframeId = new URLSearchParams(window.location.search).get('id')||Math.random().toString(16).substring(4)
// 等待初始化完毕
document.addEventListener('UniAppJSBridgeReady', function(){
window.parent.postMessage({
action: 'onJSBridgeReady',
data: '',
iframeId: iframeId
}, '*');
uni.postMessage({
data: {
action: 'onJSBridgeReady'
}
})
})
// window.addEventListener('message', function(event) {
// // 根据消息内容执行相应的操作或调用函数
// if (typeof event.data === 'object' && event.data.action === 'callFunctionInIframe') {
// var data = event.data.data;
// myFunctionInIframe(data);
// }
// });
var qr = null
// 绘制二维码。
//https://github.com/soldair/node-qrcode?tab=readme-ov-file#createtext-options
function createQrcode(size, foreground, background, text, logo, logoSize, padding) {
// let width = window.frameElement.offsetWidth
// let height = window.frameElement.offsetHeight
var canvas = document.getElementById("qrcode")
// canvas.width=width
// canvas.height=height
// canvas.style.width=width+'px'
// canvas.style.height=height+'px'
canvas.style.display = "block"
let ctx = canvas.getContext("2d");
ctx.clearRect(0, 0, canvas.width, canvas.height);
document.body.style.overflow = "hidden"
document.body.style.height = "100%"
size = size || 128;
padding = padding || 2
QRCode.toCanvas(canvas, text || 'xui', {
element: canvas,
width: size,
errorCorrectionLevel: 'H',
margin: padding,
color: {
dark: foreground || "black",
light: background || "white"
}
})
if (logo) {
let ctx = canvas.getContext("2d");
let img = new Image();
logoSize = logoSize || 50
img.width = logoSize + "px"
img.height = logoSize + "px"
img.src = logo
img.onload = function() {
let x = (size - logoSize) / 2
let y = x;
ctx.drawImage(img, x, y, logoSize, logoSize)
}
}
}
//获取二维码图片。
function QrcodeToDateUrl() {
if (qr) {
let imgdata = qr.toDataURL();
uni.postMessage({
data: {
action: 'img',
url: imgdata
}
})
} else {
uni.postMessage({
data: {
action: 'error',
}
})
}
}
var ect = null;
function getchart() {
if (ect) return ect;
let dom = document.getElementById('echart');
return echarts.init(dom);
}
function chart_setSize() {
let width = window.innerWidth
let height = window.innerHeight
let dom = document.getElementById('echart');
let domhtml = document.getElement
dom.style.width = width + 'px'
dom.style.height = height + 'px'
document.getElementsByTagName('html')[0].style = 'overflow:hidden'
}
// 解码 JSON 字符串(包括深层解码)
function decodeJSON(jsonString) {
// 如果输入不是字符串,直接返回
if (typeof jsonString !== 'string') {
return jsonString;
}
const obj = JSON.parse(jsonString,function(k,v){
// 处理常规函数定义,包括多行函数 "key": function(params) { ... }
var isFunctionStr =
// 常规函数
/^\s*function\s*\([^)]*\)\s*\{[\s\S]*\}\s*$/.test(v) ||
// 箭头函数 - 带花括号
/^\s*\([^)]*\)\s*=>\s*\{[\s\S]*\}\s*$/.test(v) ||
// 箭头函数 - 简写形式
/^\s*\([^)]*\)\s*=>\s*[^{\s][\s\S]*$/.test(v) ||
// 单参数箭头函数 - 无括号
/^\s*[a-zA-Z0-9_$]+\s*=>\s*[^{\s][\s\S]*$/.test(v) ||
// 单参数箭头函数 - 带花括号
/^\s*[a-zA-Z0-9_$]+\s*=>\s*\{[\s\S]*\}\s*$/.test(v);
if(typeof v === 'string' && isFunctionStr){
v = eval('('+v+')')
}
return v;
});
return obj;
}
function chart_setOption(optionStr) {
chart_setSize()
// 基于准备好的dom,初始化echarts实例
let chart = getchart();
if (!optionStr) return;
try {
let option = decodeJSON(optionStr)
chart.setOption(option)
} catch (error) {
alert(error)
}
}
function chart_call(funName, optionStr, eventsid) {
chart_setSize()
let filterevents = ["click"]
// 基于准备好的dom,初始化echarts实例
let chart = getchart();
if (filterevents.includes(funName)) {
chart['on'](funName, function(params) {
delete params.event
window.parent.postMessage({
action: funName,
eventId: eventsid,
data: JSON.stringify(params),
iframeId: iframeId
}, '*');
uni.postMessage({
data: {
action: funName,
eventId: eventsid,
data: JSON.stringify(params)
}
})
})
} else {
try {
let option = JSON.parse(optionStr)
chart[funName](option)
} catch (e) {
chart[funName]()
}
}
}
+1004
View File
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+103
View File
@@ -0,0 +1,103 @@
function markedHighlight(options) {
if (typeof options === 'function') {
options = {
highlight: options,
};
}
if (!options || typeof options.highlight !== 'function') {
throw new Error('Must provide highlight function');
}
if (typeof options.langPrefix !== 'string') {
options.langPrefix = 'language-';
}
if (typeof options.emptyLangClass !== 'string') {
options.emptyLangClass = '';
}
return {
async: !!options.async,
walkTokens(token) {
if (token.type !== 'code') {
return;
}
const lang = getLang(token.lang);
if (options.async) {
return Promise.resolve(options.highlight(token.text, lang, token.lang || '')).then(
updateToken(token));
}
const code = options.highlight(token.text, lang, token.lang || '');
if (code instanceof Promise) {
throw new Error(
'markedHighlight is not set to async but the highlight function is async. Set the async option to true on markedHighlight to await the async highlight function.'
);
}
updateToken(token)(code);
},
useNewRenderer: true,
renderer: {
code(code, infoString, escaped) {
// istanbul ignore next
if (typeof code === 'object') {
escaped = code.escaped;
infoString = code.lang;
code = code.text;
}
const lang = getLang(infoString);
const classValue = lang ? options.langPrefix + escape(lang) : options.emptyLangClass;
const classAttr = classValue ?
` class="${classValue}"` :
'';
code = code.replace(/\n$/, '');
return `<pre><code${classAttr}>${escaped ? code : escape(code, true)}\n</code></pre>`;
},
},
};
}
function getLang(lang) {
return (lang || '').match(/\S*/)[0];
}
function updateToken(token) {
return (code) => {
if (typeof code === 'string' && code !== token.text) {
token.escaped = true;
token.text = code;
}
};
}
// copied from marked helpers
const escapeTest = /[&<>"']/;
const escapeReplace = new RegExp(escapeTest.source, 'g');
const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, 'g');
const escapeReplacements = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
};
const getEscapeReplacement = (ch) => escapeReplacements[ch];
function escape(html, encode) {
if (encode) {
if (escapeTest.test(html)) {
return html.replace(escapeReplace, getEscapeReplacement);
}
} else {
if (escapeTestNoEncode.test(html)) {
return html.replace(escapeReplaceNoEncode, getEscapeReplacement);
}
}
return html;
}
+88
View File
@@ -0,0 +1,88 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('katex')) :
typeof define === 'function' && define.amd ? define(['katex'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.markedKatex = factory(global.katex));
})(this, (function (katex) { 'use strict';
const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/;
const inlineRuleNonStandard = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1/; // Non-standard, even if there are no spaces before and after $ or $$, try to parse
const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
function index(options = {}) {
return {
extensions: [
inlineKatex(options, createRenderer(options, false)),
blockKatex(options, createRenderer(options, true)),
],
};
}
function createRenderer(options, newlineAfter) {
return (token) => katex.renderToString(token.text, { ...options, displayMode: token.displayMode }) + (newlineAfter ? '\n' : '');
}
function inlineKatex(options, renderer) {
const nonStandard = options && options.nonStandard;
const ruleReg = nonStandard ? inlineRuleNonStandard : inlineRule;
return {
name: 'inlineKatex',
level: 'inline',
start(src) {
let index;
let indexSrc = src;
while (indexSrc) {
index = indexSrc.indexOf('$');
if (index === -1) {
return;
}
const f = nonStandard ? index > -1 : index === 0 || indexSrc.charAt(index - 1) === ' ';
if (f) {
const possibleKatex = indexSrc.substring(index);
if (possibleKatex.match(ruleReg)) {
return index;
}
}
indexSrc = indexSrc.substring(index + 1).replace(/^\$+/, '');
}
},
tokenizer(src, tokens) {
const match = src.match(ruleReg);
if (match) {
return {
type: 'inlineKatex',
raw: match[0],
text: match[2].trim(),
displayMode: match[1].length === 2,
};
}
},
renderer,
};
}
function blockKatex(options, renderer) {
return {
name: 'blockKatex',
level: 'block',
tokenizer(src, tokens) {
const match = src.match(blockRule);
if (match) {
return {
type: 'blockKatex',
raw: match[0],
text: match[2].trim(),
displayMode: match[1].length === 2,
};
}
},
renderer,
};
}
return index;
}));
+242
View File
@@ -0,0 +1,242 @@
function extendedTables({
interruptPatterns = [],
skipEmptyRows = true
} = {}) {
return {
extensions: [{
name: 'spanTable',
level: 'block', // Is this a block-level or inline-level tokenizer?
start(src) {
return src.match(/\n *([^\n ].*\|.*)\n/m)?.index;
}, // Hint to Marked.js to stop and check for a match
tokenizer(src, tokens) {
// const regex = this.tokenizer.rules.block.table;
let regexString = '^ *([^\\n ].*\\|.*\\n(?: *[^\\s].*\\n)*?)' // Header
+
' {0,3}(?:\\| *)?(:?-+(?: *(?:100|[1-9][0-9]?%) *-+)?:? *(?:\\| *:?-+(?: *(?:100|[1-9][0-9]?%) *-+)?:? *)*)(?:\\| *)?' // Align
+
'(?:\\n((?:(?! *\\n| {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})' // Cells
+
'(?:\\n+|$)| {0,3}#{1,6}(?:\\s|$)| {0,3}>| {4}[^\\n]| {0,3}(?:`{3,}' +
'(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n| {0,3}(?:[*+-]|1[.)]) |' +
'<\\/?(?:address|article|aside|base|basefont|blockquote|body' +
'|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt' +
'|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]' +
'|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem' +
'|meta|nav|noframes|ol|optgroup|option|p|param|section|source' +
'|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)' +
'(?: +|\\n|\\/?>)|<(?:script|pre|style|textarea|!--)endRegex).*(?:\\n|$))*)\\n*|$)'; // Cells
regexString = regexString.replace('endRegex', interruptPatterns.map(str =>
`|(?:${str})`).join(''));
const widthRegex = / *(?:100|[1-9][0-9]?%) */g;
const regex = new RegExp(regexString);
const cap = regex.exec(src);
if (cap) {
const item = {
type: 'spanTable',
header: cap[1].replace(/\n$/, '').split('\n'),
align: cap[2].replace(widthRegex, '').replace(/^ *|\| *$/g, '').split(
/ *\| */),
rows: cap[3]?.trim() ? cap[3].replace(/\n[ \t]*$/, '').split('\n') : [],
width: cap[2].replace(/:/g, '').replace(/-+| /g, '').split('|')
};
// Get first header row to determine how many columns
item.header[0] = splitCells(item.header[0]);
const colCount = item.header[0].reduce((length, header) => {
return length + header.colspan;
}, 0);
if (colCount === item.align.length) {
item.raw = cap[0];
let i, j, k, row;
// Get alignment row (:---:)
let l = item.align.length;
for (i = 0; i < l; i++) {
if (/^ *-+: *$/.test(item.align[i])) {
item.align[i] = 'right';
} else if (/^ *:-+: *$/.test(item.align[i])) {
item.align[i] = 'center';
} else if (/^ *:-+ *$/.test(item.align[i])) {
item.align[i] = 'left';
} else {
item.align[i] = null;
}
}
// Get any remaining header rows
l = item.header.length;
for (i = 1; i < l; i++) {
item.header[i] = splitCells(item.header[i], colCount, item.header[i -
1], skipEmptyRows);
}
// Get main table cells
l = item.rows.length;
for (i = 0; i < l; i++) {
item.rows[i] = splitCells(item.rows[i], colCount, item.rows[i - 1],
skipEmptyRows);
}
// header child tokens
l = item.header.length;
for (j = 0; j < l; j++) {
row = item.header[j];
for (k = 0; k < row.length; k++) {
row[k].tokens = [];
this.lexer.inline(row[k].text, row[k].tokens);
}
}
// cell child tokens
l = item.rows.length;
for (j = 0; j < l; j++) {
row = item.rows[j];
for (k = 0; k < row.length; k++) {
row[k].tokens = [];
this.lexer.inline(row[k].text, row[k].tokens);
}
}
return item;
}
}
},
renderer(token) {
let i, j, row, cell, col, text;
let output = '<table>';
output += '<thead>';
for (i = 0; i < token.header.length; i++) {
row = token.header[i];
let col = 0;
output += '<tr>';
for (j = 0; j < row.length; j++) {
cell = row[j];
text = this.parser.parseInline(cell.tokens);
output += getTableCell(text, cell, 'th', token.align[col], token.width[
col]);
col += cell.colspan;
}
output += '</tr>';
}
output += '</thead>';
if (token.rows.length) {
output += '<tbody>';
for (i = 0; i < token.rows.length; i++) {
row = token.rows[i];
col = 0;
if (!row[0].emptyRow) {
output += '<tr>';
for (j = 0; j < row.length; j++) {
cell = row[j];
text = this.parser.parseInline(cell.tokens);
output += getTableCell(text, cell, 'td', token.align[col], token
.width[col]);
col += cell.colspan;
}
output += '</tr>';
}
}
output += '</tbody>';
}
output += '</table>';
return output;
}
}]
};
}
const getTableCell = (text, cell, type, align, width) => {
if (!cell.rowspan) {
return '';
}
const tag = `<${type}` +
`${cell.colspan > 1 ? ` colspan=${cell.colspan}` : ''}` +
`${cell.rowspan > 1 ? ` rowspan=${cell.rowspan}` : ''}` +
`${align ? ` align=${align}` : ''}` +
`${width ? ` width=${width}` : ''}>`;
return `${tag + text}</${type}>\n`;
};
const splitCells = (tableRow, count, prevRow = [], skipEmptyRows) => {
const cells = [...tableRow.trim().matchAll(/(?:[^|\\]|\\.?)+(?:\|+|$)/g)].map((x) => x[0]);
// Remove first/last cell in a row if whitespace only and no leading/trailing pipe
if (!cells[0]?.trim()) {
cells.shift();
}
if (!cells[cells.length - 1]?.trim()) {
cells.pop();
}
let numCols = 0;
let i, j, trimmedCell, prevCell, prevCols;
for (i = 0; i < cells.length; i++) {
trimmedCell = cells[i].split(/\|+$/)[0];
cells[i] = {
rowspan: 1,
colspan: Math.max(cells[i].length - trimmedCell.length, 1),
text: trimmedCell.trim().replace(/\\\|/g, '|')
// display escaped pipes as normal character
};
// Handle Rowspan
if (trimmedCell.slice(-1) === '^' && prevRow.length) {
// Find matching cell in previous row
prevCols = 0;
for (j = 0; j < prevRow.length; j++) {
prevCell = prevRow[j];
if ((prevCols === numCols) && (prevCell.colspan === cells[i].colspan)) {
// merge into matching cell in previous row (the "target")
cells[i].rowSpanTarget = prevCell.rowSpanTarget ?? prevCell;
cells[i].rowSpanTarget.text += ` ${cells[i].text.slice(0, -1)}`;
cells[i].rowSpanTarget.rowspan += 1;
cells[i].rowspan = 0;
break;
}
prevCols += prevCell.colspan;
if (prevCols > numCols) {
break;
}
}
}
numCols += cells[i].colspan;
}
// If all cells have been merged, flag as an empty row
if (cells.length > 0 && skipEmptyRows && cells.length === cells.filter((cell) => {
return cell.rowspan === 0;
}).length) {
cells[0].emptyRow = true;
for (i = 0; i < cells.length; i++) {
cells[i].rowSpanTarget.rowspan -= 1;
}
}
// Force main cell rows to match header column count
if (numCols > count) {
cells.splice(count);
} else {
while (numCols < count) {
cells.push({
rowspan: 1,
colspan: 1,
text: ''
});
numCols += 1;
}
}
return cells;
};
+21
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long