Commit e5d00b04 by 无尘

fix: 修改文档中心

parent 968657d9
<!DOCTYPE html><html><head><meta charset=utf-8><link rel="shortcut icon" href=./favicon.ico><title>达摩开放平台</title><link href=./static/css/app.70985527784af3c07404e768ccc695a1.css rel=stylesheet></head><body class=damolish><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 type=text/javascript src=./static/js/manifest.bc6a12e54a4187c47e8e.js></script><script type=text/javascript src=./static/js/vendor.2b107cdd6cec563c6dab.js></script><script type=text/javascript src=./static/js/app.1129bfcdd6c254304c01.js></script></body></html> <!DOCTYPE html><html><head><meta charset=utf-8><link rel="shortcut icon" href=./favicon.ico><title>达摩开放平台</title><link href=./static/css/app.cc2bc184d68d1ee4d6932c5a50710c98.css rel=stylesheet></head><body class=damolish><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 type=text/javascript src=./static/js/manifest.362580376b1deeb5f7ed.js></script><script type=text/javascript src=./static/js/vendor.0f5b275d4a227ad49647.js></script><script type=text/javascript src=./static/js/app.9c50334119061bcb2895.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.
!function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,a,c){for(var f,i,u,d=0,s=[];d<r.length;d++)i=r[d],t[i]&&s.push(t[i][0]),t[i]=0;for(f in a)Object.prototype.hasOwnProperty.call(a,f)&&(e[f]=a[f]);for(n&&n(r,a,c);s.length;)s.shift()();if(c)for(d=0;d<c.length;d++)u=o(o.s=c[d]);return u};var r={},t={13: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 a=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.charset="utf-8",c.async=!0,c.timeout=12e4,o.nc&&c.setAttribute("nonce",o.nc),c.src=o.p+"static/js/"+e+"."+{0:"dc5820857959176b1da4",1:"0ebe3ead93207dc78a78",2:"78f59f0e37cbd9544576",3:"953747746c3caf71cd86",4:"2ff0ba051a42a51dbec4",5:"55627a5270057a1d7660",6:"4a571dddcc1a56031102",7:"3b027583d4af17e36af0",8:"5e787f5eb2f4bd7cfb7b",9:"9caad4c0ba5b8b4813ee",10:"63807a09986add449f8a"}[e]+".js";var f=setTimeout(i,12e4);function i(){c.onerror=c.onload=null,clearTimeout(f);var n=t[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),t[e]=void 0)}return c.onerror=c.onload=i,a.appendChild(c),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}}([]); !function(e){var n=window.webpackJsonp;window.webpackJsonp=function(r,a,c){for(var f,d,i,u=0,s=[];u<r.length;u++)d=r[u],t[d]&&s.push(t[d][0]),t[d]=0;for(f in a)Object.prototype.hasOwnProperty.call(a,f)&&(e[f]=a[f]);for(n&&n(r,a,c);s.length;)s.shift()();if(c)for(u=0;u<c.length;u++)i=o(o.s=c[u]);return i};var r={},t={13: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 a=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.charset="utf-8",c.async=!0,c.timeout=12e4,o.nc&&c.setAttribute("nonce",o.nc),c.src=o.p+"static/js/"+e+"."+{0:"dc5820857959176b1da4",1:"0ebe3ead93207dc78a78",2:"78f59f0e37cbd9544576",3:"953747746c3caf71cd86",4:"4548fd42b2f176f8de1d",5:"a86d1b66fe77d729cd77",6:"737da25334f9daa2d713",7:"3b027583d4af17e36af0",8:"5e787f5eb2f4bd7cfb7b",9:"9caad4c0ba5b8b4813ee",10:"63807a09986add449f8a"}[e]+".js";var f=setTimeout(d,12e4);function d(){c.onerror=c.onload=null,clearTimeout(f);var n=t[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),t[e]=void 0)}return c.onerror=c.onload=d,a.appendChild(c),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 \ 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.
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
}, },
"dependencies": { "dependencies": {
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"element-ui": "^2.6.3", "element-ui": "^2.11.1",
"file-saver": "^1.3.8", "file-saver": "^1.3.8",
"html2canvas": "^1.0.0-alpha.12", "html2canvas": "^1.0.0-alpha.12",
"js-md5": "^0.7.3", "js-md5": "^0.7.3",
......
...@@ -95,3 +95,28 @@ export function isRepeat(arr) { ...@@ -95,3 +95,28 @@ export function isRepeat(arr) {
} }
return false; return false;
} }
// json <---> jsonSchema
// 如果传入的是对象,处理对象,返回结果
export function processObject(object, output, nested) {
let arr = [];
for (let key in object.properties) {
let value = object.properties[key]; // 拿到相当于数组的一列数据
// 如果这一行数据的 type 是 object
if (value.type == 'object' && Object.keys(value.properties).length) {
value.children = [];
value.children = processObject(value);
arr.push(value);
continue;
}
// 如果这一行数据的 type 是 array
if (value.type == 'array' && Object.keys(value.items.properties).length) {
value.children = [];
value.children = processObject(value.items);
arr.push(value);
continue;
}
arr.push(value);
}
return arr;
}
<!--
公共api详情
<api-detail :apiData="apiData" v-model=""></api-detail>
import apiDetail from '@/components/openPlatform/api-detail.vue'
components: {
apiDetail
},
-->
<template>
<div class="api-detail-wrap">
<div class="api-detail-h2">{{ menuItemData.interfaceName }}(v{{ menuItemData.version }}</div>
<div class="api-detail-descripe">
<el-input disabled type="textarea" resize="none" :rows="3" placeholder="请输入内容" v-model="menuItemData.interfaceDescribe" @blur="changeValue"> </el-input>
</div>
<div class="api-url m-t-16">
<div class="api-detail-p">请求地址:{{ menuItemData.interfaceUrl }}</div>
</div>
<div class="api-method m-b-10 m-t-10">
<div class="api-detail-p">请求方法:{{ menuItemData.requestType }}</div>
</div>
<div class="api-request-param m-t-10">
<div class="api-detail-h3 m-b-10">请求参数:</div>
<div>
<el-table :data="menuItemData.frontParams" row-key="currentKey" style="width: 100%;margin-bottom: 20px;" border default-expand-all :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
<el-table-column prop="currentKey" label="名称"> </el-table-column>
<el-table-column prop="type" label="类型"> </el-table-column>
<el-table-column prop="example" label="示例值"> </el-table-column>
<el-table-column prop="description" label="描述"> </el-table-column>
</el-table>
</div>
</div>
<div class="api-response-param">
<div class="api-detail-h3 m-b-10 m-t-27">响应参数:</div>
<div>
<el-table :data="menuItemData.resultParams" row-key="currentKey" style="width: 100%;margin-bottom: 20px;" border default-expand-all :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
<el-table-column prop="currentKey" label="名称"> </el-table-column>
<el-table-column prop="type" label="类型"> </el-table-column>
<el-table-column prop="example" label="示例值"> </el-table-column>
<el-table-column prop="description" label="描述"> </el-table-column>
</el-table>
</div>
</div>
<div class="api-request-demo" v-if="false">
<div class="api-detail-h3 m-b-10 m-t-27">请求示例:</div>
<div class="api-demo-text">
<pre>{{ menuItemData }}</pre>
</div>
</div>
<div class="api-response-success">
<div class="api-detail-h3 m-b-10 m-t-27">成功响应示例:</div>
<div class="api-demo-text">
<pre>{{ menuItemData.sucReturn }}</pre>
</div>
</div>
<div class="api-response-error">
<div class="api-detail-h3 m-b-10 m-t-27">失败响应示例:</div>
<div class="api-demo-text">
<pre>{{ menuItemData.errReturn }}</pre>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
value: {
type: String,
default() {
return '';
}
},
apiData: {
type: [Object, Array],
default() {
return {};
}
}
},
data() {
return {
menuItemData: this.apiData,
describeValue: this.value
};
},
methods: {
changeValue(e) {
const that = this;
that.$emit('input', that.describeValue);
}
},
watch: {
value(newData, oldDate) {
this.describeValue = newData;
/* eslint-disable */
console.log(this.apiData, this.value, newData);
},
apiData(newData, oldDate) {
this.menuItemData = newData;
/* eslint-disable */
console.log(this.apiData, this.menuItemData, newData);
}
},
mounted() {
const that = this;
that.$nextTick(() => {
that.menuItemData = that.apiData;
that.describeValue = that.value;
/* eslint-disable */
console.log(that.apiData, that.value);
});
}
};
</script>
<style lang="less" scoped>
.m-t-27 {
margin-top: 27px;
}
.m-t-16 {
margin-top: 16px;
}
.api-detail-wrap {
.api-detail-h2 {
height: 55px;
line-height: 55px;
font-size: 16px;
color: #303133;
font-weight: 600;
}
.api-detail-p {
font-size: 14px;
line-height: 14px;
color: #606266;
}
.api-detail-h3 {
font-size: 14px;
line-height: 14px;
color: #303133;
font-weight: 600;
}
.api-demo-text {
height: 142px;
padding: 10px 12px;
overflow-y: auto;
font-size: 14px;
color: #606266;
border: 1px solid #dcdfe6;
}
}
</style>
<!--
公共api详情
<error-code-table :errorCodeData="errorCodeData"></error-code-table>
import errorCodeTable from '@/components/error-code-table.vue'
components: {
errorCode
},
-->
<template>
<div class="error-code-wrap">
<el-table :data="errorCodeData" style="width: 100%">
<el-table-column prop="errorCode" label="错误码"> </el-table-column>
<el-table-column prop="errorInfo" label="错误信息" show-overflow-tooltip> </el-table-column>
</el-table>
</div>
</template>
<script>
export default {
props: {
errorCodeData: {
type: [Object, Array],
default() {
return {};
}
}
},
data() {
return {};
}
};
</script>
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<div class="open-header-right border-box"> <div class="open-header-right border-box">
<div class="open-header-right_wrap flex flex-space-between"> <div class="open-header-right_wrap flex flex-space-between">
<ul class="flex"> <ul class="flex">
<li v-for="(item, index) in openMenuData" :key="index + 'menu'" :class="['menu-li border-box', currentTab == item.menuId ? 'active-tab' : '']" @click.stop.prevent="toRedirect(item)"> <li v-for="(item, index) in openMenuData" :key="index + 'menu'" :class="['menu-li border-box', currentMenuTab == item.menuId ? 'active-tab' : '']" @click.stop.prevent="toRedirect(item)">
<span>{{ item.menuName }}</span> <span>{{ item.menuName }}</span>
</li> </li>
</ul> </ul>
...@@ -35,6 +35,7 @@ export default { ...@@ -35,6 +35,7 @@ export default {
}, },
data() { data() {
return { return {
currentMenuTab: this.currentTab,
openMenuData: [ openMenuData: [
{ {
menuId: '2', menuId: '2',
...@@ -68,12 +69,16 @@ export default { ...@@ -68,12 +69,16 @@ export default {
}, },
// 深度观察监听 // 深度观察监听
deep: true deep: true
},
currentTab(newData, oldData) {
const that = this;
that.currentMenuTab = newData;
} }
}, },
/* 接收数据 */ /* 接收数据 */
mounted() { mounted() {
var that = this; const that = this;
that.pathName = that.$route.path; that.currentMenuTab = that.$route.query.currentTab || '2';
} }
}; };
</script> </script>
......
...@@ -66,7 +66,7 @@ export default { ...@@ -66,7 +66,7 @@ export default {
parentId: this.currentTab, // 1:解决方案,2:开发者接入 parentId: this.currentTab, // 1:解决方案,2:开发者接入
activeId: '', activeId: '',
menuData: [ menuData: [
{ /* {
level: 1, level: 1,
memo: '嗷呜', memo: '嗷呜',
menuId: '44498258223366144', menuId: '44498258223366144',
...@@ -79,53 +79,8 @@ export default { ...@@ -79,53 +79,8 @@ export default {
subType: 1, subType: 1,
updateFlag: 1, updateFlag: 1,
expanded: false, // 新增展开 expanded: false, // 新增展开
children: [ children: []
{ } */
level: 2,
memo: '嗷呜',
menuId: '444982582233661446',
menuName: '第四个关联了api128',
operator: '10',
operatorName: '蘑菇',
parentId: '1',
relationData: '',
seq: 0,
subType: 1,
updateFlag: 1,
expanded: false, // 新增展开
children: [
{
level: 3,
memo: '嗷呜',
menuId: '4449825822336614646',
menuName: '第四个关联了api128',
operator: '10',
operatorName: '蘑菇',
parentId: '1',
relationData: '',
seq: 0,
subType: 1,
updateFlag: 1,
expanded: false // 新增展开
}
]
}
]
},
{
level: 1,
memo: '嗷呜',
menuId: '111825822336614646',
menuName: '第四个关联了api128',
operator: '10',
operatorName: '蘑菇',
parentId: '1',
relationData: '',
seq: 0,
subType: 1,
updateFlag: 1,
expanded: false // 新增展开
}
] ]
}; };
}, },
...@@ -143,7 +98,7 @@ export default { ...@@ -143,7 +98,7 @@ export default {
that.$emit('changeDoc', {}); that.$emit('changeDoc', {});
} else { } else {
// 没有子级先加载看看是否有子级 // 没有子级先加载看看是否有子级
that.getMenuData(item.menuId, item); that.$emit('changeDoc', item);
} }
}, },
getMenuData(parentId, node) { getMenuData(parentId, node) {
...@@ -158,10 +113,9 @@ export default { ...@@ -158,10 +113,9 @@ export default {
if (!!resData.result && resData.result.length) { if (!!resData.result && resData.result.length) {
resData.result.forEach(ele => { resData.result.forEach(ele => {
ele.expanded = false; ele.expanded = false;
ele.children = [];
}); });
} }
if (node) { /* if (node) {
node.children = resData.result || []; node.children = resData.result || [];
that.$forceUpdate(); that.$forceUpdate();
return false; return false;
...@@ -170,7 +124,7 @@ export default { ...@@ -170,7 +124,7 @@ export default {
if (node && !resData.result.length) { if (node && !resData.result.length) {
that.$emit('changeDoc', node); that.$emit('changeDoc', node);
return false; return false;
} } */
that.menuData = resData.result || []; that.menuData = resData.result || [];
return; return;
} }
...@@ -192,7 +146,7 @@ export default { ...@@ -192,7 +146,7 @@ export default {
}, },
mounted() { mounted() {
const that = this; const that = this;
that.parentId = that.currentTab; that.parentId = that.$route.query.currentTab || '2';
that.getMenuData(that.parentId); that.getMenuData(that.parentId);
} }
}; };
......
<template> <template>
<div class="document-right"> <div class="document-right">
<div class="document-right-body border-box"></div> <div class="document-right-body border-box">
<!-- 内容 -->
<div class="article-contain" v-if="formData.content">
<div class="markdown-content" v-html="formData.content"></div>
</div>
<!-- api -->
<api-detail v-if="Object.keys(apiData).length" :apiData="apiData"></api-detail>
<!-- 错误码 -->
<error-code-table v-if="errorCodeData.length" :errorCodeData="errorCodeData"></error-code-table>
</div>
<open-doc-footer></open-doc-footer> <open-doc-footer></open-doc-footer>
</div> </div>
</template> </template>
<script> <script>
import openDocFooter from '@/components/open-doc-footer.vue'; import openDocFooter from '@/components/open-doc-footer.vue';
import errorCodeTable from '@/components/error-code-table.vue';
import apiDetail from '@/components/api-detail.vue';
import { getArtical, getApi, getErrorCode } from '@/api/document'; import { getArtical, getApi, getErrorCode } from '@/api/document';
import errMsg from '@/assets/js/error'; import errMsg from '@/assets/js/error';
import { processObject } from '@/assets/js/public';
import marked from 'marked';
export default { export default {
props: { props: {
currentDoc: { currentDoc: {
...@@ -18,7 +31,9 @@ export default { ...@@ -18,7 +31,9 @@ export default {
} }
}, },
components: { components: {
openDocFooter openDocFooter,
errorCodeTable,
apiDetail
}, },
data() { data() {
return { return {
...@@ -37,7 +52,7 @@ export default { ...@@ -37,7 +52,7 @@ export default {
let para = {}; let para = {};
getErrorCode(para) getErrorCode(para)
.then(res => { .then(res => {
let resData = res; let resData = res.data;
if (resData.code == '0000') { if (resData.code == '0000') {
that.errorCodeData = resData.result; that.errorCodeData = resData.result;
return; return;
...@@ -61,9 +76,15 @@ export default { ...@@ -61,9 +76,15 @@ export default {
}; };
getApi(para) getApi(para)
.then(res => { .then(res => {
let resData = res; let resData = res.data;
if (resData.code == '0000') { if (resData.code == '0000') {
that.apiData = resData.result; let data = resData.result;
data.frontParams = JSON.parse(data.frontParams);
data.frontParams = processObject(data.frontParams);
data.resultParams = JSON.parse(data.resultParams);
data.resultParams = processObject(data.resultParams);
that.formData.memo = data.interfaceDescribe;
that.apiData = JSON.parse(JSON.stringify(data));
return false; return false;
} }
errMsg.errorMsg(resData); errMsg.errorMsg(resData);
...@@ -83,10 +104,11 @@ export default { ...@@ -83,10 +104,11 @@ export default {
let para = { let para = {
articleId: articleId articleId: articleId
}; };
getDocDetail(para) getArtical(para)
.then(res => { .then(res => {
let resData = res; let resData = res.data;
if (resData.code == '0000') { if (resData.code == '0000') {
resData.result.content = marked(resData.result.content);
that.formData = resData.result || {}; that.formData = resData.result || {};
return; return;
} }
...@@ -108,13 +130,21 @@ export default { ...@@ -108,13 +130,21 @@ export default {
const subType = that.menuDetailData.subType; const subType = that.menuDetailData.subType;
if (!Object.keys(that.menuDetailData).length) { if (!Object.keys(that.menuDetailData).length) {
that.formData = {}; that.formData = {};
that.apiData = {};
that.errorCodeData = [];
} else if (type == 1) { } else if (type == 1) {
window.location.href = that.menuDetailData.relationData; window.open(that.menuDetailData.relationData);
} else if (type == 2) { } else if (type == 2) {
that.apiData = {};
that.errorCodeData = [];
that.getData(JSON.parse(that.menuDetailData.relationData)[1]); that.getData(JSON.parse(that.menuDetailData.relationData)[1]);
} else if (type == 3 && subType == '0') { } else if (type == 3 && subType == '0') {
that.getErrorCodeData(); that.apiData = {};
that.formData = {};
that.errorCodeData = JSON.parse(that.menuDetailData.relationData);
} else if (type == 3 && subType == '1') { } else if (type == 3 && subType == '1') {
that.formData = {};
that.errorCodeData = [];
that.getApiDetailData(JSON.parse(that.menuDetailData.relationData)[2]); that.getApiDetailData(JSON.parse(that.menuDetailData.relationData)[2]);
} }
} }
...@@ -143,7 +173,7 @@ export default { ...@@ -143,7 +173,7 @@ export default {
.document-right-body { .document-right-body {
width: 900px; width: 900px;
margin: 0 auto; margin: 0 auto;
padding: 45px 0 147px 0;
min-height: calc(100vh - 118px;); min-height: calc(100vh - 118px;);
} }
} }
......
...@@ -11,7 +11,7 @@ import store from './store/store'; ...@@ -11,7 +11,7 @@ import store from './store/store';
/* eslint-disable */ /* eslint-disable */
import * as types from './store/types'; import * as types from './store/types';
import '../static/css/index.less'; import '../static/css/index.less';
// import 'element-ui/lib/theme-chalk/index.css' import 'element-ui/lib/theme-chalk/index.css'
import '../static/font/iconfont.css'; import '../static/font/iconfont.css';
import '../theme/index.css'; import '../theme/index.css';
import filters from './filters/index.js'; import filters from './filters/index.js';
......
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