You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
878 B
JavaScript

const fs = require('fs');
const baseUrl = 'http://localhost:8090/';
function routerLog({
name,
url,
type,
desc,
accessUrl,
responseExample
}) {
let log = `### ${name} \n` +
` \n #### 说明 \n` +
` \n ${desc} \n` +
` \n #### 请求方式 \n` +
` \n ${type} \n` +
` \n #### 接口地址 \n` +
` \n ${url} \n` +
` \n #### 预览接口 \n` +
` \n [预览接口${name}](${baseUrl}${accessUrl}) \n\n`+
` \n #### 相应示例 \n` +
` \n `+'```'+' \n '+` ${responseExample}`+' \n '+'```'+` \n\n`
return log;
}
function markdownTitle({
name
}) {
let data = `\n ## ${name} \n\n`;
writeLog(data);
}
function writeLog(data) {
fs.appendFile('./routerLog.md', data, 'utf8', function(err) {
if (err) {
console.log(err);
} else {
console.log('写入路由记录')
}
});
}
module.exports = {
markdownTitle,
routerLog,
writeLog
};