feat: 完善外部资源备用机制和日志系统

- 在header.php中添加用户角色检测,传递给前端JavaScript
- 更新Open Sans字体CSS文件,支持本地woff2字体文件备用
- 修改footer.php中MathJax 3/2和KaTeX加载机制,添加onerror备用处理
- 优化resource-loader.js日志系统,使用ArgonLogger替代console.log
- 仅管理员用户显示控制台日志,普通用户和游客不显示调试信息
- 完善资源加载错误处理,统一使用ArgonLogger记录警告信息
This commit is contained in:
2026-01-11 20:37:03 +08:00
parent a01f161bca
commit ea167c379a
17 changed files with 1621 additions and 60 deletions

View File

@@ -0,0 +1,54 @@
/* KaTeX Auto-Render - Local Fallback */
(function() {
'use strict';
console.warn('KaTeX Auto-Render 本地备用版本 - 功能受限');
window.renderMathInElement = function(element, options) {
console.warn('KaTeX 自动渲染功能不可用 - 使用备用版本');
options = options || {};
var delimiters = options.delimiters || [
{left: "$$", right: "$$", display: true},
{left: "$", right: "$", display: false},
{left: "\\(", right: "\\)", display: false},
{left: "\\[", right: "\\]", display: true}
];
if (!element) {
element = document.body;
}
// 简单的文本替换处理
var walker = document.createTreeWalker(
element,
NodeFilter.SHOW_TEXT,
null,
false
);
var textNodes = [];
var node;
while (node = walker.nextNode()) {
textNodes.push(node);
}
textNodes.forEach(function(textNode) {
var text = textNode.textContent;
var hasMatch = false;
delimiters.forEach(function(delimiter) {
if (text.includes(delimiter.left) && text.includes(delimiter.right)) {
hasMatch = true;
}
});
if (hasMatch) {
var span = document.createElement('span');
span.innerHTML = text.replace(/\$([^$]+)\$/g,
'<span class="katex" style="font-style: italic; color: #666;" title="数学公式渲染服务不可用">$1</span>');
textNode.parentNode.replaceChild(span, textNode);
}
});
};
})();

View File

@@ -0,0 +1,47 @@
/* KaTeX CSS - Local Fallback */
.katex {
font: normal 1.21em KaTeX_Main, "Times New Roman", serif;
line-height: 1.2;
text-indent: 0;
text-rendering: auto;
font-style: italic;
color: #666;
}
.katex * {
-ms-high-contrast-adjust: none !important;
}
.katex .katex-version::after {
content: "本地备用版本";
}
.katex .katex-mathml {
position: absolute;
clip: rect(1px, 1px, 1px, 1px);
padding: 0;
border: 0;
height: 1px;
width: 1px;
overflow: hidden;
}
.katex-display {
display: block;
margin: 1em 0;
text-align: center;
}
.katex-display > .katex {
display: block;
text-align: center;
white-space: nowrap;
}
/* 备用样式提示 */
.katex::before {
content: "[数学公式渲染服务不可用] ";
font-size: 0.8em;
color: #999;
font-style: normal;
}

View File

@@ -0,0 +1,27 @@
/* KaTeX JS - Local Fallback */
(function() {
'use strict';
console.warn('KaTeX 本地备用版本 - 功能受限');
// 创建简化的 KaTeX 对象
window.katex = {
render: function(tex, element, options) {
console.warn('KaTeX 渲染功能不可用 - 使用备用版本');
if (element) {
element.innerHTML = '<span style="font-style: italic; color: #666;" title="数学公式渲染服务不可用">' +
tex + '</span>';
element.className = (element.className || '') + ' katex';
}
},
renderToString: function(tex, options) {
console.warn('KaTeX 渲染功能不可用 - 使用备用版本');
return '<span class="katex" style="font-style: italic; color: #666;" title="数学公式渲染服务不可用">' +
tex + '</span>';
}
};
// 版本信息
window.katex.__version = "0.11.1-fallback";
})();