diff --git a/src/locales/en-US.json b/src/locales/en-US.json index f248c0fef..a4f2f231a 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -259,23 +259,23 @@ "SHENYU.DIC.INPUTNAME": "DictionaryName", "SHENYU.PERMISSION.EMPTY": "The role of the login user is not configured with menu permissions", - "SHENYU.BUTTON.PLUGIN.RULE.ADD": "addRule", - "SHENYU.BUTTON.PLUGIN.RULE.DELETE": "deleteRule", - "SHENYU.BUTTON.PLUGIN.RULE.EDIT": "editRule", - "SHENYU.BUTTON.PLUGIN.RULE.QUERY": "queryRule", - "SHENYU.BUTTON.PLUGIN.SELECTOR.ADD": "addSelector", - "SHENYU.BUTTON.PLUGIN.SELECTOR.DELETE": "deleteSelector", - "SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT": "editSelector", - "SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY": "querySelector", - "SHENYU.BUTTON.PLUGIN.SYNCHRONIZE": "synchronizeData", - "SHENYU.BUTTON.SYSTEM.ADD": "add", - "SHENYU.BUTTON.SYSTEM.LIST": "query", - "SHENYU.BUTTON.SYSTEM.DELETE": "delete", - "SHENYU.BUTTON.SYSTEM.EDIT": "modify", - "SHENYU.BUTTON.SYSTEM.SYNCHRONIZE": "synchronize", - "SHENYU.BUTTON.SYSTEM.ENABLE": "enable", - "SHENYU.BUTTON.SYSTEM.EDITRESOURCEDETAILS": "editDetails", - "SHENYU.BUTTON.SYSTEM.RESOURCE": "resource", + "SHENYU.BUTTON.PLUGIN.RULE.ADD": "AddRule", + "SHENYU.BUTTON.PLUGIN.RULE.DELETE": "DeleteRule", + "SHENYU.BUTTON.PLUGIN.RULE.EDIT": "EditRule", + "SHENYU.BUTTON.PLUGIN.RULE.QUERY": "QueryRule", + "SHENYU.BUTTON.PLUGIN.SELECTOR.ADD": "AddSelector", + "SHENYU.BUTTON.PLUGIN.SELECTOR.DELETE": "DeleteSelector", + "SHENYU.BUTTON.PLUGIN.SELECTOR.EDIT": "EditSelector", + "SHENYU.BUTTON.PLUGIN.SELECTOR.QUERY": "QuerySelector", + "SHENYU.BUTTON.PLUGIN.SYNCHRONIZE": "SynchronizeData", + "SHENYU.BUTTON.SYSTEM.ADD": "Add", + "SHENYU.BUTTON.SYSTEM.LIST": "Query", + "SHENYU.BUTTON.SYSTEM.DELETE": "Delete", + "SHENYU.BUTTON.SYSTEM.EDIT": "Modify", + "SHENYU.BUTTON.SYSTEM.SYNCHRONIZE": "Synchronize", + "SHENYU.BUTTON.SYSTEM.ENABLE": "Enable", + "SHENYU.BUTTON.SYSTEM.EDITRESOURCEDETAILS": "EditDetails", + "SHENYU.BUTTON.SYSTEM.RESOURCE": "Resource", "SHENYU.BUTTON.DATA.PERMISSION.CONFIG": "ConfigureDataPermission", "SHENYU.MESSAGE.SESSION.INVALID": "Session is invalid", "SHENYU.MESSAGE.SESSION.RELOGIN": "Please login in again", @@ -319,23 +319,24 @@ "SHENYU.DOCUMENT.APIDOC.CONTENTS.TO.BE.SIGNED": "Contents To Be Signed", "SHENYU.DOCUMENT.APIDOC.SIGNATURE": "Signature", "SHENYU.DOCUMENT.APIDOC.ERROR.CODE.DETAILS": "Error Code Details", - "SHENYU.DOCUMENT.APIDOC.CONTEXTPATH": "contextPath", - "SHENYU.DOCUMENT.APIDOC.APIPATH": "apiPath", - "SHENYU.DOCUMENT.APIDOC.HTTPMETHOD": "httpMethod", - "SHENYU.DOCUMENT.APIDOC.CONSUME": "consume", - "SHENYU.DOCUMENT.APIDOC.PRODUCE": "produce", - "SHENYU.DOCUMENT.APIDOC.VERSION": "version", - "SHENYU.DOCUMENT.APIDOC.RPCTYPE": "rpcType", - "SHENYU.DOCUMENT.APIDOC.STATE": "state", - "SHENYU.DOCUMENT.APIDOC.EXT": "ext", - "SHENYU.DOCUMENT.APIDOC.APIOWNER": "apiOwner", - "SHENYU.DOCUMENT.APIDOC.APIDESC": "apiDesc", - "SHENYU.DOCUMENT.APIDOC.APISOURCE": "apiSource", - "SHENYU.DOCUMENT.APIDOC.DOCUMENT": "document", - "SHENYU.DOCUMENT.TAG.NAME": "name", - "SHENYU.DOCUMENT.TAG.DESC": "tagDesc", - "SHENYU.DOCUMENT.TAG.PARENT.ID": "parentTagId", - "SHENYU.DOCUMENT.TAG.ext": "ext", + "SHENYU.DOCUMENT.APIDOC.CONTEXTPATH": "Context Path", + "SHENYU.DOCUMENT.APIDOC.APIPATH": "Api Path", + "SHENYU.DOCUMENT.APIDOC.HTTPMETHOD": "Http Method", + "SHENYU.DOCUMENT.APIDOC.CONSUME": "Consume", + "SHENYU.DOCUMENT.APIDOC.PRODUCE": "Produce", + "SHENYU.DOCUMENT.APIDOC.VERSION": "Version", + "SHENYU.DOCUMENT.APIDOC.RPCTYPE": "Rpc Type", + "SHENYU.DOCUMENT.APIDOC.STATE": "State", + "SHENYU.DOCUMENT.APIDOC.EXT": "Extent Param", + "SHENYU.DOCUMENT.APIDOC.EXT.INFO": "Extend param content need json format", + "SHENYU.DOCUMENT.APIDOC.APIOWNER": "Api Owner", + "SHENYU.DOCUMENT.APIDOC.APIDESC": "Api Desc", + "SHENYU.DOCUMENT.APIDOC.APISOURCE": "Api Source", + "SHENYU.DOCUMENT.APIDOC.DOCUMENT": "Document", + "SHENYU.DOCUMENT.TAG.NAME": "Tag Name", + "SHENYU.DOCUMENT.TAG.DESC": "Tag Desc", + "SHENYU.DOCUMENT.TAG.PARENT.ID": "ParentTagId", + "SHENYU.DOCUMENT.TAG.ext": "Ext", "SHENYU.COMMON.REQUIRED": "Required", "SHENYU.COMMON.MAX.LENGTH": "Max Length", "SHENYU.COMMON.MAX.EXAMPLE": "Example", diff --git a/src/locales/zh-CN.json b/src/locales/zh-CN.json index 798a6f352..c8a69f1f5 100644 --- a/src/locales/zh-CN.json +++ b/src/locales/zh-CN.json @@ -307,17 +307,18 @@ "SHENYU.DOCUMENT.APIDOC.SIGNATURE": "签名(sign)", "SHENYU.DOCUMENT.APIDOC.ERROR.CODE.DETAILS": "错误代码", "SHENYU.DOCUMENT.APIDOC.CONTEXTPATH": "上下文路径", - "SHENYU.DOCUMENT.APIDOC.APIPATH": "api路径", - "SHENYU.DOCUMENT.APIDOC.HTTPMETHOD": "http方法", + "SHENYU.DOCUMENT.APIDOC.APIPATH": "Api路径", + "SHENYU.DOCUMENT.APIDOC.HTTPMETHOD": "Http方法", "SHENYU.DOCUMENT.APIDOC.CONSUME": "消费", "SHENYU.DOCUMENT.APIDOC.PRODUCE": "生产", "SHENYU.DOCUMENT.APIDOC.VERSION": "版本", - "SHENYU.DOCUMENT.APIDOC.RPCTYPE": "rpc类型", + "SHENYU.DOCUMENT.APIDOC.RPCTYPE": "Rpc类型", "SHENYU.DOCUMENT.APIDOC.STATE": "状态", - "SHENYU.DOCUMENT.APIDOC.EXT": "ext", - "SHENYU.DOCUMENT.APIDOC.APIOWNER": "api持有者", - "SHENYU.DOCUMENT.APIDOC.APIDESC": "api描述", - "SHENYU.DOCUMENT.APIDOC.APISOURCE": "api来源", + "SHENYU.DOCUMENT.APIDOC.EXT": "扩展参数", + "SHENYU.DOCUMENT.APIDOC.EXT.INFO": "扩展参数需要为JSON格式", + "SHENYU.DOCUMENT.APIDOC.APIOWNER": "Api持有者", + "SHENYU.DOCUMENT.APIDOC.APIDESC": "Api描述", + "SHENYU.DOCUMENT.APIDOC.APISOURCE": "Api来源", "SHENYU.DOCUMENT.APIDOC.DOCUMENT": "文档说明", "SHENYU.DOCUMENT.TAG.NAME": "标签名称", "SHENYU.DOCUMENT.TAG.DESC": "标签描述", diff --git a/src/routes/Document/components/AddAndUpdateApiDoc.js b/src/routes/Document/components/AddAndUpdateApiDoc.js index 06083b7be..ffca196b0 100644 --- a/src/routes/Document/components/AddAndUpdateApiDoc.js +++ b/src/routes/Document/components/AddAndUpdateApiDoc.js @@ -62,15 +62,29 @@ class AddAndUpdateApiDoc extends Component { formLoaded?.(form); } + handleSubmit = () => { const { form, onOk } = this.props; form.validateFieldsAndScroll(async (err, values) => { + function isJsonStr(str) { + try { + let obj = JSON.parse(str); + return !!(typeof obj === 'object' && obj); + } catch(e) { + return false; + } + } if (!err) { const { id } = values; let res = {}; values.state = parseInt(values.state); values.apiSource = parseInt(values.apiSource); values.httpMethod = parseInt(values.httpMethod); + // validate ext + if (!isJsonStr(values.ext)) { + message.error(getIntlContent("SHENYU.DOCUMENT.APIDOC.EXT.INFO")); + return; + } if (!id) { res = await addApi({ ...values @@ -103,7 +117,7 @@ class AddAndUpdateApiDoc extends Component { version = "", rpcType = "", state = "", - ext = "", + ext = "{}", apiOwner = "", apiDesc = "", apiSource = "", @@ -113,10 +127,10 @@ class AddAndUpdateApiDoc extends Component { const { getFieldDecorator } = form; const formItemLayout = { labelCol: { - sm: { span: 5 } + sm: { span: 6 } }, wrapperCol: { - sm: { span: 19 } + sm: { span: 18 } } }; @@ -290,7 +304,7 @@ class AddAndUpdateApiDoc extends Component { ); })} - + )} @@ -302,13 +316,14 @@ class AddAndUpdateApiDoc extends Component { rules: [ { required: true, - message: getIntlContent("SHENYU.DOCUMENT.APIDOC.EXT") + message: getIntlContent("SHENYU.DOCUMENT.APIDOC.EXT.INFO") } ], initialValue: ext })( )}