fork from bc4552c5a8
This commit is contained in:
Binary file not shown.
Binary file not shown.
76
exts/yapi-plugin-gen-services/Services/Services.js
Normal file
76
exts/yapi-plugin-gen-services/Services/Services.js
Normal file
@@ -0,0 +1,76 @@
|
||||
import React, { PureComponent as Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux';
|
||||
import { getToken } from '../../../client/reducer/modules/project.js'
|
||||
|
||||
|
||||
import './Services.scss';
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
token: state.project.token
|
||||
}
|
||||
},
|
||||
{
|
||||
getToken
|
||||
}
|
||||
)
|
||||
export default class Services extends Component {
|
||||
static propTypes = {
|
||||
projectId: PropTypes.number,
|
||||
token: PropTypes.string,
|
||||
getToken: PropTypes.func
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
const id = this.props.projectId;
|
||||
await this.props.getToken(id);
|
||||
|
||||
}
|
||||
render () {
|
||||
const id = this.props.projectId;
|
||||
return (
|
||||
<div className="project-services">
|
||||
<section className="news-box m-panel">
|
||||
<div className="token">
|
||||
<h5>安装工具</h5>
|
||||
<pre>{`
|
||||
npm i sm2tsservice -D
|
||||
`}</pre>
|
||||
<h5>配置【3.2.0及以上版本】</h5>
|
||||
<pre>{`
|
||||
touch json2service.json
|
||||
`}</pre>
|
||||
<pre>{`
|
||||
{
|
||||
"url": "yapi-swagger.json",
|
||||
"remoteUrl": "${location.protocol}//${location.hostname}${location.port ? `:${location.port}` : ''}/api/open/plugin/export-full?type=json&pid=${id}&status=all&token=${this.props.token}",
|
||||
"type": "yapi",
|
||||
"swaggerParser": {}
|
||||
}
|
||||
`}
|
||||
</pre>
|
||||
<h5>配置【3.2.0以下版本】</h5>
|
||||
<pre>{`
|
||||
touch json2service.json
|
||||
`}</pre>
|
||||
<pre>{`
|
||||
{
|
||||
"url": "${location.protocol}//${location.hostname}${location.port ? `:${location.port}` : ''}/api/open/plugin/export-full?type=json&pid=${id}&status=all&token=${this.props.token}",
|
||||
"type": "yapi",
|
||||
"swaggerParser": {}
|
||||
}
|
||||
`}
|
||||
</pre>
|
||||
<h5>生成services代码</h5>
|
||||
<pre>{`
|
||||
(./node_modules/.bin/)sm2tsservice --clear
|
||||
`}</pre>
|
||||
</div>
|
||||
<a href="https://github.com/gogoyqj/sm2tsservice">更多说明 sm2tsservice</a>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
6
exts/yapi-plugin-gen-services/Services/Services.scss
Normal file
6
exts/yapi-plugin-gen-services/Services/Services.scss
Normal file
@@ -0,0 +1,6 @@
|
||||
.project-services {
|
||||
margin: 0;
|
||||
pre {
|
||||
background: #efefef;
|
||||
}
|
||||
}
|
||||
12
exts/yapi-plugin-gen-services/client.js
Normal file
12
exts/yapi-plugin-gen-services/client.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import Services from './Services/Services.js';
|
||||
|
||||
function genServices(routers) {
|
||||
routers['services'] = {
|
||||
name: '生成 ts services',
|
||||
component: Services
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function() {
|
||||
this.bindHook('sub_setting_nav', genServices);
|
||||
};
|
||||
209
exts/yapi-plugin-gen-services/controller.js
Normal file
209
exts/yapi-plugin-gen-services/controller.js
Normal file
@@ -0,0 +1,209 @@
|
||||
const baseController = require('controllers/base.js');
|
||||
const interfaceModel = require('models/interface.js');
|
||||
const projectModel = require('models/project.js');
|
||||
// const wikiModel = require('../yapi-plugin-wiki/wikiModel.js');
|
||||
const interfaceCatModel = require('models/interfaceCat.js');
|
||||
const yapi = require('yapi.js');
|
||||
const markdownIt = require('markdown-it');
|
||||
const markdownItAnchor = require('markdown-it-anchor');
|
||||
const markdownItTableOfContents = require('markdown-it-table-of-contents');
|
||||
const defaultTheme = require('./defaultTheme.js');
|
||||
const md = require('../../common/markdown');
|
||||
|
||||
// const htmlToPdf = require("html-pdf");
|
||||
class exportController extends baseController {
|
||||
constructor(ctx) {
|
||||
super(ctx);
|
||||
this.catModel = yapi.getInst(interfaceCatModel);
|
||||
this.interModel = yapi.getInst(interfaceModel);
|
||||
this.projectModel = yapi.getInst(projectModel);
|
||||
|
||||
}
|
||||
|
||||
async handleListClass(pid, status) {
|
||||
let result = await this.catModel.list(pid),
|
||||
newResult = [];
|
||||
for (let i = 0, item, list; i < result.length; i++) {
|
||||
item = result[i].toObject();
|
||||
list = await this.interModel.listByInterStatus(item._id, status);
|
||||
list = list.sort((a, b) => {
|
||||
return a.index - b.index;
|
||||
});
|
||||
if (list.length > 0) {
|
||||
item.list = list;
|
||||
newResult.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
return newResult;
|
||||
}
|
||||
|
||||
handleExistId(data) {
|
||||
function delArrId(arr, fn) {
|
||||
if (!Array.isArray(arr)) return;
|
||||
arr.forEach(item => {
|
||||
delete item._id;
|
||||
delete item.__v;
|
||||
delete item.uid;
|
||||
delete item.edit_uid;
|
||||
delete item.catid;
|
||||
delete item.project_id;
|
||||
|
||||
if (typeof fn === 'function') fn(item);
|
||||
});
|
||||
}
|
||||
|
||||
delArrId(data, function(item) {
|
||||
delArrId(item.list, function(api) {
|
||||
delArrId(api.req_body_form);
|
||||
delArrId(api.req_params);
|
||||
delArrId(api.req_query);
|
||||
delArrId(api.req_headers);
|
||||
if (api.query_path && typeof api.query_path === 'object') {
|
||||
delArrId(api.query_path.params);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
// @feat: serives
|
||||
|
||||
async exportFullData (ctx) {
|
||||
return this.exportData(ctx, 'full-path');
|
||||
}
|
||||
|
||||
async exportData(ctx, fullPath) {
|
||||
let pid = ctx.request.query.pid;
|
||||
let type = ctx.request.query.type;
|
||||
let status = ctx.request.query.status;
|
||||
let isWiki = ctx.request.query.isWiki;
|
||||
|
||||
if (!pid) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 200, 'pid 不为空');
|
||||
}
|
||||
let curProject, wikiData;
|
||||
let tp = '';
|
||||
try {
|
||||
curProject = await this.projectModel.get(pid);
|
||||
const basepath = curProject.basepath;
|
||||
if (isWiki === 'true') {
|
||||
const wikiModel = require('../yapi-plugin-wiki/wikiModel.js');
|
||||
wikiData = await yapi.getInst(wikiModel).get(pid);
|
||||
}
|
||||
ctx.set('Content-Type', 'application/octet-stream');
|
||||
const list = await this.handleListClass(pid, status);
|
||||
|
||||
switch (type) {
|
||||
case 'markdown': {
|
||||
tp = await createMarkdown.bind(this)(list, false);
|
||||
ctx.set('Content-Disposition', `attachment; filename=api.md`);
|
||||
return (ctx.body = tp);
|
||||
}
|
||||
case 'json': {
|
||||
let data = this.handleExistId(list);
|
||||
if (Array.isArray(data) && fullPath === 'full-path' && basepath) {
|
||||
data.forEach(function(cate) {
|
||||
if (Array.isArray(cate.list)) {
|
||||
cate.proBasepath = basepath;
|
||||
cate.proName = curProject.name;
|
||||
cate.proDescription = curProject.desc;
|
||||
cate.list = cate.list.map(function(api) {
|
||||
api.path = api.query_path.path = (basepath + '/' + api.path).replace(/[\/]{2,}/g, '/');
|
||||
return api;
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
tp = JSON.stringify(data, null, 2);
|
||||
ctx.set('Content-Disposition', `attachment; filename=api.json`);
|
||||
return (ctx.body = tp);
|
||||
}
|
||||
default: {
|
||||
//默认为html
|
||||
tp = await createHtml.bind(this)(list);
|
||||
ctx.set('Content-Disposition', `attachment; filename=api.html`);
|
||||
return (ctx.body = tp);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
yapi.commons.log(error, 'error');
|
||||
ctx.body = yapi.commons.resReturn(null, 502, '下载出错');
|
||||
}
|
||||
|
||||
async function createHtml(list) {
|
||||
let md = await createMarkdown.bind(this)(list, true);
|
||||
let markdown = markdownIt({ html: true, breaks: true });
|
||||
markdown.use(markdownItAnchor); // Optional, but makes sense as you really want to link to something
|
||||
markdown.use(markdownItTableOfContents, {
|
||||
markerPattern: /^\[toc\]/im
|
||||
});
|
||||
|
||||
// require('fs').writeFileSync('./a.markdown', md);
|
||||
let tp = unescape(markdown.render(md));
|
||||
// require('fs').writeFileSync('./a.html', tp);
|
||||
let left;
|
||||
// console.log('tp',tp);
|
||||
let content = tp.replace(
|
||||
/<div\s+?class="table-of-contents"\s*>[\s\S]*?<\/ul>\s*<\/div>/gi,
|
||||
function(match) {
|
||||
left = match;
|
||||
return '';
|
||||
}
|
||||
);
|
||||
|
||||
return createHtml5(left || '', content);
|
||||
}
|
||||
|
||||
function createHtml5(left, tp) {
|
||||
//html5模板
|
||||
let html = `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>${curProject.name}</title>
|
||||
<meta charset="utf-8" />
|
||||
${defaultTheme}
|
||||
</head>
|
||||
<body>
|
||||
<div class="m-header">
|
||||
<a href="#" style="display: inherit;"><svg class="svg" width="32px" height="32px" viewBox="0 0 64 64" version="1.1"><title>Icon</title><desc>Created with Sketch.</desc><defs><linearGradient x1="50%" y1="0%" x2="50%" y2="100%" id="linearGradient-1"><stop stop-color="#FFFFFF" offset="0%"></stop><stop stop-color="#F2F2F2" offset="100%"></stop></linearGradient><circle id="path-2" cx="31.9988602" cy="31.9988602" r="2.92886048"></circle><filter x="-85.4%" y="-68.3%" width="270.7%" height="270.7%" filterUnits="objectBoundingBox" id="filter-3"><feOffset dx="0" dy="1" in="SourceAlpha" result="shadowOffsetOuter1"></feOffset><feGaussianBlur stdDeviation="1.5" in="shadowOffsetOuter1" result="shadowBlurOuter1"></feGaussianBlur><feColorMatrix values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.159703351 0" type="matrix" in="shadowBlurOuter1"></feColorMatrix></filter></defs><g id="首页" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="大屏幕"><g id="Icon"><circle id="Oval-1" fill="url(#linearGradient-1)" cx="32" cy="32" r="32"></circle><path d="M36.7078009,31.8054514 L36.7078009,51.7110548 C36.7078009,54.2844537 34.6258634,56.3695395 32.0579205,56.3695395 C29.4899777,56.3695395 27.4099998,54.0704461 27.4099998,51.7941246 L27.4099998,31.8061972 C27.4099998,29.528395 29.4909575,27.218453 32.0589004,27.230043 C34.6268432,27.241633 36.7078009,29.528395 36.7078009,31.8054514 Z" id="blue" fill="#2359F1" fill-rule="nonzero"></path><path d="M45.2586091,17.1026914 C45.2586091,17.1026914 45.5657231,34.0524383 45.2345291,37.01141 C44.9033351,39.9703817 43.1767091,41.6667796 40.6088126,41.6667796 C38.040916,41.6667796 35.9609757,39.3676862 35.9609757,37.0913646 L35.9609757,17.1034372 C35.9609757,14.825635 38.0418959,12.515693 40.6097924,12.527283 C43.177689,12.538873 45.2586091,14.825635 45.2586091,17.1026914 Z" id="green" fill="#57CF27" fill-rule="nonzero" transform="translate(40.674608, 27.097010) rotate(60.000000) translate(-40.674608, -27.097010) "></path><path d="M28.0410158,17.0465598 L28.0410158,36.9521632 C28.0410158,39.525562 25.9591158,41.6106479 23.3912193,41.6106479 C20.8233227,41.6106479 18.7433824,39.3115545 18.7433824,37.035233 L18.7433824,17.0473055 C18.7433824,14.7695034 20.8243026,12.4595614 23.3921991,12.4711513 C25.9600956,12.4827413 28.0410158,14.7695034 28.0410158,17.0465598 Z" id="red" fill="#FF561B" fill-rule="nonzero" transform="translate(23.392199, 27.040878) rotate(-60.000000) translate(-23.392199, -27.040878) "></path><g id="inner-round"><use fill="black" fill-opacity="1" filter="url(#filter-3)" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#path-2"></use><use fill="#F7F7F7" fill-rule="evenodd" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#path-2"></use></g></g></g></g></svg></a>
|
||||
<a href="#"><h1 class="title">YAPI 接口文档</h1></a>
|
||||
<div class="nav">
|
||||
<a href="https://hellosean1025.github.io/yapi/">YApi</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="g-doc">
|
||||
${left}
|
||||
<div id="right" class="content-right">
|
||||
${tp}
|
||||
<footer class="m-footer">
|
||||
<p>Build by <a href="https://ymfe.org/">YMFE</a>.</p>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
|
||||
function createMarkdown(list, isToc) {
|
||||
//拼接markdown
|
||||
//模板
|
||||
let mdTemplate = ``;
|
||||
try {
|
||||
// 项目名称信息
|
||||
mdTemplate += md.createProjectMarkdown(curProject, wikiData);
|
||||
// 分类信息
|
||||
mdTemplate += md.createClassMarkdown(curProject, list, isToc);
|
||||
return mdTemplate;
|
||||
} catch (e) {
|
||||
yapi.commons.log(e, 'error');
|
||||
ctx.body = yapi.commons.resReturn(null, 502, '下载出错');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = exportController;
|
||||
351
exts/yapi-plugin-gen-services/defaultTheme.css
Normal file
351
exts/yapi-plugin-gen-services/defaultTheme.css
Normal file
@@ -0,0 +1,351 @@
|
||||
@charset "UTF-8";
|
||||
html,
|
||||
body,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
p,
|
||||
blockquote {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-weight: normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
/* 设置滚动条的样式 */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
/* 外层轨道 */
|
||||
::-webkit-scrollbar-track {
|
||||
-webkit-box-shadow: inset006pxrgba(255, 0, 0, 0.3);
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
/* 滚动条滑块 */
|
||||
::-webkit-scrollbar-thumb {
|
||||
border-radius: 4px;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
-webkit-box-shadow: inset006pxrgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:window-inactive {
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", SimSun, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 25px;
|
||||
color: #393838;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
table {
|
||||
margin: 10px 0 15px 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
td,
|
||||
th {
|
||||
border: 1px solid #ddd;
|
||||
padding: 3px 10px;
|
||||
}
|
||||
|
||||
th {
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
a, a:link, a:visited {
|
||||
color: #34495e;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover, a:focus {
|
||||
color: #59d69d;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
p {
|
||||
padding-left: 10px;
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
color: #404040;
|
||||
line-height: 36px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #2c3e50;
|
||||
font-weight: 600;
|
||||
margin-bottom: 16px;
|
||||
font-size: 32px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
line-height: 50px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 28px;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
clear: both;
|
||||
font-weight: 400;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
border-left: 3px solid #59d69d;
|
||||
padding-left: 8px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
hr {
|
||||
margin: 0 0 19px;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
padding: 13px 13px 21px 15px;
|
||||
margin-bottom: 18px;
|
||||
font-family: georgia, serif;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
blockquote:before {
|
||||
font-size: 40px;
|
||||
margin-left: -10px;
|
||||
font-family: georgia, serif;
|
||||
color: #eee;
|
||||
}
|
||||
|
||||
blockquote p {
|
||||
font-size: 14px;
|
||||
font-weight: 300;
|
||||
line-height: 18px;
|
||||
margin-bottom: 0;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
code,
|
||||
pre {
|
||||
font-family: Monaco, Andale Mono, Courier New, monospace;
|
||||
}
|
||||
|
||||
code {
|
||||
background-color: #fee9cc;
|
||||
color: rgba(0, 0, 0, 0.75);
|
||||
padding: 1px 3px;
|
||||
font-size: 12px;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
pre {
|
||||
display: block;
|
||||
padding: 14px;
|
||||
margin: 0 0 18px;
|
||||
line-height: 16px;
|
||||
font-size: 11px;
|
||||
border: 1px solid #d9d9d9;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
background: #f6f6f6;
|
||||
}
|
||||
|
||||
pre code {
|
||||
background-color: #f6f6f6;
|
||||
color: #737373;
|
||||
font-size: 11px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
sup {
|
||||
font-size: 0.83em;
|
||||
vertical-align: super;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
* {
|
||||
-webkit-print-color-adjust: exact;
|
||||
}
|
||||
|
||||
@media print {
|
||||
body,
|
||||
code,
|
||||
pre code,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
color: black;
|
||||
}
|
||||
|
||||
table,
|
||||
pre {
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
}
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.table-of-contents {
|
||||
position: fixed;
|
||||
top: 61px;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
width: 260px;
|
||||
}
|
||||
|
||||
.table-of-contents > ul > li > a {
|
||||
font-size: 20px;
|
||||
margin-bottom: 16px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.table-of-contents ul {
|
||||
overflow: auto;
|
||||
margin: 0px;
|
||||
height: 100%;
|
||||
padding: 0px 0px;
|
||||
box-sizing: border-box;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.table-of-contents ul li {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.table-of-contents a {
|
||||
padding: 2px 0px;
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.content-right {
|
||||
max-width: 700px;
|
||||
margin-left: 290px;
|
||||
padding-left: 70px;
|
||||
flex-grow: 1;
|
||||
}
|
||||
.content-right h2:target {
|
||||
padding-top: 80px;
|
||||
}
|
||||
|
||||
body > p {
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
body > table {
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
body > pre {
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
.curProject {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
font-size: 25px;
|
||||
color: black;
|
||||
margin-left: -240px;
|
||||
width: 240px;
|
||||
padding: 5px;
|
||||
line-height: 25px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.g-doc {
|
||||
margin-top: 56px;
|
||||
padding-top: 24px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.curproject-name {
|
||||
font-size: 42px;
|
||||
}
|
||||
|
||||
.m-header {
|
||||
background: #32363a;
|
||||
height: 56px;
|
||||
line-height: 56px;
|
||||
padding-left: 60px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: fixed;
|
||||
z-index: 9;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
}
|
||||
.m-header .title {
|
||||
font-size: 22px;
|
||||
color: #fff;
|
||||
font-weight: normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
margin: 0;
|
||||
margin-left: 16px;
|
||||
padding: 0;
|
||||
line-height: 56px;
|
||||
border: none;
|
||||
}
|
||||
.m-header .nav {
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
position: absolute;
|
||||
right: 32px;
|
||||
top: 0;
|
||||
}
|
||||
.m-header .nav a {
|
||||
color: #fff;
|
||||
margin-left: 16px;
|
||||
padding: 8px;
|
||||
transition: color .2s;
|
||||
}
|
||||
.m-header .nav a:hover {
|
||||
color: #59d69d;
|
||||
}
|
||||
|
||||
.m-footer {
|
||||
border-top: 1px solid #ddd;
|
||||
padding-top: 16px;
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
/*# sourceMappingURL=defaultTheme.css.map */
|
||||
7
exts/yapi-plugin-gen-services/defaultTheme.css.map
Normal file
7
exts/yapi-plugin-gen-services/defaultTheme.css.map
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"mappings": ";AAAA;;;;;;;;;UASW;EACP,MAAM,EAAE,CAAC;EACT,OAAO,EAAE,CAAC;EACV,WAAW,EAAE,MAAM;EACnB,sBAAsB,EAAE,WAAW;;;AAEvC,cAAc;AACd,mBAAoB;EAChB,KAAK,EAAE,GAAG;;;AAEd,UAAU;AACV,yBAA0B;EACtB,kBAAkB,EAAE,8BAA8B;EAClD,UAAU,EAAE,kBAAkB;;;AAElC,WAAW;AACX,yBAA0B;EACtB,aAAa,EAAE,GAAG;EAClB,UAAU,EAAE,kBAAkB;EAC9B,kBAAkB,EAAE,4BAA4B;;;AAEpD,yCAA0C;EACtC,UAAU,EAAE,kBAAkB;;;AAGlC,IAAK;EACD,WAAW,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;EACjB,YAAY,EAAE,IAAI;EAClB,OAAO,EAAE,IAAI;EACb,WAAW,EAAE,MAAM;EACnB,QAAQ,EAAE,KAAK;EACf,OAAO,EAAE,CAAC;EACV,GAAG,EAAE,CAAC;EACN,IAAI,EAAE,CAAC;EACP,KAAK,EAAE,CAAC;;AACR,gBAAO;EACH,SAAS,EAAE,IAAI;EACf,KAAK,EAAE,IAAI;EACX,WAAW,EAAE,MAAM;EACnB,sBAAsB,EAAE,WAAW;EACnC,MAAM,EAAE,CAAC;EACT,WAAW,EAAE,IAAI;EACjB,OAAO,EAAE,CAAC;EACV,WAAW,EAAE,IAAI;EACjB,MAAM,EAAE,IAAI;;AAEhB,cAAK;EACD,KAAK,EAAE,IAAI;EACX,SAAS,EAAE,IAAI;EACf,QAAQ,EAAE,QAAQ;EAClB,KAAK,EAAE,IAAI;EACX,GAAG,EAAE,CAAC;;AACN,gBAAE;EACE,KAAK,EAAE,IAAI;EACX,WAAW,EAAE,IAAI;EACjB,OAAO,EAAE,GAAG;EACZ,UAAU,EAAE,SAAS;;AAEzB,sBAAQ;EACJ,KAAK,EAAE,OAAO;;;AAK1B,SAAU;EACN,UAAU,EAAE,cAAc;EAC1B,WAAW,EAAE,IAAI;EACjB,cAAc,EAAE,IAAI",
|
||||
"sources": ["defaultTheme.scss"],
|
||||
"names": [],
|
||||
"file": "defaultTheme.css"
|
||||
}
|
||||
4
exts/yapi-plugin-gen-services/defaultTheme.js
Normal file
4
exts/yapi-plugin-gen-services/defaultTheme.js
Normal file
@@ -0,0 +1,4 @@
|
||||
const fs = require('fs');
|
||||
const sysPath = require('path');
|
||||
const css = fs.readFileSync(sysPath.join(__dirname, './defaultTheme.css'));
|
||||
module.exports = '<style>' + css + '</style>';
|
||||
355
exts/yapi-plugin-gen-services/defaultTheme.scss
Normal file
355
exts/yapi-plugin-gen-services/defaultTheme.scss
Normal file
@@ -0,0 +1,355 @@
|
||||
html,
|
||||
body,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6,
|
||||
p,
|
||||
blockquote {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-weight: normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
/* 设置滚动条的样式 */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
/* 外层轨道 */
|
||||
::-webkit-scrollbar-track {
|
||||
-webkit-box-shadow: inset006pxrgba(255, 0, 0, 0.3);
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
/* 滚动条滑块 */
|
||||
::-webkit-scrollbar-thumb {
|
||||
border-radius: 4px;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
-webkit-box-shadow: inset006pxrgba(0, 0, 0, 0.5);
|
||||
}
|
||||
::-webkit-scrollbar-thumb:window-inactive {
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", SimSun, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 25px;
|
||||
color: #393838;
|
||||
position: relative;
|
||||
// overflow-x: hidden;
|
||||
}
|
||||
|
||||
table {
|
||||
margin: 10px 0 15px 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
td,
|
||||
th {
|
||||
border: 1px solid #ddd;
|
||||
padding: 3px 10px;
|
||||
}
|
||||
|
||||
th {
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
a, a:link, a:visited {
|
||||
color: #34495e;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover, a:focus {
|
||||
color: #59d69d;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
p {
|
||||
padding-left: 10px;
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
color: #404040;
|
||||
line-height: 36px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #2c3e50;
|
||||
font-weight: 600;
|
||||
// margin-top: 35px;
|
||||
margin-bottom: 16px;
|
||||
font-size: 32px;
|
||||
padding-bottom: 16px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
line-height: 50px;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 28px;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
h3 {
|
||||
clear: both;
|
||||
font-weight: 400;
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
border-left: 3px solid #59d69d;
|
||||
padding-left: 8px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
h5 {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
h6 {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
hr {
|
||||
margin: 0 0 19px;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
padding: 13px 13px 21px 15px;
|
||||
margin-bottom: 18px;
|
||||
font-family: georgia, serif;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
blockquote:before {
|
||||
font-size: 40px;
|
||||
margin-left: -10px;
|
||||
font-family: georgia, serif;
|
||||
color: #eee;
|
||||
}
|
||||
|
||||
blockquote p {
|
||||
font-size: 14px;
|
||||
font-weight: 300;
|
||||
line-height: 18px;
|
||||
margin-bottom: 0;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
code,
|
||||
pre {
|
||||
font-family: Monaco, Andale Mono, Courier New, monospace;
|
||||
}
|
||||
|
||||
code {
|
||||
background-color: #fee9cc;
|
||||
color: rgba(0, 0, 0, 0.75);
|
||||
padding: 1px 3px;
|
||||
font-size: 12px;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
pre {
|
||||
display: block;
|
||||
padding: 14px;
|
||||
margin: 0 0 18px;
|
||||
line-height: 16px;
|
||||
font-size: 11px;
|
||||
border: 1px solid #d9d9d9;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
background: #f6f6f6;
|
||||
}
|
||||
|
||||
pre code {
|
||||
background-color: #f6f6f6;
|
||||
color: #737373;
|
||||
font-size: 11px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
sup {
|
||||
font-size: 0.83em;
|
||||
vertical-align: super;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
* {
|
||||
-webkit-print-color-adjust: exact;
|
||||
}
|
||||
|
||||
@media print {
|
||||
body,
|
||||
code,
|
||||
pre code,
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
color: black;
|
||||
}
|
||||
table,
|
||||
pre {
|
||||
page-break-inside: avoid;
|
||||
}
|
||||
}
|
||||
|
||||
html,
|
||||
body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.table-of-contents {
|
||||
position: fixed;
|
||||
top: 61px;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
width: 260px;
|
||||
}
|
||||
|
||||
.table-of-contents>ul>li>a {
|
||||
font-size: 20px;
|
||||
margin-bottom: 16px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.table-of-contents ul {
|
||||
// position: fixed;
|
||||
// top: 80px;
|
||||
// left: 40px;
|
||||
overflow: auto;
|
||||
margin: 0px;
|
||||
height: 100%;
|
||||
padding: 0px 0px;
|
||||
box-sizing: border-box;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.table-of-contents ul li {
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.table-of-contents a {
|
||||
padding: 2px 0px;
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.content-right {
|
||||
// position: relative;
|
||||
// top: -20px;
|
||||
max-width: 700px;
|
||||
margin-left: 290px;
|
||||
padding-left: 70px;
|
||||
flex-grow: 1;
|
||||
h2:target{
|
||||
padding-top: 80px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
body>p {
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
body>table {
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
body>pre {
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
.curProject {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
font-size: 25px;
|
||||
color: black;
|
||||
margin-left: -240px;
|
||||
width: 240px;
|
||||
padding: 5px;
|
||||
line-height: 25px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.g-doc {
|
||||
margin-top: 56px;
|
||||
padding-top: 24px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.curproject-name{
|
||||
font-size: 42px;
|
||||
}
|
||||
|
||||
.m-header {
|
||||
background: #32363a;
|
||||
height: 56px;
|
||||
line-height: 56px;
|
||||
padding-left: 60px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: fixed;
|
||||
z-index: 9;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
.title {
|
||||
font-size: 22px;
|
||||
color: #fff;
|
||||
font-weight: normal;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
margin: 0;
|
||||
margin-left: 16px;
|
||||
padding: 0;
|
||||
line-height: 56px;
|
||||
border: none;
|
||||
}
|
||||
.nav {
|
||||
color: #fff;
|
||||
font-size: 16px;
|
||||
position: absolute;
|
||||
right: 32px;
|
||||
top: 0;
|
||||
a {
|
||||
color: #fff;
|
||||
margin-left: 16px;
|
||||
padding: 8px;
|
||||
transition: color .2s;
|
||||
}
|
||||
a:hover {
|
||||
color: #59d69d;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.m-footer {
|
||||
border-top: 1px solid #ddd;
|
||||
padding-top: 16px;
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
4
exts/yapi-plugin-gen-services/index.js
Normal file
4
exts/yapi-plugin-gen-services/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
server: true,
|
||||
client: true
|
||||
}
|
||||
18
exts/yapi-plugin-gen-services/server.js
Normal file
18
exts/yapi-plugin-gen-services/server.js
Normal file
@@ -0,0 +1,18 @@
|
||||
const controller = require('./controller');
|
||||
|
||||
// const mongoose = require('mongoose');
|
||||
// const _ = require('underscore');
|
||||
|
||||
module.exports = function(){
|
||||
this.bindHook('add_router', function(addRouter){
|
||||
// @feat: serives
|
||||
addRouter({
|
||||
controller: controller,
|
||||
method: 'get',
|
||||
prefix: '/open',
|
||||
path: 'export-full',
|
||||
action: 'exportFullData'
|
||||
});
|
||||
})
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user