import path from 'path'; import {readdirSync, readFileSync} from 'fs'; import '../utils/marked.min.js'; export default (fastify, options, done) => { // 添加 / 接口 fastify.get('/', async (request, reply) => { let readmePath = null; const files = readdirSync(options.rootDir); for (const file of files) { if (/^readme\.md$/i.test(file)) { readmePath = path.join(options.rootDir, file); break; } } // 如果未找到 README.md 文件 if (!readmePath) { reply.code(404).send('