diff --git a/nginx.conf b/nginx.conf index b59df94..76aa277 100644 --- a/nginx.conf +++ b/nginx.conf @@ -13,7 +13,8 @@ server { # Markdown 接口说明,直接返回文本内容 location = /apidoc { - default_type text/markdown; + types { } + default_type text/plain; charset utf-8; try_files /apidoc =404; add_header Cache-Control "no-store"; diff --git a/scripts/generate-api.mjs b/scripts/generate-api.mjs index 39f6dd5..42f8ded 100644 --- a/scripts/generate-api.mjs +++ b/scripts/generate-api.mjs @@ -37,7 +37,8 @@ function writeTextFile(target, content) { function copyApiDoc() { const source = path.join(rootDir, 'docs', '知识库API接口说明.md') const content = fs.readFileSync(source, 'utf8') - writeTextFile(apiDocPath, content) + // /apidoc 是无扩展名文本接口;写入 UTF-8 BOM,避免部分静态服务器或浏览器按非 UTF-8 猜测导致中文乱码。 + writeTextFile(apiDocPath, `\uFEFF${content}`) } function extractConstArrayFromTs(filePath, constName) {