Commit 21866044 by 无尘

feat: 增加 dubbo 参数导入

parent 4f0be794
<!DOCTYPE html><html><head><meta charset=utf-8><link rel="shortcut icon" href=./favicon.ico><title>API网关管理平台</title><link href=./static/css/app.3334f7823f703f6f6a7c6a59540e4e64.css rel=stylesheet></head><body style="min-width: 1400px;"><div id=app></div><script src=//web-1251519181.file.myqcloud.com/lib/vue/2.6.6/vue.min.js></script><script src=//web-1251519181.file.myqcloud.com/lib/vue-router/3.0.2/vue-router.min.js></script><script src=//web-1251519181.file.myqcloud.com/lib/vuex/3.1.0/vuex.min.js></script><script src=//web-1251519181.file.myqcloud.com/components/img-preview.2.0.00.js></script><script>// Raven.config('https://3715a345910d4c768e7a1ec14619c2d5@sentry.io/1413672').install();</script><script src=//web-1251519181.file.myqcloud.com/components/input.2.0.15.js></script><script src=//web-1251519181.file.myqcloud.com/components/delete.2.0.01.js></script><script type=text/javascript src=./static/js/manifest.bd93d8d63ee22caec60a.js></script><script type=text/javascript src=./static/js/vendor.71dc162eb690bf6a36a0.js></script><script type=text/javascript src=./static/js/app.645acae76cd0fc1ae565.js></script></body></html> <!DOCTYPE html><html><head><meta charset=utf-8><link rel="shortcut icon" href=./favicon.ico><title>API网关管理平台</title><link href=./static/css/app.1c1ed4131ae44c50cd84def45cf5d7f6.css rel=stylesheet></head><body style="min-width: 1400px;"><div id=app></div><script src=//web-1251519181.file.myqcloud.com/lib/vue/2.6.6/vue.min.js></script><script src=//web-1251519181.file.myqcloud.com/lib/vue-router/3.0.2/vue-router.min.js></script><script src=//web-1251519181.file.myqcloud.com/lib/vuex/3.1.0/vuex.min.js></script><script src=//web-1251519181.file.myqcloud.com/components/img-preview.2.0.00.js></script><script>// Raven.config('https://3715a345910d4c768e7a1ec14619c2d5@sentry.io/1413672').install();</script><script src=//web-1251519181.file.myqcloud.com/components/input.2.0.15.js></script><script src=//web-1251519181.file.myqcloud.com/components/delete.2.0.01.js></script><script type=text/javascript src=./static/js/manifest.d512dd35283afb265cb7.js></script><script type=text/javascript src=./static/js/vendor.71dc162eb690bf6a36a0.js></script><script type=text/javascript src=./static/js/app.8c17e0f45e015cda57f6.js></script></body></html>
\ No newline at end of file \ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,c,a){for(var f,d,b,i=0,u=[];i<r.length;i++)d=r[i],t[d]&&u.push(t[d][0]),t[d]=0;for(f in c)Object.prototype.hasOwnProperty.call(c,f)&&(e[f]=c[f]);for(n&&n(r,c,a);u.length;)u.shift()();if(a)for(i=0;i<a.length;i++)b=o(o.s=a[i]);return b};var r={},t={24:0};function o(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,o),t.l=!0,t.exports}o.e=function(e){var n=t[e];if(0===n)return new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,o){n=t[e]=[r,o]});n[2]=r;var c=document.getElementsByTagName("head")[0],a=document.createElement("script");a.type="text/javascript",a.charset="utf-8",a.async=!0,a.timeout=12e4,o.nc&&a.setAttribute("nonce",o.nc),a.src=o.p+"static/js/"+e+"."+{0:"63d3650fda518fa5d91a",1:"0ebe3ead93207dc78a78",2:"45333a09bedc26a925f6",3:"02f6ff10c5e83fdc830b",4:"83b134741cef8a1fc258",5:"61455822347fda4022ec",6:"7a4f7f41cea5405e209f",7:"b2a85a42ddd430235a63",8:"81460c8c66d06cfea732",9:"9c96ae683c51b04359d0",10:"638039a7b39908980436",11:"f27d1de28264fbbe30ff",12:"ccbc18453e41490e2dba",13:"b109164d2be44afb7733",14:"9825bb69e60b8030c230",15:"ffd723714f3c604ae809",16:"825722b083bcf8e5877e",17:"4786e13164b8fb55cf3b",18:"ebf8edd37453b58275c4",19:"237102ab58f0569908b0",20:"106676f1ed05cab7702b",21:"9811614945523e2ab002"}[e]+".js";var f=setTimeout(d,12e4);function d(){a.onerror=a.onload=null,clearTimeout(f);var n=t[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),t[e]=void 0)}return a.onerror=a.onload=d,c.appendChild(a),r},o.m=e,o.c=r,o.d=function(e,n,r){o.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},o.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(n,"a",n),n},o.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},o.p="./",o.oe=function(e){throw console.error(e),e}}([]);
\ No newline at end of file
!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,o,a){for(var f,b,d,i=0,u=[];i<r.length;i++)b=r[i],t[b]&&u.push(t[b][0]),t[b]=0;for(f in o)Object.prototype.hasOwnProperty.call(o,f)&&(e[f]=o[f]);for(n&&n(r,o,a);u.length;)u.shift()();if(a)for(i=0;i<a.length;i++)d=c(c.s=a[i]);return d};var r={},t={24:0};function c(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,c),t.l=!0,t.exports}c.e=function(e){var n=t[e];if(0===n)return new Promise(function(e){e()});if(n)return n[2];var r=new Promise(function(r,c){n=t[e]=[r,c]});n[2]=r;var o=document.getElementsByTagName("head")[0],a=document.createElement("script");a.type="text/javascript",a.charset="utf-8",a.async=!0,a.timeout=12e4,c.nc&&a.setAttribute("nonce",c.nc),a.src=c.p+"static/js/"+e+"."+{0:"63d3650fda518fa5d91a",1:"0ebe3ead93207dc78a78",2:"83213865379f03bc089c",3:"02f6ff10c5e83fdc830b",4:"83b134741cef8a1fc258",5:"61455822347fda4022ec",6:"7a4f7f41cea5405e209f",7:"b2a85a42ddd430235a63",8:"81460c8c66d06cfea732",9:"9c96ae683c51b04359d0",10:"638039a7b39908980436",11:"f27d1de28264fbbe30ff",12:"ccbc18453e41490e2dba",13:"b109164d2be44afb7733",14:"9825bb69e60b8030c230",15:"ffd723714f3c604ae809",16:"825722b083bcf8e5877e",17:"4786e13164b8fb55cf3b",18:"ebf8edd37453b58275c4",19:"237102ab58f0569908b0",20:"106676f1ed05cab7702b",21:"9811614945523e2ab002"}[e]+".js";var f=setTimeout(b,12e4);function b(){a.onerror=a.onload=null,clearTimeout(f);var n=t[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),t[e]=void 0)}return a.onerror=a.onload=b,o.appendChild(a),r},c.m=e,c.c=r,c.d=function(e,n,r){c.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},c.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(n,"a",n),n},c.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},c.p="./",c.oe=function(e){throw console.error(e),e}}([]);
\ No newline at end of file
...@@ -17,11 +17,14 @@ ...@@ -17,11 +17,14 @@
"element-ui": "^2.6.3", "element-ui": "^2.6.3",
"file-saver": "^1.3.8", "file-saver": "^1.3.8",
"html2canvas": "^1.0.0-alpha.12", "html2canvas": "^1.0.0-alpha.12",
"is-json": "^2.0.1",
"js-md5": "^0.7.3", "js-md5": "^0.7.3",
"jsoneditor": "^7.0.5",
"jspdf": "^1.5.3", "jspdf": "^1.5.3",
"qrcodejs2": "0.0.2", "qrcodejs2": "0.0.2",
"requset": "0.0.1-security", "requset": "0.0.1-security",
"script-loader": "^0.7.2", "script-loader": "^0.7.2",
"type-of-is": "^3.5.1",
"vue-clipboard2": "^0.2.0", "vue-clipboard2": "^0.2.0",
"xlsx": "^0.13.5" "xlsx": "^0.13.5"
}, },
...@@ -78,6 +81,7 @@ ...@@ -78,6 +81,7 @@
"vue-loader": "^13.3.0", "vue-loader": "^13.3.0",
"vue-style-loader": "^3.0.1", "vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2", "vue-template-compiler": "^2.5.2",
"vue2-ace-editor": "0.0.14",
"vuedraggable": "^2.17.0", "vuedraggable": "^2.17.0",
"webpack": "^3.6.0", "webpack": "^3.6.0",
"webpack-bundle-analyzer": "^2.9.0", "webpack-bundle-analyzer": "^2.9.0",
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @Author: 无尘 * @Author: 无尘
* @Date: 2019-08-07 18:01:05 * @Date: 2019-08-07 18:01:05
* @LastEditors: 无尘 * @LastEditors: 无尘
* @LastEditTime: 2019-09-29 12:35:55 * @LastEditTime: 2019-10-10 14:10:17
--> -->
<!-- <!--
<create-backend></create-backend> <create-backend></create-backend>
...@@ -323,6 +323,7 @@ export default { ...@@ -323,6 +323,7 @@ export default {
/* eslint-disable */ /* eslint-disable */
async handlebackData() { async handlebackData() {
const that = this; const that = this;
console.log(that.constData)
const paramKeys = [...Object.keys(that.constData.properties)]; const paramKeys = [...Object.keys(that.constData.properties)];
let returnFlag = await isRepeat(paramKeys); let returnFlag = await isRepeat(paramKeys);
if (returnFlag) { if (returnFlag) {
...@@ -505,6 +506,13 @@ export default { ...@@ -505,6 +506,13 @@ export default {
const that = this; const that = this;
that.apiInfoData = JSON.parse(JSON.stringify(that.$store.state.backInfo)); that.apiInfoData = JSON.parse(JSON.stringify(that.$store.state.backInfo));
that.constData = that.apiInfoData.constData; that.constData = that.apiInfoData.constData;
if (!that.apiInfoData.constData) {
that.constData = {
type: 'object',
level: 1,
properties: {}
}
}
} }
}, },
mounted() { mounted() {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* @Author: 无尘 * @Author: 无尘
* @Date: 2019-08-07 17:17:50 * @Date: 2019-08-07 17:17:50
* @LastEditors: 无尘 * @LastEditors: 无尘
* @LastEditTime: 2019-09-29 10:42:27 * @LastEditTime: 2019-10-11 12:54:16
--> -->
<!-- <!--
<create-base></create-base> <create-base></create-base>
...@@ -21,6 +21,22 @@ import createBase from '@/components/api/create-base.vue'; ...@@ -21,6 +21,22 @@ import createBase from '@/components/api/create-base.vue';
<el-option label="POST" value="POST"></el-option> <el-option label="POST" value="POST"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="导入参数" class="color-303133 font-w-700">
<!-- <el-radio-group v-model="importType" @change="changeImportType">
<el-radio-button label="1">导入json参数</el-radio-button>
<el-radio-button label="2">导入dubbo参数</el-radio-button>
</el-radio-group> -->
<div role="radiogroup" class="el-radio-group">
<label for="importJson" role="radio" tabindex="0" :class="['el-radio-button el-radio-button--large', importType == 1 ? 'is-active' : '']" @click="changeImportType(1)">
<input id="importJson" name="drone" type="radio" tabindex="-1" class="el-radio-button__orig-radio" value="1" />
<span class="el-radio-button__inner">导入json参数</span>
</label>
<label for="importDubbo" role="radio" tabindex="0" :class="['el-radio-button el-radio-button--large', importType == 2 ? 'is-active' : '']" @click="changeImportType(2)">
<input id="importDubbo" name="drone" type="radio" tabindex="-1" class="el-radio-button__orig-radio" value="2" />
<span class="el-radio-button__inner">导入dubbo参数</span>
</label>
</div>
</el-form-item>
<el-form-item label="参数配置" class="color-303133 font-w-700"> </el-form-item> <el-form-item label="参数配置" class="color-303133 font-w-700"> </el-form-item>
<el-form-item label="参数位置:"> <el-form-item label="参数位置:">
<div class="font-14 color-303133">header</div> <div class="font-14 color-303133">header</div>
...@@ -89,6 +105,8 @@ import createBase from '@/components/api/create-base.vue'; ...@@ -89,6 +105,8 @@ import createBase from '@/components/api/create-base.vue';
<el-button type="primary" @click="submitForm('baseForm')">下一步</el-button> <el-button type="primary" @click="submitForm('baseForm')">下一步</el-button>
</el-form-item> </el-form-item>
</el-form> </el-form>
<import-dubbo :showDialog="showDialog" @hideDialog="hideDialog"> </import-dubbo>
<web-editor :showJsonDialog="showJsonDialog" @hideJsonDialog="hideJsonDialog"> </web-editor>
</div> </div>
</template> </template>
<script> <script>
...@@ -96,6 +114,8 @@ import limitTextarea from '@/components/limit-textarea.vue'; ...@@ -96,6 +114,8 @@ import limitTextarea from '@/components/limit-textarea.vue';
import limitInput from '@/components/limit-input.vue'; import limitInput from '@/components/limit-input.vue';
import headerParam from '@/components/createApi/header-param.vue'; import headerParam from '@/components/createApi/header-param.vue';
import bodyParam from '@/components/createApi/body-param.vue'; import bodyParam from '@/components/createApi/body-param.vue';
import importDubbo from '@/components/createApi/import-dubbo.vue';
import webEditor from '@/components/createApi/web-editor.vue';
import showMsg from '@/assets/js/showmsg'; import showMsg from '@/assets/js/showmsg';
import { isRepeat } from '@/assets/js/public'; import { isRepeat } from '@/assets/js/public';
export default { export default {
...@@ -104,11 +124,15 @@ export default { ...@@ -104,11 +124,15 @@ export default {
limitTextarea, limitTextarea,
limitInput, limitInput,
headerParam, headerParam,
bodyParam bodyParam,
importDubbo,
webEditor
}, },
data() { data() {
return { return {
importType: '',
showDialog: false,
apiInfoData: { apiInfoData: {
protocol: 'http', protocol: 'http',
requestType: 'GET', requestType: 'GET',
...@@ -119,6 +143,11 @@ export default { ...@@ -119,6 +143,11 @@ export default {
bodyJsonData: {}, bodyJsonData: {},
bodyFormData: {} bodyFormData: {}
}, },
// 导入 dubbo
dubboData: {
apiPackage: '',
method: ''
},
// header // header
headerData: { headerData: {
type: 'object', type: 'object',
...@@ -220,10 +249,106 @@ export default { ...@@ -220,10 +249,106 @@ export default {
}, },
rules: { rules: {
requestType: [{ required: true, message: '请选择请求方法', trigger: 'blur' }] requestType: [{ required: true, message: '请选择请求方法', trigger: 'blur' }]
} },
// 导入json
showJsonDialog: false
}; };
}, },
methods: { methods: {
/**
* 修改导入类型
*/
changeImportType(e) {
const that = this;
that.importType = e;
if (e == '2') {
that.showDialog = true;
} else {
// that.showJsonDialog = true;
}
},
/**
* dubbo 选择返回
*/
hideDialog(data, dubboData) {
const that = this;
that.showDialog = false;
that.dubboData = dubboData;
if (!data) {
return false;
}
that.handleFrontData(JSON.parse(data));
},
/**
* json 选择后返回
*/
hideJsonDialog(data, type) {
const that = this;
that.showJsonDialog = false;
if (!data) {
return false;
}
if (type == 'first') {
// json
} else {
// jsonschema
}
},
// 前端通用数据处理
handleQuery(allData, type) {
const that = this;
let newObj = {
type: 'object',
level: 1,
properties: {},
required: []
};
for (let key in allData.properties) {
if (allData.properties[key].frontOriginType == type) {
that.$set(newObj.properties, allData.properties[key].currentKey, allData.properties[key]);
}
}
return newObj;
},
/**
* 处理dubbo数据
*/
async handleFrontData(data) {
const that = this;
let allData = JSON.parse(JSON.stringify(data));
that.queryData = await that.handleQuery(allData, 'query');
that.headerData = await that.handleQuery(allData, 'header');
that.bodyFormData = await that.handleQuery(allData, 'form');
that.bodyJsonData = await that.handleQuery(allData, 'body');
// 如果返回没有 bodyRoot,需要添加默认的
let bodyJsonData = {
type: 'object',
level: 1,
properties: {
bodyRoot: {
level: 2,
currentKey: 'bodyRoot',
frontOriginType: 'body', //来源类型 query,body,header
backendOriginType: 'body',
type: 'object',
isBackendField: 0, //是否后端字段
defaultVal: '', //默认值
isRootKey: 0, //是否是后端参数字段
isRootKeyFlag: false, // 禁用标志
rootKey: '', //后端参数字段
objectClass: '', //如果是object 并且是dubbo
description: '描述',
example: '示例',
check: true,
properties: {}
}
},
required: []
};
if (!Object.keys(that.bodyJsonData.properties).length) {
that.bodyJsonData = bodyJsonData;
}
},
refreshData(data) { refreshData(data) {
const that = this; const that = this;
that.frontData = data; that.frontData = data;
...@@ -250,6 +375,7 @@ export default { ...@@ -250,6 +375,7 @@ export default {
}); });
}, },
/* eslint-disable */
async handleData() { async handleData() {
const that = this; const that = this;
// 判断参数重复 // 判断参数重复
...@@ -262,6 +388,14 @@ export default { ...@@ -262,6 +388,14 @@ export default {
showMsg.showmsg('参数名重复', 'warning'); showMsg.showmsg('参数名重复', 'warning');
return false; return false;
} }
// 如果有选导入 dubbo 数据
if (that.importType == 2 && that.dubboData.apiPackage != '' && that.dubboData.method != '') {
let apiBack = JSON.parse(JSON.stringify(that.$store.state.backInfo));
apiBack.dubboInterface = that.dubboData.apiPackage;
apiBack.dubboMethod = that.dubboData.method;
apiBack.interfaceType = '1';
that.$store.dispatch('saveBackInfo', apiBack);
}
if (that.apiInfoData.requestType == 'POST' && that.apiInfoData.frontBodyType == 'json') { if (that.apiInfoData.requestType == 'POST' && that.apiInfoData.frontBodyType == 'json') {
if (Object.keys(that.bodyJsonData.properties.bodyRoot.properties).length) { if (Object.keys(that.bodyJsonData.properties.bodyRoot.properties).length) {
......
<!--
* @Descripttion: 当前组件信息
* @version: 1.0.0
* @Author: 无尘
* @Date: 2019-10-09 16:04:09
* @LastEditors: 无尘
* @LastEditTime: 2019-10-11 11:48:36
-->
<!--
<web-editor
:showJsonDialog="showJsonDialog"
@hideJsonDialog="hideJsonDialog">
</web-editor>
import webEditor from '@/components/createApi/web-editor.vue'
-->
<template>
<div v-show="customDialog">
<el-dialog class="edit-dialog" title="导入json" :visible.sync="customDialog" width="600px" :before-close="handleClose">
<div class="edit-dialog-body">
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="JSON" name="first">
<editor ref="myEditorJson" v-model="contentJson" @init="editorInit" lang="javascript" theme="chrome" width="500" height="300"></editor>
</el-tab-pane>
<el-tab-pane label="JSON-SCHEMA" name="second">
<editor ref="myEditorJsonSchema" v-model="contentJsonSchema" @init="editorInit" lang="javascript" theme="chrome" width="500" height="300"></editor>
</el-tab-pane>
</el-tabs>
</div>
<div slot="footer" class="dialog-footer" style="padding-bottom: 10px;">
<el-button @click="customCancel">取消</el-button>
<el-button type="primary" @click="customConfirm('importForm')">确定</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
/* eslint-disable */
import { getRequest } from '@/api/api';
import showMsg from '@/assets/js/showmsg';
import errMsg from '@/assets/js/error';
import { _debounce } from '@/assets/js/public';
import isJSON from 'is-json';
export default {
name: 'import-dubbo',
props: {
showJsonDialog: {
type: Boolean,
default: false
}
},
components: {
editor: require('vue2-ace-editor'),
},
data() {
return {
customDialog: false, // 弹框显示
activeName: 'first',
contentJson: '',
contentJsonSchema:''
};
},
methods: {
/**
* 关闭
*/
handleClose(done) {
const that = this;
done();
that.hideDialog();
},
/**
* 取消
*/
customCancel() {
const that = this;
that.hideDialog();
},
hideDialog() {
const that = this;
that.customDialog = false;
that.$emit('hideJsonDialog', '');
},
/**
* 确定
*/
customConfirm(formName) {
const that = this;
if (that.activeName == 'first' && !isJSON(that.contentJson)) {
showMsg.showmsg('json 数据格式有误', 'warning');
return false;
}
if (that.activeName == 'second' && (!isJSON(that.contentJsonSchema) || Array.isArray(JSON.parse(that.contentJsonSchema)))) {
showMsg.showmsg('JSON-SCHEMA 数据格式有误', 'warning');
return false;
}
const emitData = {
}//that.activeName == 'first' ? that.contentJson : that.contentJsonSchema;
// 第一种情况: json----obj
if (that.activeName == 'first' && Object.prototype.toString.call(JSON.parse(that.contentJson)) == '[object Object]') {
}
// 第二种情况: json----array
if (that.activeName == 'first') {
}
// 第三种情况: jsonschema----obj
if (that.activeName == 'second') {
}
// 处理json 和jsonschema
that.$nextTick(() => {
that.$emit('hideJsonDialog', emitData, that.activeName);
})
},
editorInit: function (editor) {
require('brace/ext/language_tools') //language extension prerequsite...
require('brace/mode/html')
require('brace/mode/json')
require('brace/mode/javascript') //language
require('brace/mode/less')
require('brace/theme/chrome')
require('brace/snippets/javascript') //snippet
// editor.getSession().setMode("brace/mode/json")
}
},
watch: {
showJsonDialog: function(newData, oldData) {
const that = this;
that.customDialog = newData;
}
},
/* 接收数据 */
mounted() {
const that = this;
that.customDialog = that.showJsonDialog;
}
};
</script>
<style lang="less" scoped>
.edit-dialog {
/deep/ .el-dialog__body {
padding: 2px 55px 0 34px;
}
/deep/ .el-dialog__footer {
border: none;
padding-top: 3px;
}
&__title {
width: 100%;
height: 38px;
padding: 12px 15px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
background: rgba(235, 238, 245, 1);
}
.el-alert--info {
width: 400px;
font-size: 14px;
color: #606266;
background: #e6f7ff;
border: 1px solid rgba(145, 213, 255, 1);
}
.el-icon-info {
width: 12px;
font-size: 12px;
color: #1890ff;
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment