Merge pull request #17 from xuanqb/patch-1

fix:安卓端渲染失败
This commit is contained in:
小能饼干 2025-04-12 13:39:37 +08:00 committed by GitHub
commit e478eb5a83
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 89 additions and 70 deletions

View File

@ -1,12 +1,32 @@
<div class="md-content">
{{Front}}
</div>
<!-- https://github.com/markdown-it/markdown-it -->
<script defer src="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/markdown-it/12.3.2/markdown-it.min.js"></script>
<!-- 代码高亮库 -->
<script defer src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/highlight.js/11.4.0/highlight.min.js"></script>
<script defer>
'use strict'
<script>
var getResources = [
getScript("https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/markdown-it/12.3.2/markdown-it.min.js"),
getScript("https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/highlight.js/11.4.0/highlight.min.js"),
];
// 加载资源并初始化
Promise.all(getResources)
.then(() => {
parseMarkDownFn();
})
.catch(error => {
consoleLog('Failed to load required resources: ' + error);
});
function getScript(url) {
return new Promise((resolve, reject) => {
const script = document.createElement("script");
script.onload = resolve;
script.onerror = () => reject(new Error(`Failed to load script from ${url}`));
script.src = url;
document.head.appendChild(script);
});
}
// 在anki中通过窗口查看调试信息 没控制台啊
function consoleLog(str) {
var div = document.createElement('div')
@ -71,5 +91,4 @@
// 不能从body直接插入元素 anki 不刷新的
})
}
parseMarkDownFn();
</script>