@@ -3,9 +3,9 @@ import * as drpy from './libs/drpyS.js';
33import path from 'path' ;
44import os from "os" ;
55import { fileURLToPath } from 'url' ;
6- import { readdirSync , readFileSync } from 'fs' ;
6+ import { readdirSync , readFileSync } from 'fs' ;
77import { base64Decode } from "./libs_drpy/crypto-util.js" ;
8- import { marked } from './utils/marked.esm .min.js' ;
8+ import './utils/marked.min.js' ;
99
1010const fastify = Fastify ( { logger : true } ) ;
1111
@@ -14,14 +14,13 @@ console.log('__dirname:', __dirname);
1414
1515// 添加 / 接口
1616fastify . get ( '/' , async ( request , reply ) => {
17- const rootDir = path . resolve ( '.' ) ; // 当前根目录
1817 let readmePath = null ;
1918
2019 // 查找根目录下的 README.md 文件(不区分大小写)
21- const files = readdirSync ( rootDir ) ;
20+ const files = readdirSync ( __dirname ) ;
2221 for ( const file of files ) {
2322 if ( / ^ r e a d m e \. m d $ / i. test ( file ) ) {
24- readmePath = path . join ( rootDir , file ) ;
23+ readmePath = path . join ( __dirname , file ) ;
2524 break ;
2625 }
2726 }
@@ -36,7 +35,7 @@ fastify.get('/', async (request, reply) => {
3635 const markdownContent = readFileSync ( readmePath , 'utf-8' ) ;
3736
3837 // 将 Markdown 转换为 HTML
39- const htmlContent = marked ( markdownContent ) ;
38+ const htmlContent = marked . parse ( markdownContent ) ;
4039
4140 // 返回 HTML 内容
4241 reply . type ( 'text/html' ) . send ( `
@@ -79,7 +78,7 @@ fastify.get('/api/:module', async (request, reply) => {
7978 }
8079 }
8180 // 分类逻辑
82- const result = await drpy . cate ( modulePath , query . t , pg , 1 , extend ) ;
81+ const result = await drpy . cate ( modulePath , query . t , pg , 1 , extend ) ;
8382 return reply . send ( result ) ;
8483 }
8584
@@ -125,7 +124,7 @@ fastify.get('/api/:module', async (request, reply) => {
125124const start = async ( ) => {
126125 try {
127126 // 监听 0.0.0.0
128- await fastify . listen ( { port : 5757 , host : '0.0.0.0' } ) ;
127+ await fastify . listen ( { port : 5757 , host : '0.0.0.0' } ) ;
129128
130129 // 获取本地地址
131130 const localAddress = `http://localhost:5757` ;
0 commit comments