1
0
mirror of https://gitee.com/tawords/tawords-docs synced 2025-09-11 04:41:39 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

CSS JS文件本地化提高加载速度

This commit is contained in:
2021-08-07 01:44:15 +08:00
parent 6776edbd16
commit 6793ff7a27
12 changed files with 4184 additions and 10 deletions

View File

@@ -0,0 +1,51 @@
(function () {
// 下面是解析的部分
const chatMap = {
"&": "&",
"'": "'",
"`": "`",
'"': """,
"<": "&lt;",
">": "&gt;",
};
const escapeHTML = (string) => {
if (typeof string !== "string") return string;
return string.replace(/[&'`"<>]/g, function (match) {
return chatMap[match];
});
};
window.drawioConverter = function (xml, idx = new Date().getTime()) {
let mxGraphData = {
editable: false,
highlight: "#0000ff",
nav: false,
toolbar: null,
edit: null,
resize: true,
lightbox: "open",
// "check-visible-state": false,
// "auto-fit": false,
// move: false,
xml,
};
const json = JSON.stringify(mxGraphData);
return `<div class="drawio-viewer-index-${idx}">
<div class="mxgraph" style="max-width: 100%; border: 1px solid transparent" data-mxgraph="${escapeHTML(json)}"></div>
</div>
`;
};
// 下面是插件加载部分
const install = function (hook) {
hook.doneEach((hook) => {
try {
window.GraphViewer.processElements();
} catch {}
});
};
window.$docsify.plugins = [].concat(install, $docsify.plugins);
})();

File diff suppressed because one or more lines are too long