fix: 更新健康监测模块页面与文档,新增静态服务配置
This commit is contained in:
@@ -75,6 +75,14 @@ body { font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Helvetica
|
||||
<img id="lightbox-img" src="" alt="放大预览">
|
||||
</div>
|
||||
<script>
|
||||
/* ===== file:// 协议 → 自动跳转到本地服务器 ===== */
|
||||
(function() {
|
||||
if (location.protocol === 'file:') {
|
||||
var search = location.search; /* 保留 ?file=...&title=... 参数 */
|
||||
location.href = 'http://localhost:8080/_templates/md-viewer.html' + search;
|
||||
}
|
||||
})();
|
||||
|
||||
const params = new URLSearchParams(location.search);
|
||||
const filePath = params.get('file');
|
||||
const title = params.get('title');
|
||||
@@ -113,7 +121,8 @@ if (title) {
|
||||
}
|
||||
if (filePath) {
|
||||
document.getElementById('doc-path').textContent = filePath;
|
||||
fetch(filePath)
|
||||
/* 用绝对路径(/ 开头),避免 <base href="../"> 在不同浏览器中解析不一致 */
|
||||
fetch('/' + filePath)
|
||||
.then(res => {
|
||||
if (!res.ok) throw new Error('文件未找到 (' + res.status + ')');
|
||||
return res.text();
|
||||
@@ -203,7 +212,7 @@ if (filePath) {
|
||||
content.querySelectorAll('img').forEach(img => {
|
||||
const src = img.getAttribute('src');
|
||||
if (src && !src.startsWith('http') && !src.startsWith('/') && !src.startsWith('data:')) {
|
||||
img.src = mdBase + src;
|
||||
img.src = '/' + mdBase + src;
|
||||
}
|
||||
});
|
||||
/* 绑定图片点击放大 */
|
||||
|
||||
Reference in New Issue
Block a user