代码拉取完成,页面将自动刷新
同步操作将从 CPC123456/koa2-typescript 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/* eslint-disable */
const path = require("path");
const apidoc = require("apidoc");
const fs = require('fs');
const src = path.resolve(__dirname, 'src/routes/');
const dest = path.resolve(__dirname, 'public/apidoc/');
const doc = apidoc.createDoc({src, dest})
if (typeof doc !== 'boolean') {
replaceFile(dest + "/vendor/webfontloader.js", "//fonts.googleapis.com/css", "");
addHeaderText();
console.log("成功生成文档!");
const config = require("./env/development.js");
console.log("访问地址:http://127.0.0.1:" + config.port + "/public/apidoc/index.html")
}
function replaceFile(filePath, sourceRegx, targetStr) {
fs.readFile(filePath, function (err, data) {
if (err) {
return err;
}
let str = data.toString();
str = str.replace(sourceRegx, targetStr);
fs.writeFile(filePath, str, function (err) {
if (err) return err;
});
});
}
function addHeaderText() {
const text = `<div style="position: fixed;right: 10px;top: 10px;">
统一Header修改:
<select id="cpcRequeryType"></select>
<input id="cpcRequeryValue" type="text">
<button onclick="uniformModification()">确定修改</button>
<script>
document.getElementById('loader').addEventListener("DOMNodeRemoved", function () {
setTimeout(() => {
const allFieldDom = document.querySelectorAll('[id^="sample-request-header-field-"]');
let allMap = [];
allFieldDom.forEach(el => allMap.push(el.id))
const all = [...new Set(allMap)];
document.getElementById("cpcRequeryType").innerHTML = [...new Set(allMap)].map(id => {
return '<option value="'+id+'">'+id.replaceAll("sample-request-header-field-", "")+'</option>'
});
document.getElementById("cpcRequeryValue").value = localStorage.getItem("cpcRequeryValue");
uniformModification();
}, 1000)
}, false);
function uniformModification() {
const cpcRequeryType = document.getElementById("cpcRequeryType");
const value = document.getElementById("cpcRequeryValue").value;
localStorage.setItem("cpcRequeryValue",value);
document.querySelectorAll("#"+cpcRequeryType.value).forEach(el => {
el.value = value
})
}
</script>
</div>`;
const filePath = dest + "/index.html";
fs.readFile(filePath, function (err, data) {
if (err) {
return err;
}
let str = data.toString();
str = str + text;
fs.writeFile(filePath, str, function (err) {
if (err) return err;
});
});
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。