fix: ensure apidoc uses utf-8 text

This commit is contained in:
ittoview
2026-05-10 12:19:51 +01:00
parent 71b8b34df0
commit 22d9abe0f2
2 changed files with 4 additions and 2 deletions

View File

@@ -13,7 +13,8 @@ server {
# Markdown 接口说明,直接返回文本内容 # Markdown 接口说明,直接返回文本内容
location = /apidoc { location = /apidoc {
default_type text/markdown; types { }
default_type text/plain;
charset utf-8; charset utf-8;
try_files /apidoc =404; try_files /apidoc =404;
add_header Cache-Control "no-store"; add_header Cache-Control "no-store";

View File

@@ -37,7 +37,8 @@ function writeTextFile(target, content) {
function copyApiDoc() { function copyApiDoc() {
const source = path.join(rootDir, 'docs', '知识库API接口说明.md') const source = path.join(rootDir, 'docs', '知识库API接口说明.md')
const content = fs.readFileSync(source, 'utf8') const content = fs.readFileSync(source, 'utf8')
writeTextFile(apiDocPath, content) // /apidoc 是无扩展名文本接口;写入 UTF-8 BOM避免部分静态服务器或浏览器按非 UTF-8 猜测导致中文乱码。
writeTextFile(apiDocPath, `\uFEFF${content}`)
} }
function extractConstArrayFromTs(filePath, constName) { function extractConstArrayFromTs(filePath, constName) {