mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-21 05:19:42 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
30c6d6226b
2
.gitignore
vendored
2
.gitignore
vendored
@ -36,5 +36,5 @@ Thumbs.db
|
||||
node_modules/
|
||||
runtime/init.lock
|
||||
runtime/log
|
||||
prd/
|
||||
./prd/
|
||||
dev/
|
||||
|
@ -4,7 +4,7 @@ import PropTypes from 'prop-types'
|
||||
import axios from 'axios'
|
||||
import { connect } from 'react-redux'
|
||||
import { autobind } from 'core-decorators'
|
||||
import { Button, Tabs } from 'antd'
|
||||
import { Button, Tabs, message } from 'antd'
|
||||
import ReqMethod from './ReqMethod/ReqMethod.js'
|
||||
import ReqHeader from './ReqHeader/ReqHeader.js'
|
||||
import ReqParams from './ReqParams/ReqParams.js'
|
||||
@ -20,6 +20,10 @@ import {
|
||||
pushInterfaceName
|
||||
} from '../../actions/addInterface.js'
|
||||
|
||||
const success = () => {
|
||||
message.success('保存成功!')
|
||||
}
|
||||
|
||||
@connect(
|
||||
state => {
|
||||
return {
|
||||
@ -60,7 +64,8 @@ class AddInterface extends Component {
|
||||
constructor (props) {
|
||||
super(props)
|
||||
this.state = {
|
||||
isLoading: ''
|
||||
isLoading: '',
|
||||
isSave: false
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,15 +114,6 @@ class AddInterface extends Component {
|
||||
props.addReqHeader(req_headers)
|
||||
}
|
||||
|
||||
editState2 () {
|
||||
const props = this.props
|
||||
props.pushInputValue(props.url)
|
||||
// props.pushInterfaceName(title)
|
||||
// props.getReqParams(req_params_other)
|
||||
props.getResParams(props.resParams)
|
||||
// props.addReqHeader(req_headers)
|
||||
}
|
||||
|
||||
initInterfaceData (interfaceId) {
|
||||
const params = { id: interfaceId }
|
||||
|
||||
@ -147,6 +143,12 @@ class AddInterface extends Component {
|
||||
location.href = `${origin}${pathname}#/interface`
|
||||
}
|
||||
|
||||
changeState (ifTrue) {
|
||||
this.setState({
|
||||
isSave: ifTrue
|
||||
})
|
||||
}
|
||||
|
||||
@autobind
|
||||
saveForms () {
|
||||
let postURL = undefined
|
||||
@ -175,10 +177,10 @@ class AddInterface extends Component {
|
||||
this.setLoading(true)
|
||||
|
||||
axios.post(postURL, params)
|
||||
.then(data => {
|
||||
console.log(data)
|
||||
.then(() => {
|
||||
this.setLoading()
|
||||
this.editState2()
|
||||
success()
|
||||
this.changeState(true)
|
||||
// this.routerPage()
|
||||
})
|
||||
.catch(e => {
|
||||
@ -188,7 +190,7 @@ class AddInterface extends Component {
|
||||
|
||||
render () {
|
||||
const TabPane = Tabs.TabPane
|
||||
const isLoading = this.state.isLoading
|
||||
const { isLoading, isSave } = this.state
|
||||
|
||||
return (
|
||||
<section className="add-interface-box">
|
||||
@ -200,7 +202,7 @@ class AddInterface extends Component {
|
||||
<ReqHeader />
|
||||
<ReqParams data={this.props} />
|
||||
<ResParams />
|
||||
<Result />
|
||||
<Result isSave={isSave} />
|
||||
</TabPane>
|
||||
<TabPane tab="Mock" key="2">mock</TabPane>
|
||||
<TabPane tab="测试" key="3">
|
||||
|
@ -38,6 +38,7 @@ class ResParams extends Component {
|
||||
const reg = /(<p>)|(<\/p>)| |(<br>)|\s+|<div>|<\/div>/g
|
||||
editor.customConfig.menus = []
|
||||
editor.customConfig.onchange = html => {
|
||||
console.log(html)
|
||||
html = html.match(/{.*}/g)[0]
|
||||
html = html.replace(reg, '')
|
||||
console.log(html)
|
||||
|
@ -16,7 +16,8 @@ import PropTypes from 'prop-types'
|
||||
class Result extends Component {
|
||||
static propTypes = {
|
||||
resParams: PropTypes.string,
|
||||
reqParams: PropTypes.string
|
||||
reqParams: PropTypes.string,
|
||||
isSave: PropTypes.bool
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
@ -24,16 +25,15 @@ class Result extends Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
console.log(1)
|
||||
let TabPane = Tabs.TabPane
|
||||
let resParams = ''
|
||||
let json = ''
|
||||
|
||||
if(this.props.resParams){
|
||||
console.log(this.props.resParams)
|
||||
resParams = JSON.parse(this.props.resParams)
|
||||
json = JSON.stringify(Mock.mock(resParams), null, 2)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="result">
|
||||
<strong className="res-h3">返回示例 :</strong>
|
||||
|
@ -56,7 +56,7 @@ class Login extends Component {
|
||||
componentDidMount() {
|
||||
window.QSSO.attach('qsso-login','/user/login_by_token')
|
||||
}
|
||||
|
||||
|
||||
|
||||
render() {
|
||||
const { getFieldDecorator } = this.props.form;
|
||||
@ -86,6 +86,9 @@ class Login extends Component {
|
||||
<FormItem style={formItemStyle}>
|
||||
<Button style={changeHeight} type="primary" htmlType="submit" className="login-form-button">登录</Button>
|
||||
</FormItem>
|
||||
<div className="qsso-breakline">
|
||||
<span className="qsso-breakword">或</span>
|
||||
</div>
|
||||
<Button style={changeHeight} id="qsso-login" type="primary" className="login-form-button" size="large" ghost>QSSO登录</Button>
|
||||
</Form>
|
||||
|
||||
|
@ -11,6 +11,21 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ant-form-item{
|
||||
.ant-form-item {
|
||||
margin-bottom: .1rem;
|
||||
}
|
||||
|
||||
.qsso-breakline {
|
||||
position: relative;
|
||||
text-align: center;
|
||||
margin: .24rem auto;
|
||||
height: 1px;
|
||||
background-color: #bbb;
|
||||
.qsso-breakword {
|
||||
display: inline-block;
|
||||
transform: translateY(-50%);
|
||||
background-color: #f7f7f7;
|
||||
padding: 0 .08rem;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ export default class GroupList extends Component {
|
||||
if(this.props.groupList[i].group_name === groupName){
|
||||
currGroup = this.props.groupList[i];
|
||||
}else{
|
||||
this.props.history.push(`${currGroup.group_name}`);
|
||||
this.props.history.replace(`${currGroup.group_name}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -156,7 +156,7 @@ export default class GroupList extends Component {
|
||||
const groupId = e.key;
|
||||
const currGroup = this.props.groupList.find((group) => { return +group._id === +groupId });
|
||||
this.props.setCurrGroup(currGroup);
|
||||
this.props.history.push(`${currGroup.group_name}`);
|
||||
this.props.history.replace(`${currGroup.group_name}`);
|
||||
}
|
||||
|
||||
@autobind
|
||||
|
@ -16,11 +16,14 @@
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@qnpm/ykit-config-qunar": "^0.8.2",
|
||||
"assets-webpack-plugin": "^3.5.1",
|
||||
"axios": "^0.16.2",
|
||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||
"copy-webpack-plugin": "^4.0.1",
|
||||
"core-decorators": "^0.17.0",
|
||||
"cross-request": "^1.0.1",
|
||||
"fs-extra": "^3.0.1",
|
||||
"jsoneditor": "^5.9.3",
|
||||
"jsonwebtoken": "^7.4.1",
|
||||
"koa": "^2.0.0",
|
||||
"koa-bodyparser": "^3.2.0",
|
||||
@ -34,16 +37,19 @@
|
||||
"mock": "^0.1.1",
|
||||
"mockjs": "^1.0.1-beta3",
|
||||
"moment": "^2.18.1",
|
||||
"monaco-editor": "^0.9.0",
|
||||
"mongoose": "4.10.8",
|
||||
"mongoose-auto-increment": "^5.0.1",
|
||||
"node-sass-china": "^4.5.0",
|
||||
"nodemailer": "^4.0.1",
|
||||
"prop-types": "^15.5.10",
|
||||
"react-monaco-editor": "^0.8.1",
|
||||
"redux": "^3.7.1",
|
||||
"redux-promise": "^0.5.3",
|
||||
"redux-thunk": "^2.2.0",
|
||||
"request": "^2.81.0",
|
||||
"sha1": "^1.1.1",
|
||||
"string-replace-webpack-plugin": "^0.1.3",
|
||||
"universal-cookie": "^2.0.8",
|
||||
"wangeditor": "^3.0.4",
|
||||
"ykit-config-antd": "^0.1.3",
|
||||
@ -71,6 +77,7 @@
|
||||
"eslint-plugin-react": "^7.1.0",
|
||||
"express": "^4.15.3",
|
||||
"extract-text-webpack-plugin": "^1.0.1",
|
||||
"fast-sass-loader": "^1.2.5",
|
||||
"fs-extra": "^3.0.1",
|
||||
"ghooks": "^2.0.0",
|
||||
"gulp": "^3.9.1",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"port": "3000",
|
||||
"webhost": "127.0.0.1",
|
||||
"webhost": "yapi.local.qunar.com",
|
||||
"adminAccount": "admin@admin.com",
|
||||
"db": {
|
||||
"servername": "10.86.40.194",
|
||||
|
36
static/dev.html
Normal file
36
static/dev.html
Normal file
@ -0,0 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>my yApi</title>
|
||||
<link rel="stylesheet" href="http://127.0.0.1:4000/yapi/prd/index@dev.css">
|
||||
<script src="https://qsso.corp.qunar.com/lib/qsso-auth.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="yapi" style="height: 100%;"></div>
|
||||
<script src="http://127.0.0.1:4000/yapi/prd/index@dev.js"></script>
|
||||
|
||||
<!--
|
||||
<button id="qsso-login">qsso登录</button>
|
||||
<script src="https://qsso.corp.qunar.com/lib/qsso-auth.js"></script>
|
||||
|
||||
<script>
|
||||
QSSO.attach('qsso-login','/user/login_by_token');
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', '/user/status')
|
||||
xhr.onload = function(e){
|
||||
if(this.status == 200){
|
||||
alert(this.responseText)
|
||||
}
|
||||
}
|
||||
xhr.send()
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<html>
|
||||
|
||||
-->
|
||||
</body>
|
||||
</html>
|
@ -4,33 +4,19 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<title>my yApi</title>
|
||||
<link rel="stylesheet" href="http://127.0.0.1:4000/yapi/prd/index@dev.css">
|
||||
<script>
|
||||
document.write('<script src="prd/assets.js?v=' + Math.random() + '"><\/script>');
|
||||
</script>
|
||||
<script>
|
||||
document.write('<link rel="stylesheet" href="/prd/' + window.WEBPACK_ASSETS['index.js'].css + '" />');
|
||||
</script>
|
||||
|
||||
<script src="https://qsso.corp.qunar.com/lib/qsso-auth.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="yapi" style="height: 100%;"></div>
|
||||
<script src="http://127.0.0.1:4000/yapi/prd/index@dev.js"></script>
|
||||
|
||||
<!--
|
||||
<button id="qsso-login">qsso登录</button>
|
||||
<script src="https://qsso.corp.qunar.com/lib/qsso-auth.js"></script>
|
||||
|
||||
<script>
|
||||
QSSO.attach('qsso-login','/user/login_by_token');
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open('GET', '/user/status')
|
||||
xhr.onload = function(e){
|
||||
if(this.status == 200){
|
||||
alert(this.responseText)
|
||||
}
|
||||
}
|
||||
xhr.send()
|
||||
|
||||
document.write('<script src="/prd/' + window.WEBPACK_ASSETS['index.js'].js + '"><\/script>');
|
||||
</script>
|
||||
|
||||
|
||||
<html>
|
||||
|
||||
-->
|
||||
</body>
|
||||
</html>
|
||||
|
1
static/prd/assets.js
Normal file
1
static/prd/assets.js
Normal file
@ -0,0 +1 @@
|
||||
window.WEBPACK_ASSETS = {"index.js":{"js":"index.js","css":"index.css"}}
|
21
static/prd/index.css
Normal file
21
static/prd/index.css
Normal file
File diff suppressed because one or more lines are too long
1
static/prd/index.js
Normal file
1
static/prd/index.js
Normal file
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
||||
4c1b3161122796d85b75b3c0f041cd26
|
@ -1 +0,0 @@
|
||||
064c5c9b316a6ad40669
|
@ -1 +0,0 @@
|
||||
064c5c9b316a6ad40669
|
@ -1,3 +0,0 @@
|
||||
index.css#064c5c9b316a6ad40669
|
||||
index.js#064c5c9b316a6ad40669
|
||||
chunk.json#4c1b3161122796d85b75b3c0f041cd26
|
@ -1,61 +0,0 @@
|
||||
const webpack = require('webpack')
|
||||
const path = require('path')
|
||||
const nodeExternals = require('webpack-node-externals')
|
||||
const ExtractTextPlugin = require("extract-text-webpack-plugin")
|
||||
|
||||
module.exports = {
|
||||
// context: 如果不通过path.resolve 配置入口访问路径 watch: true失效
|
||||
context: path.resolve('./client'),
|
||||
|
||||
entry: {
|
||||
index: './index.js',
|
||||
},
|
||||
|
||||
output: {
|
||||
// filename: 编译的文件名 仅用于命名每个文件
|
||||
// [name]: 多入口形式 入口文件名替换这里的name
|
||||
// [chunkhash: num]: 入口文件的hash值 用于修改后清空缓存
|
||||
// filename: '[name].[chunkhash:3].js',
|
||||
filename: './[name].js',
|
||||
// 包存放的目录
|
||||
path: path.resolve('./build'),
|
||||
},
|
||||
devServer:{
|
||||
contentBase:'./'
|
||||
},
|
||||
// target: 'node',
|
||||
// externals: [nodeExternals()],
|
||||
module: {
|
||||
noParse: /\.css$/,
|
||||
|
||||
rules: [
|
||||
{
|
||||
test: /\.scss$/,
|
||||
use: [
|
||||
{
|
||||
loader: "style-loader"
|
||||
},
|
||||
{
|
||||
loader: "css-loader"
|
||||
},
|
||||
{
|
||||
loader: "sass-loader"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.(jsx|js)?$/,
|
||||
exclude: /node_modules/,
|
||||
use: {
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
presets: ['es2015', 'react']
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
watch: true
|
||||
}
|
||||
|
55
ykit.js
55
ykit.js
@ -1,30 +1,53 @@
|
||||
var path = require('path');
|
||||
|
||||
var AssetsPlugin = require('assets-webpack-plugin')
|
||||
var assetsPluginInstance = new AssetsPlugin({
|
||||
filename: 'static/prd/assets.js',
|
||||
processOutput: function (assets) {
|
||||
return 'window.WEBPACK_ASSETS = ' + JSON.stringify(assets);
|
||||
}
|
||||
})
|
||||
module.exports = {
|
||||
plugins: [{
|
||||
name: 'qunar',
|
||||
options: {
|
||||
eslint: true,
|
||||
configFile: path.resolve(__dirname, "./client/.eslintrc.js")
|
||||
}
|
||||
}, {
|
||||
name: 'antd',
|
||||
options: {
|
||||
modifyQuery: function(defaultQuery) { // 可查看和编辑 defaultQuery
|
||||
modifyQuery: function (defaultQuery) { // 可查看和编辑 defaultQuery
|
||||
defaultQuery.plugins.push('transform-decorators-legacy');
|
||||
return defaultQuery;
|
||||
}
|
||||
}
|
||||
}],
|
||||
// devtool: 'cheap-source-map',
|
||||
config: {
|
||||
exports: [
|
||||
'./index.js'
|
||||
],
|
||||
modifyWebpackConfig: function(baseConfig) {
|
||||
baseConfig.devtool = 'cheap-module-eval-source-map'
|
||||
baseConfig.context = path.resolve(__dirname, "client");
|
||||
return baseConfig;
|
||||
config: function (ykit) {
|
||||
return {
|
||||
exports: [
|
||||
'./index.js'
|
||||
],
|
||||
modifyWebpackConfig: function (baseConfig) {
|
||||
|
||||
baseConfig.devtool = 'cheap-module-eval-source-map'
|
||||
baseConfig.context = path.resolve(__dirname, "client");
|
||||
|
||||
baseConfig.output.prd.path = 'static/prd';
|
||||
baseConfig.output.prd.publicPath = '';
|
||||
baseConfig.output.prd.filename = '[name][ext]'
|
||||
baseConfig.plugins.push(assetsPluginInstance)
|
||||
|
||||
baseConfig.module.loaders.push({
|
||||
test: /\.(sass|scss)$/,
|
||||
loader: ykit.ExtractTextPlugin.extract(
|
||||
require.resolve('css-loader')
|
||||
+ '?sourceMap!'
|
||||
+ require.resolve('fast-sass-loader') + '?sourceMap'
|
||||
)
|
||||
})
|
||||
baseConfig.module.preLoaders.push({
|
||||
test: /\.(js|jsx)$/,
|
||||
exclude: /node_modules/,
|
||||
loader: "eslint-loader"
|
||||
});
|
||||
|
||||
return baseConfig;
|
||||
}
|
||||
}
|
||||
},
|
||||
server: {
|
||||
|
Loading…
Reference in New Issue
Block a user