XML.htm 86 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>新版杏聆荟JsonRPC接口文档</title>
  7. <link rel="stylesheet" type="text/css" href="https://img.cdn.apipost.cn/docs/css/reset.css">
  8. <link rel="stylesheet" type="text/css" href="https://img.cdn.apipost.cn/docs/css/style.css">
  9. <link rel="stylesheet" type="text/css"
  10. href="https://img.cdn.apipost.cn/docs/css/font-awesome-4.7.0/css/font-awesome.css">
  11. <link rel="stylesheet" href="https://img.cdn.apipost.cn/docs/css/content.css">
  12. <link rel="stylesheet" href="https://img.cdn.apipost.cn/docs/css/github.css">
  13. <link rel="icon" href="ReleaseNoteStyle/favicon.ico">
  14. <script src="https://img.cdn.apipost.cn/docs/js/jquery-3.4.1.min.js"></script>
  15. <script src="https://img.cdn.apipost.cn/docs/js/marked.min.js"></script>
  16. <script src="https://img.cdn.apipost.cn/docs/js/template-web.js"></script>
  17. <script src="https://img.cdn.apipost.cn/docs/js/highlight.js"></script>
  18. <script src="https://img.cdn.apipost.cn/statics/libs/crypto-js/crypto-js.min.js" type="text/javascript" charset="utf-8"></script>
  19. <script src="https://docs.apipost.cn/statics/enc.min.js"></script>
  20. <script src="https://img.cdn.apipost.cn/docs/js/clipboard.min.js"></script>
  21. <script src="ReleaseNoteStyle/xlsx.core.min.js"></script>
  22. </head>
  23. <body>
  24. <!-- <body> -->
  25. <div class="body">
  26. <div class="doc-head">
  27. <div class="left">
  28. <img src="https://flyinsono-bj-1300984704.cos.ap-beijing.myqcloud.com/BlueLogoChineseFlynoinso.png" style="margin-top: 3px;">
  29. </div>
  30. <div class="container">
  31. <div class="container-left">
  32. <input type="text" id="txtSearch" class="search" placeholder="搜索目录接口">
  33. <button onclick="searchClick();"><i class="fa fa-search" aria-hidden="true"></i></button>
  34. </div>
  35. <!-- <div class="export" style="position: relative;-->
  36. <!-- float: right;-->
  37. <!-- margin: -16px 50px;">-->
  38. <!-- <div class="container-right">-->
  39. <!-- <a href="javascript:;">导出文档</a>-->
  40. <!-- </div>-->
  41. <!-- <div class="export_panel">-->
  42. <!-- <ul>-->
  43. <!-- <li><a href="javascript:;">导出HTML</a></li>-->
  44. <!-- <li><a href="javascript:;">导出MarkDown</a></li>-->
  45. <!-- <li><a href="javascript:;">导出Word</a></li>-->
  46. <!-- </ul>-->
  47. <!-- </div>-->
  48. <!-- </div>-->
  49. </div>
  50. </div>
  51. <div class="box">
  52. <div class="box-first">
  53. <div class="title">新版杏聆荟RPC接口文档</div>
  54. <div class="top target" data-target_id="001">服务接口 Release Notes</div>
  55. <div class="new" style="height:calc(100% - 60px) !important;">
  56. </div>
  57. <div class="bar"></div>
  58. <script type="text/html" id="template-target-sidebar-list-tpl">
  59. {{each list value}}
  60. <div>
  61. <div class="target {{value.target_type == 'folder' ? 'folder':'api'}}"
  62. data-type="{{value.target_type}}" data-id="{{value.target_id}}"
  63. data-target_id="{{value.local_target_id}}">
  64. {{if value.target_type == 'folder'}}
  65. <span>
  66. <span class="control">
  67. {{if value.children}}
  68. <i class="fa fa-angle-down"></i>
  69. {{/if}}
  70. </span>
  71. <span class="controlName controlLevelOne">{{value.name}}</span>
  72. </span>
  73. {{else}}
  74. <span>
  75. <em class="{{((target_type == 'doc') || (target_type == 'example' && is_doc == 1)) ? 'DOC' : target_type == 'example' ? method : ''}}">{{(target_type == 'doc' || (target_type == 'example' && is_doc == '1')) ? '文本' : method == 'OPTIONS' ? 'OPT' : method == 'DELETE' ? 'DEL' : method == 'UNLINK' ? 'UNLNK' : method == 'UNLOCK' ? 'UNLCK' : method == 'PROPFIND' ? 'PROP' : method}}</em>
  76. <span>{{value.name}}</span>
  77. </span>
  78. <span></span>
  79. {{/if}}
  80. </div>
  81. {{if value.children!=null}}
  82. {{each value.children data}}
  83. {{set a=data["index"]=3}}
  84. {{include 'list1' data}}
  85. {{/each}}
  86. {{/if}}
  87. </div>
  88. {{/each}}
  89. </script>
  90. <script type="text/html" id="list1">
  91. <div>
  92. <div class="target {{target_type == 'folder' ? 'folder':'api'}}" data-type="{{target_type}}"
  93. data-id="{{target_id}}" data-target_id="{{local_target_id}}"
  94. style="padding-left:{{index * 15}}px">
  95. {{if target_type == 'folder'}}
  96. <span>
  97. <span class="control">
  98. {{if children}}
  99. <i class="fa fa-angle-down"></i>
  100. {{/if}}
  101. </span>
  102. <span class="controlName controlLevelTwo api_level{{api_level}}">{{name}}</span>
  103. </span>
  104. {{else}}
  105. <span>
  106. <em class="{{((target_type == 'doc') || (target_type == 'example' && is_doc == 1)) ? 'DOC' : target_type == 'example' ? method : ''}}">{{(target_type == 'doc' || (target_type == 'example' && is_doc == '1')) ? '文本' : method == 'OPTIONS' ? 'OPT' : method == 'DELETE' ? 'DEL' : method == 'UNLINK' ? 'UNLNK' : method == 'UNLOCK' ? 'UNLCK' : method == 'PROPFIND' ? 'PROP' : method}}</em>
  107. <span>{{name}}</span>
  108. </span>
  109. <span></span>
  110. {{/if}}
  111. </div>
  112. {{if children!=null}}
  113. {{each children data}}
  114. {{if index}}
  115. {{set b=data.index=index+1}}
  116. {{else}}
  117. {{set c=data["index"] = 3}}
  118. {{/if}}
  119. {{include 'list1' data}}
  120. {{/each}}
  121. {{/if}}
  122. </div>
  123. </script>
  124. </div>
  125. <div class="box-third">
  126. <div class="preview-markdown">
  127. </div>
  128. <div class="box-nav" style="background: #fff;top: 160px;right: 50px;">
  129. <ul class="api template-nav-menu">
  130. <script type="text/html" id="template-nav-menu-tpl">
  131. {{if target_type == "api" || target_type == "folder" || (target_type == "example" && is_doc == 0) }}
  132. <li class="cur nav-btn" data-id="0"><a href="javascript:;">基本信息</a></li>
  133. {{/if}}
  134. {{if request.header.parameter.length > 0 || request.query.parameter.length > 0 || request.resful.parameter.length > 0 || request.body.parameter.length>0 ||request.body.raw !=''}}
  135. <li class="nav-btn" data-id="1" style="display: block"><a href="javascript:;">请求参数</a></li>
  136. {{else}}
  137. <li class="nav-btn" data-id="1" style="display: none"><a href="javascript:;">请求参数</a></li>
  138. {{/if}}
  139. <ul>
  140. {{if request.header.parameter.length > 0}}
  141. <li class="nav-btn" data-id="2" style="display: block"><a
  142. href="javascript:;">header参数及说明</a></li>
  143. {{else}}
  144. <li class="nav-btn" data-id="2" style="display: none"><a href="javascript:;">header参数及说明</a>
  145. </li>
  146. {{/if}}
  147. {{if request.query.parameter.length > 0}}
  148. <li class="nav-btn" data-id="3" style="display: block"><a href="javascript:;">query参数及说明</a>
  149. </li>
  150. {{else}}
  151. <li class="nav-btn" data-id="3" style="display: none"><a href="javascript:;">query参数及说明</a>
  152. </li>
  153. {{/if}}
  154. {{if request.resful.parameter.length > 0}}
  155. <li class="nav-btn" data-id="4" style="display: block"><a href="javascript:;">路径参数及说明</a>
  156. </li>
  157. {{else}}
  158. <li class="nav-btn" data-id="4" style="display: none"><a href="javascript:;">路径参数及说明</a>
  159. </li>
  160. {{/if}}
  161. {{if request.body.parameter.length>0 ||request.body.raw !='' }}
  162. <li class="nav-btn" data-id="5" style="display: block"><a href="javascript:;">body参数及说明</a>
  163. </li>
  164. {{else}}
  165. <li class="nav-btn" data-id="5" style="display: none"><a href="javascript:;">body参数及说明</a>
  166. </li>
  167. {{/if}}
  168. <!-- <li class="nav-btn" data-id="6"><a href="javascript:;">预执行脚本</a></li>-->
  169. <!-- <li class="nav-btn" data-id="7"><a href="javascript:;">后执行脚本</a></li>-->
  170. </ul>
  171. {{if response.success.raw || response.success.parameter.length > 0 || response.error.raw || response.error.parameter.length > 0}}
  172. <li class="nav-btn" data-id="6" style="display: block"><a href="javascript:;">响应示例</a></li>
  173. {{else}}
  174. <li class="nav-btn" data-id="6" style="display: none"><a href="javascript:;">响应示例</a></li>
  175. <!-- <ul>-->
  176. <!-- {{if response.success.raw || response.success.parameter.length > 0}}-->
  177. <!-- <li class="nav-btn" data-id="9"><a href="javascript:;">成功响应示例</a></li>-->
  178. <!-- {{/if}}-->
  179. <!---->
  180. <!-- {{if response.error.raw || response.error.parameter.length > 0}}-->
  181. <!-- <li class="nav-btn" data-id="10"><a href="javascript:;">失败响应示例</a></li>-->
  182. <!-- {{/if}}-->
  183. <!-- </ul>-->
  184. {{/if}}
  185. {{if response.success.error_result.length > 0}}
  186. <li class="nav-btn" data-id="9" style="display: block"><a href="javascript:;">错误码信息</a></li>
  187. {{else}}
  188. <li class="nav-btn" data-id="9" style="display: none"><a href="javascript:;">错误码信息</a></li>
  189. {{/if}}
  190. </script>
  191. </ul>
  192. </ul>
  193. <ul class="folder">
  194. <li class="cur nav-folder-btn" data-id="0"><a href="javascript:;">公共参数</a></li>
  195. <ul>
  196. <li class="nav-folder-btn" data-id="1"><a href="javascript:;">header参数及说明</a></li>
  197. <li class="nav-folder-btn" data-id="2"><a href="javascript:;">query参数及说明</a></li>
  198. <li class="nav-folder-btn" data-id="3"><a href="javascript:;">body参数及说明</a></li>
  199. <!-- <li class="nav-folder-btn" data-id="4"><a href="javascript:;">预执行脚本</a></li>-->
  200. <!-- <li class="nav-folder-btn" data-id="5"><a href="javascript:;">后执行脚本</a></li>-->
  201. </ul>
  202. </ul>
  203. </div>
  204. <script type="text/html" id="template-example-doc-tpl">
  205. <h2>
  206. <span>{{name}}</span>
  207. <span class="metadata">更新时间:{{update_dtime}}</span>
  208. </h2>
  209. {{if request.description}}
  210. <div class="editor-preview desc markdown-section" id="{{request.requestId}}">
  211. </div>
  212. {{/if}}
  213. {{if (target_type == 'example' && is_doc == '0') || target_type == 'api'}}
  214. <h3 class="title"><a href="javascript:;" class="maodian"></a> 基本信息 <i class="fa fa-angle-down"></i></h3>
  215. <ul class="editor-preview-info">
  216. <li><strong>接口状态:</strong> <code class="span {{mark}}">{{mark == 'developing' ? '开发中' : mark ==
  217. 'complated' ?
  218. '已完成' : mark == 'modifying' ? '修改中' : '开发中'}}</code></li>
  219. {{if request.url}}
  220. <li><strong>接口URL:</strong> <code class="span">{{request.url}}</code></li>
  221. {{/if}}
  222. <li><strong>请求方式:</strong> <code class="span">{{method}}</code></li>
  223. <li><strong>Content-Type:</strong><code class="span">{{request.body.mode}}</code></li>
  224. </ul>
  225. <h3 class="title"
  226. style="{{request.header.parameter.length > 0 || request.query.parameter.length > 0 || request.resful.parameter.length > 0 || request.body.parameter.length>0 ||request.body.raw !='' ? 'display:block':'display:none'}}">
  227. <a href="javascript:;" class="maodian"></a> 请求参数 <i class="fa fa-angle-down"></i></h3>
  228. {{if request.header.parameter.length > 0 || request.query.parameter.length > 0 || request.resful.parameter.length > 0 || request.body.parameter.length>0 ||request.body.raw !=''}}
  229. <div class="markdown-request">
  230. <h4 class="title" style="{{request.header.parameter.length ? 'display:block':'display:none'}}"><a
  231. href="javascript:;" class="maodian"></a> Header参数及说明</h4>
  232. {{if request.header.parameter.length > 0}}
  233. <div>
  234. <table>
  235. <tr>
  236. <th>参数名</th>
  237. <th>示例值</th>
  238. <th>参数类型</th>
  239. <th>是否必填</th>
  240. <th>参数描述</th>
  241. </tr>
  242. {{each request.header.parameter item}}
  243. {{if item.key}}
  244. <tr>
  245. <td>{{item.key}}</td>
  246. <td>{{item.value}}</td>
  247. <td>{{item.field_type == "" || item.field_type == "[]"? (typeof item.value) :
  248. item.field_type}}
  249. </td>
  250. <td>{{item.not_null == "1" ? '是' : '否'}}</td>
  251. <td>{{item.description == '' ? '暂无描述' : item.description }}</td>
  252. </tr>
  253. {{/if}}
  254. {{/each}}
  255. </table>
  256. </div>
  257. {{/if}}
  258. <h4 class="title" style="{{request.query.parameter.length > 0 ? 'display:block':'display:none'}}"><a
  259. href="javascript:;" class="maodian"></a> Query参数及说明</h4>
  260. {{if request.query.parameter.length > 0}}
  261. <div>
  262. <table>
  263. <tr>
  264. <th>参数名</th>
  265. <th>示例值</th>
  266. <th>参数类型</th>
  267. <th>是否必填</th>
  268. <th>参数描述</th>
  269. </tr>
  270. {{each request.query.parameter item}}
  271. {{if item.key}}
  272. <tr>
  273. <td>{{item.key}}</td>
  274. <td>{{item.value}}</td>
  275. <td>{{item.field_type == "" || item.field_type == "[]"? (typeof item.value) :
  276. item.field_type}}
  277. </td>
  278. <td>{{item.not_null == "1" ? '是' : '否'}}</td>
  279. <td>{{item.description == '' ? '暂无描述' : item.description }}</td>
  280. </tr>
  281. {{/if}}
  282. {{/each}}
  283. </table>
  284. </div>
  285. {{/if}}
  286. <h4 class="title" style="{{request.resful.parameter.length ? 'display:block':'display:none'}}"><a
  287. href="javascript:;" class="maodian"></a> 路径参数及说明</h4>
  288. {{if request.resful.parameter.length > 0}}
  289. <div>
  290. <table>
  291. <tr>
  292. <th>参数名</th>
  293. <th>示例值</th>
  294. <th>参数类型</th>
  295. <th>是否必填</th>
  296. <th>参数描述</th>
  297. </tr>
  298. {{each request.resful.parameter item}}
  299. {{if item.key}}
  300. <tr>
  301. <td>{{item.key}}</td>
  302. <td>{{item.value}}</td>
  303. <td>{{item.field_type == "" || item.field_type == "[]"? (typeof item.value) :
  304. item.field_type}}
  305. </td>
  306. <td>{{item.not_null == "1" ? '是' : '否'}}</td>
  307. <td>{{item.description == '' ? '暂无描述' : item.description }}</td>
  308. </tr>
  309. {{/if}}
  310. {{/each}}
  311. </table>
  312. </div>
  313. {{/if}}
  314. <h4 class="title"
  315. style="{{request.body.parameter.length > 0 || request.body.raw !='' ? 'display:block' : 'display:none'}}">
  316. <a href="javascript:;" class="maodian"></a> body参数及说明</h4>
  317. {{if request.body.parameter.length>0 ||request.body.raw !='' }}
  318. {{if request.body.mode == 'form-data' || request.body.mode == 'multipart/form-data' || request.body.mode == 'application/octet-stream' ||
  319. request.body.mode =='application/x-www-form-urlencoded' || request.body.mode=="urlencoded"}}
  320. <div>
  321. <table>
  322. <tr>
  323. <th>参数名</th>
  324. <th>示例值</th>
  325. <th>参数类型</th>
  326. <th>是否必填</th>
  327. <th>参数描述</th>
  328. </tr>
  329. {{if request.body.parameter.length > 0}}
  330. {{each request.body.parameter item}}
  331. {{if item.key}}
  332. <tr>
  333. <td>{{item.key}}</td>
  334. <td>{{item.value}}</td>
  335. <td>{{item.field_type == "" || item.field_type == "[]"? (typeof item.value) :
  336. item.field_type}}
  337. </td>
  338. <td>{{item.not_null == "1" ? '是' : '否'}}</td>
  339. <td>{{item.description == '' ? '暂无描述' : item.description }}</td>
  340. </tr>
  341. {{/if}}
  342. {{/each}}
  343. {{else}}
  344. <tr>
  345. <td colspan="5" style="text-align:center">暂无数据</td>
  346. </tr>
  347. {{/if}}
  348. </table>
  349. </div>
  350. {{else}}
  351. <div class="editor-preview">
  352. <pre><code class="hljs json" style="color: #0ad161;background: #373e52;">{{request.body.raw}}</code></pre>
  353. </div>
  354. {{if request.body.raw_para.length > 0}}
  355. <h4><a href="javascript:;" class="maodian"></a> 字段描述</h4>
  356. <table>
  357. <tr>
  358. <th>参数名</th>
  359. <th>示例值</th>
  360. <th>参数类型</th>
  361. <th>是否必填</th>
  362. <th>参数描述</th>
  363. </tr>
  364. {{each request.body.raw_para item}}
  365. {{if item.key}}
  366. <tr>
  367. <td>{{item.key}}</td>
  368. <td>{{item.value}}</td>
  369. {{if item.field_type_value == 1 }}
  370. <td><a style="text-decoration: underline;color: blue;" href="javascript:;" onclick="validateJump('{{item.file_name}}', '{{item.field_type_target_id}}')">{{item.field_type}}</a></td>
  371. {{else}}
  372. <td>{{item.field_type}}</td>
  373. {{/if}}
  374. <td>{{item.not_null == "1" ? '是' : '否'}}</td>
  375. <td>{{item.description == '' ? '暂无描述' : item.description }}</td>
  376. </tr>
  377. {{/if}}
  378. {{/each}}
  379. </table>
  380. {{/if}}
  381. {{/if}}
  382. <!-- {{if request.event.pre_script != ''}}-->
  383. <!-- <h4 class="title"><a href="javascript:;" class="maodian"></a> 预执行脚本</h4>-->
  384. <!-- <div class="editor-preview">-->
  385. <!-- <pre><code class="hljs">{{request.event.pre_script}}</code></pre>-->
  386. <!-- </div>-->
  387. <!-- {{/if}}-->
  388. <!-- {{if request.event.test != ''}}-->
  389. <!-- <h4 class="title"><a href="javascript:;" class="maodian"></a> 后执行脚本</h4>-->
  390. <!-- <div class="editor-preview">-->
  391. <!-- <pre><code class="hljs">{{request.event.test}}</code></pre>-->
  392. <!-- </div>-->
  393. <!-- {{/if}}-->
  394. </div>
  395. {{/if}}
  396. {{/if}}
  397. <!--respond-->
  398. <h3 class="title"
  399. style="{{response.success.raw || response.success.parameter.length > 0 || response.error.raw || response.error.parameter.length > 0 ? 'display:block':'display:none'}}"">
  400. <a href="javascript:;" class="maodian"></a> 响应示例<i class="fa fa-angle-down"></i></h3>
  401. {{if response.success.raw || response.success.parameter.length > 0 || response.error.raw || response.error.parameter.length > 0}}
  402. <div class="markdown-response">
  403. {{if response.success.raw || response.success.parameter.length > 0}}
  404. <h4 class="title"><a href="javascript:;" class="maodian"></a> 成功响应示例</h4>
  405. <div class="editor-preview">
  406. <pre><code class="hljs json" style="color: #0ad161;background: #373e52;">{{response.success.raw}}</code></pre>
  407. </div>
  408. {{if response.success.parameter.length > 0}}
  409. <h4><a href="javascript:;" class="maodian"></a> 字段描述</h4>
  410. <table>
  411. <tr>
  412. <th>参数名</th>
  413. <th>示例值</th>
  414. <th>参数类型</th>
  415. <th>参数描述</th>
  416. </tr>
  417. {{each response.success.parameter item}}
  418. <tr>
  419. <td>{{item.key}}</td>
  420. <td>{{item.value}}</td>
  421. {{if item.field_type_value == 1 }}
  422. <td><a style="text-decoration: underline;color: blue;" href="javascript:;" onclick="validateJump('{{item.file_name}}', '{{item.field_type_target_id}}')">{{item.field_type}}</a></td>
  423. {{else}}
  424. <td>{{item.field_type}}</td>
  425. {{/if}}
  426. <td>{{item.description == '' ? '暂无描述' : item.description }}</td>
  427. </tr>
  428. {{/each}}
  429. </table>
  430. {{/if}}
  431. {{/if}}
  432. {{if response.error.raw || response.error.parameter.length > 0}}
  433. <h4 class="title"><a href="javascript:;" class="maodian"></a> 失败响应示例</h4>
  434. <div class="editor-preview">
  435. <pre><code class="hljs json" style="color: #0ad161;background: #373e52;">{{response.error.raw}}</code></pre>
  436. </div>
  437. {{if response.error.parameter.length > 0}}
  438. <h4><a href="javascript:;" class="maodian"></a> 字段描述</h4>
  439. <table>
  440. <tr>
  441. <th>参数名</th>
  442. <th>示例值</th>
  443. <th>参数类型</th>
  444. <th>参数描述</th>
  445. </tr>
  446. {{each response.error.parameter item}}
  447. <tr>
  448. <td>{{item.key}}</td>
  449. <td>{{item.value}}</td>
  450. <td>{{item.field_type}}</td>
  451. <td>{{item.description == '' ? '暂无描述' : item.description }}</td>
  452. </tr>
  453. {{/each}}
  454. </table>
  455. {{/if}}
  456. {{/if}}
  457. </div>
  458. {{/if}}
  459. <h3 class="title" style="{{response.success.error_result.length > 0 ? 'display:block':'display:none'}}" >
  460. <a href="javascript:;" class="maodian"></a> 错误码信息<i class="fa fa-angle-down"></i>
  461. </h3>
  462. {{if response.success.error_result.length > 0 }}
  463. <div class="markdown-response">
  464. {{if response.success.error_result.length > 0}}
  465. {{each response.success.error_result resultItem}}
  466. <table>
  467. <tr>
  468. {{each resultItem.header item}}
  469. <th>{{item}}</th>
  470. {{/each}}
  471. </tr>
  472. {{each resultItem.content item}}
  473. <tr>
  474. {{each item.content_data content_dataItem}}
  475. <td>{{content_dataItem}}</td>
  476. {{/each}}
  477. </tr>
  478. {{/each}}
  479. </table>
  480. {{/each}}
  481. {{/if}}
  482. </div>
  483. {{/if}}
  484. {{else if target_type == 'folder'}}
  485. <h3 class="title"><a href="javascript:;" class="maodian"></a> 公共参数<i class="fa fa-angle-down"></i></h3>
  486. <div class="markdown-request">
  487. <h4 class="title"><a href="javascript:;" class="maodian"></a> Header参数及说明</h4>
  488. <div>
  489. <table class="header">
  490. <tr>
  491. <th>参数名</th>
  492. <th>示例值</th>
  493. <th>参数类型</th>
  494. <th>参数描述</th>
  495. </tr>
  496. {{if request.header.length > 0}}
  497. {{each request.header item}}
  498. {{if item.key}}
  499. <tr>
  500. <td>{{item.key}}</td>
  501. <td>{{item.value}}</td>
  502. <td>{{item.field_type == "" || item.field_type == "[]"? (typeof item.value) :
  503. item.field_type}}
  504. </td>
  505. <td>{{item.description == '' ? '暂无描述' : item.description }}</td>
  506. </tr>
  507. {{/if}}
  508. {{/each}}
  509. {{/if}}
  510. </table>
  511. </div>
  512. <h4 class="title"><a href="javascript:;" class="maodian"></a> Query参数及说明</h4>
  513. <div>
  514. <table class="query">
  515. <tr>
  516. <th>参数名</th>
  517. <th>示例值</th>
  518. <th>参数类型</th>
  519. <th>参数描述</th>
  520. </tr>
  521. {{each request.query item}}
  522. {{if item.key}}
  523. <tr>
  524. <td>{{item.key}}</td>
  525. <td>{{item.value}}</td>
  526. <td>{{item.field_type == "" || item.field_type == "[]"? (typeof item.value) :
  527. item.field_type}}
  528. </td>
  529. <td>{{item.description == '' ? '暂无描述' : item.description }}</td>
  530. </tr>
  531. {{/if}}
  532. {{/each}}
  533. </table>
  534. </div>
  535. <h4 class="title"><a href="javascript:;" class="maodian"></a> Body参数及说明</h4>
  536. <div>
  537. <table class="body">
  538. <tr>
  539. <th>参数名</th>
  540. <th>示例值</th>
  541. <th>参数类型</th>
  542. <th>参数描述</th>
  543. </tr>
  544. {{each request.body item}}
  545. {{if item.key}}
  546. <tr>
  547. <td>{{item.key}}</td>
  548. <td>{{item.value}}</td>
  549. <td>{{item.field_type == "" || item.field_type == "[]"? (typeof item.value) :
  550. item.field_type}}
  551. </td>
  552. <td>{{item.description == '' ? '暂无描述' : item.description }}</td>
  553. </tr>
  554. {{/if}}
  555. {{/each}}
  556. </table>
  557. </div>
  558. <!-- {{if script.pre_script != ''}}-->
  559. <!-- <h4 class="title"><a href="javascript:;" class="maodian"></a> 预执行脚本</h4>-->
  560. <!-- <div class="editor-preview">-->
  561. <!-- <pre><code class="hljs">{{script.pre_script}}</code></pre>-->
  562. <!-- </div>-->
  563. <!-- {{/if}}-->
  564. <!-- {{if script.test !=''}}-->
  565. <!-- <h4 class="title"><a href="javascript:;" class="maodian"></a> 后执行脚本</h4>-->
  566. <!-- <div class="editor-preview">-->
  567. <!-- <pre><code class="hljs">{{script.test}}</code></pre>-->
  568. <!-- </div>-->
  569. <!-- {{/if}}-->
  570. </div>
  571. <!--respond-->
  572. {{/if}}
  573. <div class="footer" style="text-align: center;margin: 35px 24px;height: 50px">本文档由Vinno-IDS-云平台文档生成工具生成</div>
  574. </script>
  575. </div>
  576. </div>
  577. </div>
  578. <script type="text/html" id="golbal-env-tpl">
  579. <h2 class="top">
  580. {{project_name}}
  581. <span class="metadata">
  582. 创建时间: {{create_time}}
  583. {{if expire_day_time}}
  584. <span style="color: #f44336; margin-left: 15px; font-weight: bold;">过期时间: {{expire_day_time}}</span>
  585. {{/if}}
  586. </span>
  587. </h2>
  588. <div class="editor-preview desc">
  589. <p>{{publishInfo}}</p>
  590. </div>
  591. <!-- <blockquote></blockquote> -->
  592. <h3 class="title">
  593. <a href="javascript:;" class="maodian"></a> 版本历史列表
  594. {{if versionDatas.length > 0}}
  595. <i class="fa fa-angle-down"></i>
  596. {{/if}}
  597. </h3>
  598. {{if versionDatas.length > 0}}
  599. <div>
  600. {{each versionDatas item}}
  601. <h4>当前部署包:{{item.currentPackage}}</h4>
  602. <table>
  603. <tr>
  604. <th style="width:22%">部署包</th>
  605. <th style="width:10%">版本号</th>
  606. <th style="width:50%">更新描述</th>
  607. <th style="width:10%">更新时间</th>
  608. <th style="width:8%">更新人</th>
  609. </tr>
  610. {{each item.list childItem}}
  611. <tr>
  612. <td>{{childItem["部署包"]}}</td>
  613. <td>{{childItem["版本号"]}}</td>
  614. <td>{{childItem["更新描述"]}}</td>
  615. <td>{{childItem["更新时间"]}}</td>
  616. <td>{{childItem["更新人"]}}</td>
  617. </tr>
  618. {{/each}}
  619. </table>
  620. {{/each}}
  621. </div>
  622. {{else}}
  623. <div style="text-align: center;">
  624. <img src="https://img.cdn.apipost.cn/docs/images/empty.svg"
  625. style="width: 100px;margin:20px auto 20px;">暂无环境
  626. </div>
  627. {{/if}}
  628. <h3 class="title">
  629. <a href="javascript:;" class="maodian"></a> 接口更新列表
  630. {{if interfaceDatas.length > 0}}
  631. <i class="fa fa-angle-down"></i>
  632. {{/if}}
  633. </h3>
  634. {{if interfaceDatas.length > 0}}
  635. <div>
  636. {{each interfaceDatas item}}
  637. <h4>发布时间:{{item.publishTime}}</h4>
  638. <table>
  639. <tr>
  640. <th style="width:7%">发布时间</th>
  641. <th style="width:20%">接口名称</th>
  642. <th style="width:38%">描述</th>
  643. <th style="width:7%">自动化测试</th>
  644. <th style="width:4%">增/改</th>
  645. <th style="width:12%">部署包</th>
  646. <th style="width:6%">版本号</th>
  647. <th style="width:6%">开发人员</th>
  648. </tr>
  649. {{each item.list childItem}}
  650. <tr>
  651. <td>{{childItem["发布时间"]}}</td>
  652. <td>{{childItem["接口名称"]}}</td>
  653. <td>{{childItem["描述"]}}</td>
  654. {{if childItem["自动化测试"] == "无测试用例"}}
  655. <td style="color: orange; font-weight: 600; ">{{childItem["自动化测试"]}}</td>
  656. {{else}}
  657. <td style="color: #40B766; font-weight: 600; ">{{childItem["自动化测试"]}}</td>
  658. {{/if}}
  659. <td>{{childItem["增/改"]}}</td>
  660. <td>{{childItem["部署包"]}}</td>
  661. <td>{{childItem["版本号"]}}</td>
  662. <td>{{childItem["开发人员"]}}</td>
  663. </tr>
  664. {{/each}}
  665. </table>
  666. {{/each}}
  667. </div>
  668. {{else}}
  669. <div style="text-align: center;">
  670. <img src="https://img.cdn.apipost.cn/docs/images/empty.svg"
  671. style="width: 100px;margin:20px auto 20px;">暂无参数
  672. </div>
  673. {{/if}}
  674. <div class="footer" style="text-align: center;margin: 35px 24px;height: 50px">本文档由Vinno-IDS-云平台文档生成工具生成</div>
  675. </script>
  676. <script>
  677. template.defaults.imports.marked = function (md) {
  678. return marked(md);
  679. }
  680. function validateJump(fileName, targetId) {
  681. if (targetId && targetId.length > 0) {
  682. let newdata = JSON.parse(JSON.stringify(arr))
  683. let LevelArr = []
  684. function levelTree(arr1, newarr) {
  685. arr1.forEach(item => {
  686. if (item.children && item.children.length > 0) {
  687. newarr.push(item)
  688. levelTree(item.children, newarr)
  689. } else {
  690. newarr.push(item)
  691. }
  692. })
  693. }
  694. levelTree(newdata.targets, LevelArr)
  695. var res = LevelArr.some(item => {
  696. if (item.local_target_id == targetId) {
  697. return true;
  698. }
  699. return false;
  700. });
  701. let url = window.location.href.split('#')[0] + '#';
  702. if (res) {
  703. //找到,正常跳转
  704. var newUrl = url + targetId;
  705. window.open(newUrl, "新版杏聆荟RPC接口文档_枚举详情");
  706. }
  707. else {
  708. //没找到,页面刷新
  709. var newUrl = url + "001";
  710. window.location.href = newUrl;
  711. window.location.reload(true);
  712. }
  713. }
  714. return false;
  715. }
  716. $(document).ready(function () {
  717. readFile('ReleaseNoteStyle/新版杏聆荟ReleaseNotes.xlsx');
  718. });
  719. function readFile(filePath) {
  720. let xhr = new XMLHttpRequest();
  721. xhr.responseType = "blob";
  722. xhr.open('GET', filePath, true);
  723. xhr.onload = function () {
  724. if (this.status === 200) {
  725. var blob = this.response;
  726. let file = new window.File([blob], 'JSON.xlsx');
  727. var fileReader = new FileReader();
  728. fileReader.readAsBinaryString(file);
  729. fileReader.onload = function (ev) {
  730. var data = ev.target.result;
  731. var workbook = XLSX.read(data, {
  732. type: 'binary'
  733. }) // 以二进制流方式读取得到整份excel表格对象
  734. var excelDatas = [];
  735. // 遍历每张表读取
  736. for (var sheet in workbook.Sheets) {
  737. if (workbook.Sheets.hasOwnProperty(sheet)) {
  738. var dataList = [];
  739. dataList = dataList.concat(XLSX.utils.sheet_to_json(workbook.Sheets[sheet]));
  740. var entity = {
  741. "name": sheet,
  742. "datas": dataList
  743. }
  744. excelDatas.push(entity);
  745. }
  746. }
  747. if (excelDatas && excelDatas.length >= 3) {
  748. var versionList = excelDatas[0].datas;
  749. if (versionList && versionList.length > 0) {
  750. versionList.sort(compare("更新时间", 'inverted'));
  751. versionList.forEach(x => {
  752. var tempTime = dateFormat(x["更新时间"], 'yyyy-MM-dd');
  753. x["更新时间"] = tempTime;
  754. });
  755. var str = JSON.stringify(versionList);
  756. window.localStorage.setItem("CurrentVersionUpdateDatas", str);
  757. }
  758. var noteList = excelDatas[1].datas;
  759. if (noteList && noteList.length > 0) {
  760. var noteInfo = noteList[0];
  761. var serverPathStr = "服务器发布地址:" + noteInfo["服务器发布地址"];
  762. window.localStorage.setItem("CurrentPackagePublishInfo", serverPathStr);
  763. }
  764. var interfaceList = excelDatas[2].datas;
  765. if (interfaceList && interfaceList.length > 0) {
  766. interfaceList.sort(compare("发布时间", 'inverted'));
  767. interfaceList.forEach(y => {
  768. var tempPublishTime = dateFormat(y["发布时间"], 'yyyy-MM-dd');
  769. y["发布时间"] = tempPublishTime;
  770. });
  771. var str = JSON.stringify(interfaceList);
  772. window.localStorage.setItem("CurrentInterfaceUpdateDatas", str);
  773. }
  774. }
  775. else {
  776. console.log("数据格式错误,错误数据为:", excelDatas);
  777. }
  778. }
  779. }
  780. };
  781. xhr.send();
  782. }
  783. //排序
  784. function compare(prop, align) {
  785. return function (a, b) {
  786. var value1 = a[prop];
  787. var value2 = b[prop];
  788. if (align == "positive") {//正序
  789. return new Date(value1) - new Date(value2);
  790. } else if (align == "inverted") {//倒序
  791. return new Date(value2) - new Date(value1);
  792. }
  793. }
  794. }
  795. function dateFormat(date, fmt = 'yyyy-MM-dd hh:mm:ss') {
  796. date = new Date(date)
  797. var o = {
  798. "M+": date.getMonth() + 1, //月份
  799. "d+": date.getDate(), //日
  800. "h+": date.getHours(), //小时
  801. "m+": date.getMinutes(), //分
  802. "s+": date.getSeconds(), //秒
  803. "q+": Math.floor((date.getMonth() + 3) / 3), //季度
  804. "S": date.getMilliseconds() //毫秒
  805. };
  806. if (/(y+)/.test(fmt)) {
  807. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  808. }
  809. for (var k in o) {
  810. if (new RegExp("(" + k + ")").test(fmt)) {
  811. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  812. }
  813. }
  814. return fmt;
  815. }
  816. function replaceAll(str, f, t) {
  817. var newStr = str.replaceAll(f, t);
  818. return newStr;
  819. }
  820. String.prototype.replaceAll = function (s1, s2) {
  821. return this.replace(new RegExp(s1, "gm"), s2);
  822. }
  823. function dragControllerDiv(resize, left, mid, box) {
  824. for (let i = 0; i < resize.length; i++) {
  825. // 鼠标按下事件
  826. resize[i].onmousedown = function (e) {
  827. //颜色改变提醒
  828. resize[i].style.borderColor = "#9d9d9d";
  829. var startX = e.clientX;
  830. resize[i].left = resize[i].offsetLeft;
  831. // 鼠标拖动事件
  832. document.onmousemove = function (e) {
  833. var endX = e.clientX;
  834. var moveLen = resize[i].left + (endX - startX); // (endx-startx)=移动的距离。resize[i].left+移动的距离=左边区域最后的宽度
  835. var maxT = box[i].clientWidth - resize[i].offsetWidth; // 容器宽度 - 左边区域的宽度 = 右边区域的宽度
  836. if (moveLen < 300) moveLen = 300; // 左边区域的最小宽度为32px
  837. if (moveLen > maxT - 150) moveLen = maxT - 150; //右边区域最小宽度为150px
  838. resize[i].style.left = moveLen; // 设置左侧区域的宽度
  839. $('.target.title').css({maxWidth: moveLen + 'px'})
  840. for (let j = 0; j < left.length; j++) {
  841. left[j].style.width = moveLen + "px";
  842. mid[j].style.width = box[i].clientWidth - moveLen - 10 + "px";
  843. }
  844. };
  845. // 鼠标松开事件
  846. document.onmouseup = function (evt) {
  847. //颜色恢复
  848. resize[i].style.borderColor = "#d6d6d6";
  849. document.onmousemove = null;
  850. document.onmouseup = null;
  851. resize[i].releaseCapture && resize[i].releaseCapture(); //当你不在需要继续获得鼠标消息就要应该调用ReleaseCapture()释放掉
  852. };
  853. resize[i].setCapture && resize[i].setCapture(); //该函数在属于当前线程的指定窗口里设置鼠标捕获
  854. return false;
  855. };
  856. }
  857. }
  858. let timer = null
  859. let dataSources = $GetDocDataSources();
  860. let arr = $GetExportDocHtml();
  861. let _html = template('template-target-sidebar-list-tpl', {
  862. list: arr.targets
  863. });
  864. if (arr.project_logo) {
  865. $('.doc-head .left img').attr('src', arr.project_logo)
  866. }
  867. $('.new').html(_html)
  868. $('.target.folder').find('i.fa').removeClass('fa-angle-down').addClass('fa-angle-right')
  869. $('.target.folder').nextAll().hide()
  870. function findFatherDom(el) {
  871. if (el.parent().parent().children(":first").hasClass('folder')) {
  872. el.parent().parent().show()
  873. console.log(el.parent().parent());
  874. el.parent().parent().children().show()
  875. el.parent().parent().children(":first").find('i').removeClass('fa-angle-right').addClass('fa-angle-down')
  876. el.parent().parent().children(":first").nextAll('.folder').find('i').removeClass('fa-angle-down').addClass('fa-angle-right')
  877. findFatherDom(el.parent().prev())
  878. } else {
  879. el.parent().children().show()
  880. return
  881. }
  882. }
  883. function dateFormat(date, fmt = 'yyyy-MM-dd hh:mm:ss') {
  884. date = new Date(date)
  885. var o = {
  886. "M+": date.getMonth() + 1, //月份
  887. "d+": date.getDate(), //日
  888. "h+": date.getHours(), //小时
  889. "m+": date.getMinutes(), //分
  890. "s+": date.getSeconds(), //秒
  891. "q+": Math.floor((date.getMonth() + 3) / 3), //季度
  892. "S": date.getMilliseconds() //毫秒
  893. };
  894. if (/(y+)/.test(fmt)) {
  895. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  896. }
  897. for (var k in o) {
  898. if (new RegExp("(" + k + ")").test(fmt)) {
  899. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  900. }
  901. }
  902. return fmt;
  903. }
  904. window.onload = function () {
  905. let url = window.location.href;
  906. let id = url.split('#')[1] ? url.split('#')[1] : '001';
  907. if (url.split('?') && url.split('?').length > 1) {
  908. var keywordUrl = url.split('?')[1];
  909. if (keywordUrl.split('#') && keywordUrl.split('#').length > 0) {
  910. var keyword = keywordUrl.split('#')[0].replace("key=", "");
  911. if (dataSources && dataSources.length > 0) {
  912. var dataList = dataSources.filter(c => c.Key === keyword);
  913. if (dataList && dataList.length > 0) {
  914. id = dataList[0].Value;
  915. }
  916. }
  917. }
  918. }
  919. if ($(`.target[data-target_id="${id}"]`).length > 0) {
  920. if (id != "001") {
  921. findFatherDom($(`.target[data-target_id="${id}"]`))
  922. }
  923. $(`.target[data-target_id="${id}"]`).trigger('click')
  924. } else {
  925. location.href = './404.html'
  926. return
  927. }
  928. var resize = document.getElementsByClassName("bar");
  929. var left = document.getElementsByClassName("box-first");
  930. var mid = document.getElementsByClassName("box-third");
  931. var box = document.getElementsByClassName("box");
  932. dragControllerDiv(resize, left, mid, box);
  933. }
  934. $('.body').show()
  935. $(document).on('click', '.target', function () {
  936. let target_id = $(this).attr('data-id')
  937. let _local_target_id = $(this).attr('data-target_id')
  938. let url = window.location.href.split('#')[0] + '#' + _local_target_id
  939. history.replaceState(null, null, url)
  940. $('.target').each((i, el) => {
  941. $(el).removeClass('active')
  942. })
  943. if ($(this).attr('data-type') == 'folder') {
  944. //$('.box-nav').show()
  945. //$(this).nextAll().show()
  946. //$(this).find('i').removeClass('fa-angle-right').addClass('fa-angle-down')
  947. //$('.box-nav .folder').show()
  948. //$('.box-nav .api').hide()
  949. $(this).find(".controlName").each(function (i, dom) {
  950. $(dom).click();
  951. });
  952. return;
  953. } else if ($(this).attr('data-type') == 'example' || $(this).attr('data-type') == 'api') {
  954. $('.box-nav').show()
  955. $('.box-nav .api').show()
  956. $('.box-nav .folder').hide()
  957. } else {
  958. $('.box-nav').hide()
  959. }
  960. $(this).addClass('active')
  961. if (!target_id) {
  962. $(this).removeClass('active')
  963. }
  964. let newdata = JSON.parse(JSON.stringify(arr))
  965. let LevelArr = []
  966. function levelTree(arr1, newarr) {
  967. arr1.forEach(item => {
  968. if (item.children && item.children.length > 0) {
  969. newarr.push(item)
  970. levelTree(item.children, newarr)
  971. } else {
  972. newarr.push(item)
  973. }
  974. })
  975. }
  976. levelTree(newdata.targets, LevelArr)
  977. LevelArr.forEach(item => {
  978. if (item.target_id == target_id) {
  979. if (item.target_type == 'example' || item.target_type == 'api') {
  980. switch (item.request.body.mode) {
  981. case "none":
  982. break;
  983. case "form-data":
  984. item.request.body.mode = "multipart/form-data";
  985. break;
  986. case "uploadFile":
  987. item.request.body.mode = "application/octet-stream; multipart/form-data; text/html[base64]";
  988. break;
  989. case "byte":
  990. item.request.body.mode = "application/octet-stream";
  991. break;
  992. case "urlencoded":
  993. item.request.body.mode = "application/x-www-form-urlencoded";
  994. break;
  995. case "json":
  996. item.request.body.mode = "application/json";
  997. break;
  998. case "xml":
  999. item.request.body.mode = "application/xml";
  1000. break;
  1001. case "javascript":
  1002. item.request.body.mode = "application/javascript";
  1003. break;
  1004. case "plain":
  1005. item.request.body.mode = "text/plain";
  1006. break;
  1007. case "html":
  1008. item.request.body.mode = "text/html";
  1009. break;
  1010. }
  1011. $('.template-nav-menu').html(template('template-nav-menu-tpl', item));
  1012. if (item.target_type != 'folder') {
  1013. let _export_data = new ClipboardJS('.CopyCurrentData', {
  1014. text: function (trigger) {
  1015. return trigger.getAttribute('data-clipboard-text');
  1016. }
  1017. });
  1018. console.log(_export_data );
  1019. _export_data.on('success', function (e) {
  1020. $('.CopyCurrentData').text('已复制').addClass('success');
  1021. e.clearSelection();
  1022. });
  1023. _export_data.on('error', function (e) {
  1024. console.log('失败');
  1025. });
  1026. }
  1027. }
  1028. let _html = template('template-example-doc-tpl', item);
  1029. $('.preview-markdown').html(_html)
  1030. if (item.target_type == 'folder') {
  1031. if ($('table.header tr').length <= 1) {
  1032. $('table.header').parent().hide()
  1033. $('table.header').parent().prev().hide()
  1034. $('.nav-folder-btn[data-id="1"]').hide()
  1035. // $('table.header tr').after('<tr><td colspan="4" style="text-align:center">暂无数据</td></tr>')
  1036. }
  1037. if ($('table.query tr').length <= 1) {
  1038. $('table.query').parent().hide()
  1039. $('table.query').parent().prev().hide()
  1040. $('.nav-folder-btn[data-id="2"]').hide()
  1041. // $('table.query tr').after('<tr><td colspan="4" style="text-align:center">暂无数据</td></tr>')
  1042. }
  1043. if ($('table.body tr').length <= 1) {
  1044. $('table.body').parent().hide()
  1045. $('table.body').parent().prev().hide()
  1046. $('.nav-folder-btn[data-id="3"]').hide()
  1047. // $('table.body tr').after('<tr><td colspan="4" style="text-align:center">暂无数据</td></tr>')
  1048. }
  1049. if ($('table.header tr').length <= 1 && $('table.query tr').length <= 1 && $('table.body tr').length <= 1) {
  1050. $('table.header').parents('.markdown-request').prev().hide()
  1051. $('.box-nav .nav-folder-btn[data-id="0"]').hide()
  1052. //$('.preview-markdown .markdown-request').after('<div style="overflow: hidden;text-align: center;height: 100%;"><img src="https://img.cdn.apipost.cn/docs/images/empty.svg" style="width:100px;margin: 70px auto 20px;;">暂无参数</div>')
  1053. $('.preview-markdown .markdown-request').after(item.tableHtml)
  1054. }
  1055. hljs.initHighlighting();
  1056. }
  1057. if (item.target_type == 'doc') {
  1058. console.log("docId:", item.request.requestId);
  1059. document.getElementById(item.request.requestId).innerHTML = item.request.description;
  1060. }
  1061. }
  1062. })
  1063. })
  1064. .on('click', '.control', function (e) {
  1065. e.stopPropagation()
  1066. let type = $(this).find('i').hasClass('fa-angle-down')
  1067. if (type) {
  1068. $(this).find('i').removeClass('fa-angle-down').addClass('fa-angle-right')
  1069. } else {
  1070. $(this).find('i').removeClass('fa-angle-right').addClass('fa-angle-down')
  1071. }
  1072. $(this).parents('.target').nextAll().toggle()
  1073. })
  1074. .on('click', '.controlName', function (e) {
  1075. e.stopPropagation()
  1076. let type = $(this).find('i').hasClass('fa-angle-down')
  1077. if (type) {
  1078. $(this).find('i').removeClass('fa-angle-down').addClass('fa-angle-right')
  1079. } else {
  1080. $(this).find('i').removeClass('fa-angle-right').addClass('fa-angle-down')
  1081. }
  1082. $(this).parents('.target').nextAll().toggle()
  1083. })
  1084. .on('blur', '.search', function (e) {
  1085. var filterValue = $("#txtSearch").val();
  1086. filterMethod(e, filterValue);
  1087. })
  1088. .on('keydown', '.search', function (e) {
  1089. if (e.keyCode == 13)
  1090. {
  1091. var filterValue = $("#txtSearch").val();
  1092. filterMethod(e, filterValue);
  1093. }
  1094. })
  1095. .on('mouseover', '.target.api', function () {
  1096. $(this).find('em').css({visibility: 'visible'})
  1097. })
  1098. .on('mouseleave', '.target.api', function () {
  1099. $(this).find('em').css({visibility: 'hidden'})
  1100. })
  1101. .on('click', '.nav-btn', function () {
  1102. let index = parseInt($(this).attr('data-id'))
  1103. $('.nav-btn').removeClass('cur')
  1104. $(this).addClass('cur')
  1105. let top = $('.box-third .title').eq(index)[0].offsetTop
  1106. $('.box-third').scrollTop(top)
  1107. })
  1108. .on('click', '.nav-folder-btn', function () {
  1109. let index = parseInt($(this).attr('data-id'))
  1110. $('.nav-folder-btn').removeClass('cur')
  1111. $(this).addClass('cur')
  1112. let top = $('.box-third .title').eq(index)[0].offsetTop
  1113. $('.box-third').scrollTop(top)
  1114. })
  1115. .on('click', '.box-first .top', function () {
  1116. arr.project.project_name = arr.project_name
  1117. arr.project.create_time = arr.create_time
  1118. arr.project.expire_day_time = arr.expire_day_time
  1119. //发布信息
  1120. var publishInfo = window.localStorage.getItem("CurrentPackagePublishInfo");
  1121. arr.project["publishInfo"] = publishInfo;
  1122. //更新接口
  1123. var activeInterfaceDatasStr = window.localStorage.getItem("CurrentInterfaceUpdateDatas");
  1124. var activeInterfaceDatas = [];
  1125. if (activeInterfaceDatasStr && activeInterfaceDatasStr.length > 0)
  1126. {
  1127. activeInterfaceDatas = JSON.parse(activeInterfaceDatasStr);
  1128. }
  1129. if (activeInterfaceDatas && activeInterfaceDatas.length > 0)
  1130. {
  1131. var publishTimeStr = dateFormat(activeInterfaceDatas[0]["发布时间"], 'yyyy-MM-dd')
  1132. arr.project["interfaceDatas"] = [{
  1133. publishTime: publishTimeStr,
  1134. list: activeInterfaceDatas
  1135. }];
  1136. }
  1137. //包
  1138. var activeVersionDatasStr = window.localStorage.getItem("CurrentVersionUpdateDatas");
  1139. var activeVersionDatas = [];
  1140. if (activeVersionDatasStr && activeVersionDatasStr.length > 0) {
  1141. activeVersionDatas = JSON.parse(activeVersionDatasStr);
  1142. }
  1143. if (activeVersionDatas && activeVersionDatas.length > 0) {
  1144. var packageStr = activeVersionDatas[0]["部署包"];
  1145. arr.project["versionDatas"] = [{
  1146. currentPackage: packageStr,
  1147. list: activeVersionDatas
  1148. }];
  1149. }
  1150. $(this).addClass('active');
  1151. let _html = template('golbal-env-tpl', arr.project);
  1152. $('.preview-markdown').html(_html);
  1153. })
  1154. .on('click', 'h3.title', function () {
  1155. let type = $(this).find('i').hasClass('fa-angle-down')
  1156. if (type) {
  1157. $(this).find('i').removeClass('fa-angle-down').addClass('fa-angle-left')
  1158. } else {
  1159. $(this).find('i').removeClass('fa-angle-left').addClass('fa-angle-down')
  1160. }
  1161. $(this).next().toggle()
  1162. })
  1163. .on('mouseover', '.export', function () {
  1164. $(this).find('.export_panel').show()
  1165. })
  1166. .on('mouseleave', '.export', function () {
  1167. $(this).find('.export_panel').hide()
  1168. })
  1169. .on('mouseover', '.CopyCurrentData', function () {
  1170. let local_target_id = $(this).attr('data-target_id')
  1171. let newdata = JSON.parse(JSON.stringify(arr))
  1172. let LevelArr = []
  1173. function levelTree(arr1, newarr) {
  1174. arr1.forEach(item => {
  1175. if (item.children && item.children.length > 0) {
  1176. newarr.push(item)
  1177. levelTree(item.children, newarr)
  1178. } else {
  1179. newarr.push(item)
  1180. }
  1181. })
  1182. }
  1183. levelTree(newdata.targets, LevelArr)
  1184. LevelArr.forEach((item) => {
  1185. if (item.target_id == local_target_id) {
  1186. $(this).attr('data-clipboard-text', JSON.stringify(item));
  1187. }
  1188. })
  1189. })
  1190. $(".box-third").scroll(function () {
  1191. let arr = []
  1192. $('.box-third .title').each((i, el) => {
  1193. arr.push($(el)[0].offsetTop)
  1194. })
  1195. arr.push(arr[arr.length - 1] + 1000)
  1196. let topHeight = $(this).scrollTop()
  1197. if ($('.target.active').hasClass('api')) {
  1198. for (let index = 0; index < arr.length; index++) {
  1199. if (arr[index] < topHeight && topHeight < arr[index + 1]) {
  1200. $('.nav-btn').removeClass('cur')
  1201. $('.nav-btn').eq(index).addClass('cur')
  1202. }
  1203. }
  1204. } else {
  1205. for (let index = 0; index < arr.length; index++) {
  1206. if (arr[index] < topHeight && topHeight < arr[index + 1]) {
  1207. $('.nav-folder-btn').removeClass('cur')
  1208. $('.nav-folder-btn').eq(index).addClass('cur')
  1209. }
  1210. }
  1211. }
  1212. });
  1213. function searchClick()
  1214. {
  1215. var filterValue = $("#txtSearch").val();
  1216. filterMethod($("#txtSearch"), filterValue);
  1217. }
  1218. function filterMethod(e, filterValue)
  1219. {
  1220. let searchVal = filterValue;
  1221. let TreeData = JSON.parse(JSON.stringify(arr.targets))
  1222. let searchArr = []
  1223. let LevelArr = []
  1224. let fatherArr = []
  1225. function openTree(tree, parent_id) {
  1226. tree.forEach((item) => {
  1227. if (item.children && item.children.length > 0) {
  1228. openTree(item.children, item.target_id)
  1229. }
  1230. item.parent_id = parent_id
  1231. })
  1232. }
  1233. openTree(TreeData, 0);
  1234. function levelTree(arr, newarr) {
  1235. arr.forEach(item => {
  1236. if (item.children && item.children.length > 0) {
  1237. newarr.push(item)
  1238. levelTree(item.children, newarr)
  1239. } else {
  1240. newarr.push(item)
  1241. }
  1242. })
  1243. }
  1244. levelTree(TreeData, LevelArr)
  1245. if ($.trim(searchVal) != '') {
  1246. LevelArr.forEach(item => {
  1247. if (item.target_type == 'folder') {
  1248. if (item.name.toString().indexOf(searchVal) > -1) {
  1249. searchArr.push(item)
  1250. }
  1251. } else {
  1252. if (item.name.toString().indexOf(searchVal) > -1 || item.method.toString().indexOf(searchVal) > -1 || item.technology.toString().indexOf(searchVal) > -1) {
  1253. searchArr.push(item)
  1254. }
  1255. }
  1256. })
  1257. searchArr.forEach(item => {
  1258. findFather(fatherArr, LevelArr, item)
  1259. })
  1260. function findFather(tempArr, arr, self) {
  1261. if (self.parent_id != 0) {
  1262. arr.filter(item => {
  1263. if (self.parent_id == item.target_id) {
  1264. findFather(tempArr, arr, item);
  1265. if (tempArr.indexOf(item) === -1) {
  1266. tempArr.push(item);
  1267. }
  1268. }
  1269. })
  1270. }
  1271. }
  1272. let finnalArr = searchArr.concat(fatherArr);
  1273. $('.target').each((i, el) => {
  1274. $(el).removeClass('active')
  1275. })
  1276. if (finnalArr && finnalArr.length > 0) {
  1277. var tempFinnalArr = finnalArr.filter(d => d.target_type === "api" || d.target_type === "doc");
  1278. if (tempFinnalArr && tempFinnalArr.length === 1) {
  1279. let item = tempFinnalArr[0];
  1280. //先处理枚举
  1281. if (item.target_type === "doc") {
  1282. //直接处理父级
  1283. var childNodes = $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().find(".target.api");
  1284. if (childNodes && childNodes.length > 0) {
  1285. var isExpand = false;
  1286. for (var m = 0; m < childNodes.length; m++) {
  1287. var mItem = childNodes[m];
  1288. var mh = $(mItem).parent().is(':hidden');
  1289. if (!mh) {
  1290. isExpand = true;
  1291. break;
  1292. }
  1293. }
  1294. if (!isExpand) {
  1295. $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().find(".controlLevelOne").click();
  1296. }
  1297. }
  1298. }
  1299. else
  1300. {
  1301. if (item.api_level === 3 || item.api_level === "3") {
  1302. //先判断父级的父级的父级是否展开
  1303. var childNodes = $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().parent().parent().parent().find(".api_level2");
  1304. if (childNodes && childNodes.length > 0) {
  1305. var isExpand = false;
  1306. for (var m = 0; m < childNodes.length; m++) {
  1307. var mItem = childNodes[m];
  1308. var mh = $(mItem).parent().parent().is(':hidden');
  1309. if (!mh) {
  1310. isExpand = true;
  1311. break;
  1312. }
  1313. }
  1314. if (!isExpand) {
  1315. $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().parent().parent().find(".controlLevelOne").click();
  1316. }
  1317. }
  1318. //先判断父级的父级是否展开
  1319. var childNodes = $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().parent().find(".api_level3");
  1320. if (childNodes && childNodes.length > 0) {
  1321. var isExpand = false;
  1322. for (var m = 0; m < childNodes.length; m++) {
  1323. var mItem = childNodes[m];
  1324. var mh = $(mItem).parent().parent().is(':hidden');
  1325. if (!mh) {
  1326. isExpand = true;
  1327. break;
  1328. }
  1329. }
  1330. if (!isExpand) {
  1331. $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().parent().find(".api_level2").click();
  1332. }
  1333. }
  1334. //在判断父级是否展开
  1335. if ($(`.target[data-target_id="${item.local_target_id}"]`).parent().is(':hidden')) {
  1336. $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().find(".api_level3").click();
  1337. }
  1338. }
  1339. else if (item.api_level === 2 || item.api_level === "2")
  1340. {
  1341. //先判断父级的父级是否展开
  1342. var childNodes = $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().parent().find(".api_level2");
  1343. if (childNodes && childNodes.length > 0) {
  1344. var isExpand = false;
  1345. for (var m = 0; m < childNodes.length; m++) {
  1346. var mItem = childNodes[m];
  1347. var mh = $(mItem).parent().parent().is(':hidden');
  1348. if (!mh) {
  1349. isExpand = true;
  1350. break;
  1351. }
  1352. }
  1353. if (!isExpand) {
  1354. $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().parent().find(".controlLevelOne").click();
  1355. }
  1356. }
  1357. //在判断父级是否展开
  1358. if ($(`.target[data-target_id="${item.local_target_id}"]`).parent().is(':hidden'))
  1359. {
  1360. $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().find(".api_level2").click();
  1361. }
  1362. }
  1363. }
  1364. jumpDefaultPage(item);
  1365. return;
  1366. }
  1367. var tempFolderArr = finnalArr.filter(d => d.target_type === "folder");
  1368. if (tempFolderArr && tempFolderArr.length > 0) {
  1369. //文件夹一级
  1370. var firstFolderArr = tempFolderArr.filter(d => d.local_parent_id === "0");
  1371. if (firstFolderArr && firstFolderArr.length === 1) {
  1372. //展开子菜单及所有
  1373. var firstFolderItem = firstFolderArr[0];
  1374. //展示子节点
  1375. var childNodes = $(`.target[data-target_id="${firstFolderItem.local_target_id}"]`).parent().find(".controlLevelTwo");
  1376. if (childNodes && childNodes.length > 0)
  1377. {
  1378. var isExpand = false;
  1379. for (var m = 0; m < childNodes.length; m++)
  1380. {
  1381. var mItem = childNodes[m];
  1382. var mh = $(mItem).parent().parent().is(':hidden');
  1383. if (!mh)
  1384. {
  1385. isExpand = true;
  1386. break;
  1387. }
  1388. }
  1389. if (!isExpand)
  1390. {
  1391. $(`.target[data-target_id="${firstFolderItem.local_target_id}"]`).find(".controlLevelOne").click();
  1392. }
  1393. }
  1394. }
  1395. //文件夹二级
  1396. var secondFolderArr = tempFolderArr.filter(d => d.local_parent_id !== "0" && (d.api_level === 2 || d.api_level === "2"));
  1397. if (secondFolderArr && secondFolderArr.length > 0) {
  1398. //展开子菜单及所有
  1399. secondFolderArr.forEach(secondFolderItem => {
  1400. //处理父菜单
  1401. var childNodes = $(`.target[data-target_id="${secondFolderItem.local_target_id}"]`).parent().parent().find(".api_level2");
  1402. if (childNodes && childNodes.length > 0) {
  1403. var isExpand = false;
  1404. for (var m = 0; m < childNodes.length; m++) {
  1405. var mItem = childNodes[m];
  1406. var mh = $(mItem).parent().parent().is(':hidden');
  1407. if (!mh) {
  1408. isExpand = true;
  1409. break;
  1410. }
  1411. }
  1412. if (!isExpand) {
  1413. $(`.target[data-target_id="${secondFolderItem.local_target_id}"]`).parent().parent().find(".controlLevelOne").click();
  1414. }
  1415. }
  1416. //处理子菜单
  1417. if (secondFolderItem.children && secondFolderItem.children.length > 0) {
  1418. var isChildExpand = secondFolderItem.children.some(mc => {
  1419. var childFolder = $(`.target[data-target_id="${mc.local_target_id}"]`).parent();
  1420. if (!childFolder.is(':hidden')) {
  1421. return true;
  1422. }
  1423. return false;
  1424. });
  1425. if (!isChildExpand) {
  1426. $(`.target[data-target_id="${secondFolderItem.local_target_id}"]`).find(".api_level2").click();
  1427. }
  1428. }
  1429. });
  1430. }
  1431. //文件夹三级
  1432. var secondFolderArr = tempFolderArr.filter(d => d.local_parent_id !== "0" && (d.api_level === 3 || d.api_level === "3"));
  1433. if (secondFolderArr && secondFolderArr.length > 0) {
  1434. //展开子菜单及所有
  1435. secondFolderArr.forEach(secondFolderItem => {
  1436. //处理父菜单
  1437. var childNodes = $(`.target[data-target_id="${secondFolderItem.local_target_id}"]`).parent().parent().parent().parent().find(".api_level2");
  1438. if (childNodes && childNodes.length > 0) {
  1439. var isExpand = false;
  1440. for (var m = 0; m < childNodes.length; m++) {
  1441. var mItem = childNodes[m];
  1442. var mh = $(mItem).parent().parent().is(':hidden');
  1443. if (!mh) {
  1444. isExpand = true;
  1445. break;
  1446. }
  1447. }
  1448. if (!isExpand) {
  1449. $(`.target[data-target_id="${secondFolderItem.local_target_id}"]`).parent().parent().parent().parent().find(".controlLevelOne").click();
  1450. }
  1451. }
  1452. var childNodes = $(`.target[data-target_id="${secondFolderItem.local_target_id}"]`).parent().parent().find(".api_level3");
  1453. if (childNodes && childNodes.length > 0) {
  1454. var isExpand = false;
  1455. for (var m = 0; m < childNodes.length; m++) {
  1456. var mItem = childNodes[m];
  1457. var mh = $(mItem).parent().parent().is(':hidden');
  1458. if (!mh) {
  1459. isExpand = true;
  1460. break;
  1461. }
  1462. }
  1463. if (!isExpand) {
  1464. $(`.target[data-target_id="${secondFolderItem.local_target_id}"]`).parent().parent().find(".api_level2").click();
  1465. }
  1466. }
  1467. //处理子菜单
  1468. if (secondFolderItem.children && secondFolderItem.children.length > 0) {
  1469. var isChildExpand = secondFolderItem.children.some(mc => {
  1470. var childFolder = $(`.target[data-target_id="${mc.local_target_id}"]`).parent();
  1471. if (!childFolder.is(':hidden')) {
  1472. return true;
  1473. }
  1474. return false;
  1475. });
  1476. if (!isChildExpand) {
  1477. $(`.target[data-target_id="${secondFolderItem.local_target_id}"]`).find(".api_level3").click();
  1478. }
  1479. }
  1480. });
  1481. }
  1482. }
  1483. //$('.target').hide()
  1484. $('.target[data-target_id="001"]').show();
  1485. finnalArr.forEach(item => {
  1486. if (item.target_type === "api" || item.target_type === "doc") {
  1487. $(`.target[data-target_id="${item.local_target_id}"]`).addClass('active');
  1488. if (item.target_type === "doc") {
  1489. //直接处理父级
  1490. var childNodes = $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().find(".target.api");
  1491. if (childNodes && childNodes.length > 0) {
  1492. var isExpand = false;
  1493. for (var m = 0; m < childNodes.length; m++) {
  1494. var mItem = childNodes[m];
  1495. var mh = $(mItem).parent().is(':hidden');
  1496. if (!mh) {
  1497. isExpand = true;
  1498. break;
  1499. }
  1500. }
  1501. if (!isExpand) {
  1502. $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().find(".controlLevelOne").click();
  1503. }
  1504. }
  1505. }
  1506. else {
  1507. if (item.api_level === 3 || item.api_level === "3") {
  1508. //先判断父级的父级的父级是否展开
  1509. var childNodes = $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().parent().parent().parent().find(".api_level2");
  1510. if (childNodes && childNodes.length > 0) {
  1511. var isExpand = false;
  1512. for (var m = 0; m < childNodes.length; m++) {
  1513. var mItem = childNodes[m];
  1514. var mh = $(mItem).parent().parent().is(':hidden');
  1515. if (!mh) {
  1516. isExpand = true;
  1517. break;
  1518. }
  1519. }
  1520. if (!isExpand) {
  1521. $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().parent().parent().find(".controlLevelOne").click();
  1522. }
  1523. }
  1524. //先判断父级的父级是否展开
  1525. var childNodes = $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().parent().find(".api_level3");
  1526. if (childNodes && childNodes.length > 0) {
  1527. var isExpand = false;
  1528. for (var m = 0; m < childNodes.length; m++) {
  1529. var mItem = childNodes[m];
  1530. var mh = $(mItem).parent().parent().is(':hidden');
  1531. if (!mh) {
  1532. isExpand = true;
  1533. break;
  1534. }
  1535. }
  1536. if (!isExpand) {
  1537. $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().parent().find(".api_level2").click();
  1538. }
  1539. }
  1540. //在判断父级是否展开
  1541. if ($(`.target[data-target_id="${item.local_target_id}"]`).parent().is(':hidden')) {
  1542. $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().find(".api_level3").click();
  1543. }
  1544. }
  1545. else if (item.api_level === 2 || item.api_level === "2") {
  1546. //先判断父级的父级是否展开
  1547. var childNodes = $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().parent().find(".api_level2");
  1548. if (childNodes && childNodes.length > 0) {
  1549. var isExpand = false;
  1550. for (var m = 0; m < childNodes.length; m++) {
  1551. var mItem = childNodes[m];
  1552. var mh = $(mItem).parent().parent().is(':hidden');
  1553. if (!mh) {
  1554. isExpand = true;
  1555. break;
  1556. }
  1557. }
  1558. if (!isExpand) {
  1559. $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().parent().find(".controlLevelOne").click();
  1560. }
  1561. }
  1562. //在判断父级是否展开
  1563. if ($(`.target[data-target_id="${item.local_target_id}"]`).parent().is(':hidden')) {
  1564. $(`.target[data-target_id="${item.local_target_id}"]`).parent().parent().find(".api_level2").click();
  1565. }
  1566. }
  1567. }
  1568. }
  1569. else {
  1570. $(`.target[data-target_id="${item.local_target_id}"]`).removeClass('active')
  1571. }
  1572. });
  1573. if (tempFinnalArr && tempFinnalArr.length > 0) {
  1574. let firstItem = tempFinnalArr[0];
  1575. jumpDefaultPage(firstItem);
  1576. }
  1577. }
  1578. } else {
  1579. $('.target').parent().show()
  1580. $('.target').show()
  1581. }
  1582. }
  1583. function jumpDefaultPage(item)
  1584. {
  1585. //独立处理
  1586. let target_id = item.target_id;
  1587. let _local_target_id = item.local_target_id;
  1588. let url = window.location.href.split('#')[0] + '#' + _local_target_id;
  1589. var curObject = $(`.target[data-target_id="${item.local_target_id}"]`);
  1590. var h6 = $(".new").scrollTop();
  1591. var h5 = curObject.position().top;
  1592. if (h5 > 600) {
  1593. if (h5 > 100) {
  1594. h5 = h5 - 150;
  1595. }
  1596. var newHeight = h5 + h6
  1597. $('.new').scrollTop(newHeight);
  1598. }
  1599. else if (h5 < 0) {
  1600. var newHeight = h5 + h6;
  1601. if (newHeight > 100) {
  1602. newHeight = newHeight - 150;
  1603. }
  1604. $('.new').scrollTop(newHeight);
  1605. }
  1606. history.replaceState(null, null, url);
  1607. if (curObject.attr('data-type') == 'example' || curObject.attr('data-type') == 'api') {
  1608. $('.box-nav').show()
  1609. $('.box-nav .api').show()
  1610. $('.box-nav .folder').hide()
  1611. } else {
  1612. $('.box-nav').hide()
  1613. }
  1614. curObject.addClass('active');
  1615. if (!target_id) {
  1616. curObject.removeClass('active')
  1617. }
  1618. if (item.target_type == 'example' || item.target_type == 'api') {
  1619. switch (item.request.body.mode) {
  1620. case "none":
  1621. break;
  1622. case "form-data":
  1623. item.request.body.mode = "multipart/form-data";
  1624. break;
  1625. case "uploadFile":
  1626. item.request.body.mode = "application/octet-stream; multipart/form-data; text/html[base64]";
  1627. break;
  1628. case "byte":
  1629. item.request.body.mode = "application/octet-stream";
  1630. break;
  1631. case "urlencoded":
  1632. item.request.body.mode = "application/x-www-form-urlencoded";
  1633. break;
  1634. case "json":
  1635. item.request.body.mode = "application/json";
  1636. break;
  1637. case "xml":
  1638. item.request.body.mode = "application/xml";
  1639. break;
  1640. case "javascript":
  1641. item.request.body.mode = "application/javascript";
  1642. break;
  1643. case "plain":
  1644. item.request.body.mode = "text/plain";
  1645. break;
  1646. case "html":
  1647. item.request.body.mode = "text/html";
  1648. break;
  1649. }
  1650. $('.template-nav-menu').html(template('template-nav-menu-tpl', item));
  1651. if (item.target_type != 'folder') {
  1652. let _export_data = new ClipboardJS('.CopyCurrentData', {
  1653. text: function (trigger) {
  1654. return trigger.getAttribute('data-clipboard-text');
  1655. }
  1656. });
  1657. console.log(_export_data);
  1658. _export_data.on('success', function (e) {
  1659. $('.CopyCurrentData').text('已复制').addClass('success');
  1660. e.clearSelection();
  1661. });
  1662. _export_data.on('error', function (e) {
  1663. console.log('失败');
  1664. });
  1665. }
  1666. }
  1667. let _html = template('template-example-doc-tpl', item);
  1668. $('.preview-markdown').html(_html)
  1669. if (item.target_type == 'doc') {
  1670. console.log("docId:", item.request.requestId);
  1671. document.getElementById(item.request.requestId).innerHTML = item.request.description;
  1672. }
  1673. }
  1674. </script>
  1675. </body>
  1676. </html>