fix(doc): GetDoc 识别完整 HTML 文档为 html 格式
- 内容以 <!DOCTYPE/html 开头且标为 markdown 时按 html 返回,避免 marked 拆坏内嵌 </style> 污染站点样式(配合前端 @layer 隔离) - TempLate 同步 GVSite 最新构建产物
This commit is contained in:
1 parent
404befbb3e
commit
ca935eda20
3 files changed
+9
-4
No files matched your search
+1
-1
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>银河锋锐(GVSDS)</title>
|
||||
<link rel="icon" href="https://hb.cdn.gvsds.com/assets/icon/ICON.png">
|
||||
<script type="module" crossorigin src="/GVSite/index-gTeqxgRk.js"></script>
|
||||
<script type="module" crossorigin src="/GVSite/index-CTnafLRB.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/GVSite/index-DRWk7H-y.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>银河锋锐(GVSDS)</title>
|
||||
<link rel="icon" href="https://hb.cdn.gvsds.com/assets/icon/ICON.png">
|
||||
<script type="module" crossorigin src="/GVSite/index-DhQua3qJ.js"></script>
|
||||
<script type="module" crossorigin src="/GVSite/index-DrabGyKU.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/GVSite/index-DRWk7H-y.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -161,10 +161,15 @@ def _doc_api(file_path):
|
||||
doc = DocManager.GetDocument(uuid_bytes)
|
||||
if doc is None:
|
||||
return JsonResponse({'error': 'not_found'}, status=404)
|
||||
content = doc.DocContent or ''
|
||||
doc_format = doc.DocFormat
|
||||
# 数据兜底:内容实为完整 HTML 文档时按 html 渲染(marked 会把内嵌 </style> 拆坏,污染站点样式)
|
||||
if doc_format == 'markdown' and content.lstrip().lower().startswith(('<!doctype', '<html')):
|
||||
doc_format = 'html'
|
||||
return JsonResponse({
|
||||
'DocTitle': doc.DocTitle or '未命名文档',
|
||||
'DocContent': doc.DocContent or '',
|
||||
'DocFormat': doc.DocFormat,
|
||||
'DocContent': content,
|
||||
'DocFormat': doc_format,
|
||||
'DocPermission': 1,
|
||||
'DocDecrypt': True,
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user