lowerCodeHelper

低代码平台助手

当前为 2024-01-19 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name lowerCodeHelper
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3.8
  5. // @description 低代码平台助手
  6. // @author Ziker
  7. // @match https://ops.iyunquna.com/63008/*
  8. // @match http://localhost:63342/api/file/*
  9. // @require https://code.jquery.com/jquery-3.4.1.min.js
  10. // @icon https://favicon.qqsuu.cn/work.yqn.com
  11. // @note 2023年12月18日20:26:31 V0.3.4 fix RT 显示BUG
  12. // @note 2024年01月04日11:50:57 V0.3.5 支持自定义包名接口打开文件
  13. // @note 2024年01月10日11:00:40 V0.3.6 修复子流程,mq,job 跳转不显示
  14. // @note 2024年01月15日19:46:34 V0.3.7 修复自定义包名 子流程,mq,job 不跳转,MQ 消费RT显示
  15. // @note 2024年01月19日17:22:12 V0.3.8 顶部工具栏按钮新增多个工具按钮
  16. // @grant GM_openInTab
  17. // @grant unsafeWindow
  18. // @grant window.close
  19. // @grant window.focus
  20. // @run-at document-body
  21. // @noframes
  22. // @license AGPL License
  23. // ==/UserScript==
  24.  
  25. window.jq = $.noConflict(true);
  26.  
  27. (function (window) {
  28. window.pageHelper = {
  29. // 等待元素可见
  30. waitElementVisible(visibleTag, index, fun) {
  31. let node = jq(visibleTag)
  32. if (node === null || node[index] === null || node[index] === undefined) {
  33. setTimeout(() => {
  34. pageHelper.waitElementVisible(visibleTag, index, fun)
  35. }, 500)
  36. } else {
  37. fun()
  38. }
  39. },
  40. getCurrentApiIndex() {
  41. const nodes = document.getElementsByClassName("bar-tab")
  42. for (let i = 0; i < nodes.length; i++) {
  43. if (nodes[i].className.indexOf("bar-tab-selected") > 0) {
  44. return i
  45. }
  46. }
  47. return -1
  48. },
  49. getCurrentApiId() {
  50. const nodes = document.getElementsByClassName("tab-content-presentation-components")
  51. if (nodes.length === 0) {
  52. return null
  53. }
  54. let className = nodes[this.getCurrentApiIndex()].className
  55. return className.substring(className.indexOf("theia-tab-") + "theia-tab-".length)
  56. },
  57. getAppId() {
  58. return parseInt(new URLSearchParams(window.location.href.split('?')[1]).get('appId'))
  59. },
  60. sleep(duration) {
  61. return new Promise(resolve => {
  62. setTimeout(resolve, duration)
  63. })
  64. },
  65. showToast(msg, duration) {
  66. // 显示提示
  67. duration = isNaN(duration) ? 3000 : duration
  68. const m = document.createElement('div')
  69. m.innerHTML = msg
  70. m.style.cssText = "display: flex;justify-content: center;align-items: center;width:60%; min-width:180px; " +
  71. "background:#000000; opacity:0.98; height:auto;min-height: 50px;font-size:25px; color:#fff; " +
  72. "line-height:30px; text-align:center; border-radius:4px; position:fixed; top:85%; left:20%; z-index:999999;"
  73. document.body.appendChild(m)
  74. setTimeout(function () {
  75. const d = 0.5
  76. m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in'
  77. m.style.opacity = '0'
  78. setTimeout(function () {
  79. document.body.removeChild(m)
  80. }, d * 1000)
  81. }, duration)
  82. },
  83. // 关闭窗口
  84. closeWindow() {
  85. window.opener = null
  86. window.open('', '_self')
  87. window.close()
  88. },
  89. formatString(str, len, padding) {
  90. const diff = len - str.toString().length
  91. if (diff > 0) {
  92. return padding.repeat(diff) + str
  93. } else {
  94. return str
  95. }
  96. },
  97. initSetting() {
  98. const customSetting = document.createElement("div")
  99. document.body.appendChild(customSetting)
  100. customSetting.innerHTML = `
  101. <div id="copy-setting"
  102. style="display: none;position: absolute;top: 0;right: 0;background-color: #fff3f3;padding: 10px;width: 600px;z-index: 9999">
  103. <p>拷贝动作</p>
  104. <p><label>Copy File Id <input type="radio" name="copyValue" value="1" /></label></p>
  105. <p><label>Rest Api Open File <input type="radio" name="copyValue" value="2" checked/></label>&nbsp;&nbsp;&nbsp;较新版本IDEA需要下载 <a target="_blank" href="https://plugins.jetbrains.com/plugin/19991-ide-remote-control">IDE Remote Control </a> 插件</p>
  106. <p><label>ToolBox Open File <input type="radio" name="copyValue" value="3" /></label>&nbsp;&nbsp;&nbsp;需要下载 <a target="_blank" href="https://www.jetbrains.com/toolbox-app/">Jetbrains ToolBox</a> 工具箱软件</p>
  107. <div id="projectPath" style="visibility: visible"><p><label><input name="path" style="width: 100%" type="text" placeholder="项目路径截止到 src 前 E:/yqnProject/yqn-wms/yqn-wms-rest-provider/"/></label></p></div>
  108. <p style="visibility: hidden"><label>同时打开编排IDE <input type="checkbox" name="openIDE" /></label>&nbsp;&nbsp;&nbsp;</p>
  109. <div style="display: flex;margin: 5px;justify-content: space-between">
  110. <button id="save" lang="zh" type="button" class="ant-btn ant-btn-default perf-tracked yqn-button"><span
  111. style="margin-left: 5px;">save</span></button>
  112. <button id="close" lang="zh" type="button" class="ant-btn ant-btn-default perf-tracked yqn-button"><span
  113. style="margin-left: 5px;">close</span></button>
  114. </div>
  115. </div>
  116. `
  117. let copyValue = localStorage.getItem("copyValue")
  118. copyValue = copyValue === null || copyValue === undefined ? 1 : copyValue
  119. document.querySelector('input[name="copyValue"][value="' + copyValue + '"]').checked = true
  120. document.getElementById("projectPath").style.visibility = copyValue === "2" ? "visible" : "hidden"
  121.  
  122. let path = localStorage.getItem("path")
  123. document.querySelector('input[name="path"]').value = path === null || path === undefined ? null : path
  124.  
  125. let openIDE = JSON.parse(localStorage.getItem("openIDE"))
  126. document.querySelector('input[name="openIDE"]').checked = openIDE === null || openIDE === undefined ? false : openIDE
  127.  
  128. const radios = document.querySelectorAll('input[name="copyValue"]')
  129. for (let i = 0; i < radios.length; i++) {
  130. radios[i].onchange = () => {
  131. const remoteRadio = document.querySelector('input[name="copyValue"]:checked')
  132. document.getElementById("projectPath").style.visibility = remoteRadio.value === "2" ? "visible" : "hidden"
  133. }
  134. }
  135. document.getElementById("save").addEventListener("click", () => {
  136. const remoteRadio = document.querySelector('input[name="copyValue"]:checked').value
  137. const pathInput = document.querySelector('input[name="path"]').value
  138. const openIDEValue = document.querySelector('input[name="openIDE"]').checked
  139. if (remoteRadio === '2' && (pathInput === null || pathInput.length === 0)) {
  140. this.showToast("路径不可为空", 1000)
  141. } else {
  142. localStorage.setItem("copyValue", remoteRadio)
  143. localStorage.setItem("path", pathInput)
  144. localStorage.setItem("openIDE", JSON.stringify(openIDEValue))
  145. this.showToast("保存成功", 1000)
  146. }
  147. })
  148. document.getElementById("close").addEventListener("click", () => {
  149. document.getElementById("copy-setting").style.display = "none"
  150. })
  151. }
  152. }
  153. })(window);
  154.  
  155.  
  156. (function () {
  157. let historyTrace = ''
  158. 'use strict';
  159. let appName = null
  160. let packageNameMap = []
  161. let typeMap = []
  162. jq(document).ready(function () {
  163. if (window.location.href.indexOf("localhost:63342/api/file/") >= 0) {
  164. window.pageHelper.closeWindow()
  165. return
  166. }
  167. // 监听api tab变动
  168. waitObserve(".tabs-bar", () => {
  169. // bar切换关闭首页显示
  170. const homePage = document.querySelector(".tab-home-page");
  171. const tabsBar = document.querySelector(".tabs-bar");
  172. if (nonNull(homePage) && nonNull(tabsBar) && nonNull(tabsBar.childNodes) && tabsBar.childNodes.length > 0) {
  173. homePage.style.display = 'none'
  174. }
  175.  
  176. // 应用接口面板
  177. const appPanelTag = ".tab-content-presentation-components.theia-tab-" + window.pageHelper.getCurrentApiId()
  178. // 监听属性面板变动
  179. waitObserve(appPanelTag + " .p-8", () => {
  180. const p8 = document.querySelector(appPanelTag + " .p-8")
  181. const panel = p8.querySelector(".ant-form.ant-form-vertical.yqn-form")
  182. if (nonNull(panel) && isNull(panel.querySelector(".customScriptInfo"))) {
  183. const div = document.createElement("div")
  184. div.className = "customScriptInfo"
  185. panel.appendChild(div)
  186. // 获取当前 NodeName
  187. const childProcessNode = panel.querySelector("#code")
  188. const codeSpan = p8.querySelector(".dashboard-code span")
  189. if (isNull(childProcessNode) && isNull(codeSpan)) {
  190. return
  191. }
  192. let nodeName = nonNull(childProcessNode) ? childProcessNode.value : codeSpan.textContent
  193. // 获取当前节点信息
  194. getNodeInfo(nodeName, node => {
  195. // 处理信息
  196. const divNode = document.querySelector(appPanelTag + " .customScriptInfo")
  197. // 清空显示
  198. divNode.innerHTML = ""
  199. // 脚本
  200. if (nonNull(node.scriptId)) {
  201. divNode.appendChild(createTextButton("脚本:" + node.scriptId, () => copyToClipboard(node.scriptId)))
  202. }
  203. // 入参
  204. let id = node.inputScriptId
  205. const inputScriptIds = node.inputScriptIds
  206. if (nonNull(inputScriptIds)) {
  207. id = nonNull(id) ? id : inputScriptIds.example
  208. id = nonNull(id) ? id : inputScriptIds.record
  209. id = nonNull(id) ? id : inputScriptIds.recordList
  210. id = nonNull(id) ? id : inputScriptIds.condition
  211. id = nonNull(id) ? id : inputScriptIds.id
  212. }
  213. let isJava = true
  214. if (isNull(id) && nonNull(node.dslBulidData)) {
  215. id = node.dslBulidData.dslScriptId
  216. isJava = false
  217. }
  218. if (nonNull(id)) {
  219. divNode.appendChild(createTextButton("入参:" + id, () => copyToClipboard(id, isJava)))
  220. }
  221. // 条件
  222. const executeScriptId = node.executeScriptId
  223. if (nonNull(executeScriptId)) {
  224. divNode.appendChild(createTextButton("条件:" + executeScriptId, () => copyToClipboard(executeScriptId)))
  225. }
  226. // 校验
  227. const assertScriptId = node.assertScriptId
  228. if (nonNull(assertScriptId)) {
  229. divNode.appendChild(createTextButton("校验:" + assertScriptId, () => copyToClipboard(assertScriptId)))
  230. }
  231. })
  232. }
  233. })
  234.  
  235. // 监听执行历史面板变动
  236. const executeHistoryBodyTag = appPanelTag + " .test-split-item.test-split-item-right .ant-table-body tbody"
  237. waitObserve(executeHistoryBodyTag, () => {
  238. const lines = document.querySelectorAll(executeHistoryBodyTag + " .ant-table-row.ant-table-row-level-0")
  239. if (nonNull(lines)) {
  240. if (nonNull(lines[0].querySelector(".customer-button-div"))) {
  241. return
  242. }
  243. appendFlagNode(lines[0], "customer-button-div")
  244. getExecuteHistory(content => {
  245. for (let i = 0; i < content.length; i++) {
  246. const tds = lines[i].querySelectorAll("td")
  247. const actionCol = tds[tds.length - 1]
  248. const detailButton = actionCol.querySelectorAll("button")[0]
  249.  
  250. detailButton.style.display = "none"
  251. actionCol.insertBefore(createTextButton("RT:" + content[i].rt, () => {
  252. detailButton.click()
  253. historyTrace = tds[2].innerText
  254. }), detailButton)
  255. }
  256. })
  257. }
  258. })
  259.  
  260. const currentApiId = window.pageHelper.getCurrentApiId();
  261. if (isNull(packageNameMap[currentApiId])) {
  262. getApiPackageName(process => {
  263. packageNameMap[currentApiId] = isNull(process.packageName) || process.packageName === '' ? 'api_' + process.id : process.packageName
  264. const type = isNull(process.type) || process.type === '' ? 'api' : process.type;
  265. if (type === 'childProcess') {
  266. typeMap[currentApiId] = 'api'
  267. } else {
  268. typeMap[currentApiId] = type
  269. }
  270. })
  271. }
  272. })
  273.  
  274. // 监听body变动
  275. waitObserve("body", () => {
  276. // 监听执行日志流程图变动
  277. const processPanelTag = ".node-bpmn #canvas .bjs-container .djs-container .viewport .layer-base"
  278. waitObserve(processPanelTag, () => {
  279. const processPanel = document.querySelector(processPanelTag)
  280. if (isNull(processPanel.querySelector(".customer-rt"))) {
  281. appendFlagNode(processPanel, "customer-rt")
  282. const oldRtNode = processPanel.querySelectorAll(".bpmn-tiny-label");
  283. if (nonNull(oldRtNode)) {
  284. oldRtNode.forEach(v => v.style.display = "none")
  285. }
  286. getByTraceId(apiNodeLogList => {
  287. for (let i = 0; i < apiNodeLogList.length; i++) {
  288. const log = apiNodeLogList[i]
  289. const textNode = processPanel.querySelector("[data-element-id='" + log.nodeId + "'] text")
  290. console.log("ziker", textNode)
  291. if (isNull(textNode)) {
  292. continue
  293. }
  294. const tspan = textNode.querySelector("tspan")
  295. if (nonNull(tspan)) {
  296. const rtNode = tspan.cloneNode(true)
  297. textNode.appendChild(rtNode)
  298. rtNode.setAttribute("x", "65")
  299. rtNode.setAttribute("y", "15")
  300. rtNode.innerHTML = window.pageHelper.formatString(log.rt, 4, '&nbsp;&nbsp;')
  301. }
  302. }
  303. })
  304. }
  305. }, false)
  306. })
  307.  
  308. // 工具栏设置按钮
  309. waitObserve(".app-actions", () => {
  310. const buttonLists = document.querySelector(".app-actions")
  311. if (isNull(buttonLists) || nonNull(document.querySelector(".setting-flag"))) {
  312. return
  313. }
  314. appendFlagNode(document.body, "setting-flag")
  315. appendToolBarButton("设置", () => {
  316. const settingPanel = document.getElementById("copy-setting")
  317. settingPanel.style.display = settingPanel.style.display === 'block' ? 'none' : "block"
  318. })
  319. appendToolBarButton("首页", () => {
  320. // 关闭首页显示
  321. const homePage = document.querySelector(".tab-home-page");
  322. const tabsBar = document.querySelector(".tabs-bar");
  323. if (nonNull(homePage) && nonNull(tabsBar) && nonNull(tabsBar.childNodes) && tabsBar.childNodes.length > 0) {
  324. homePage.style.display = homePage.style.display === 'block' ? 'none' : "block"
  325. }
  326. })
  327. appendToolBarButton("需求列表", () => {
  328. getVersionId(versionData => {
  329. if (isNull(versionData) || versionData.length === 0) {
  330. window.pageHelper.showToast("未在YWork查询到当前分支与之对应需求版本,先在YWork发布清单添加当前分支")
  331. } else {
  332. if (versionData.length > 1) {
  333. let name = "";
  334. for (let i = 0; i < versionData.length; i++) {
  335. name += versionData[i].appVersion + " ";
  336. }
  337. window.pageHelper.showToast("当前分支查到了如下 " + name + " 多个版本,不能直接跳转!")
  338. } else {
  339. window.open("https://ops.iyunquna.com/request/list/3?versionId=" + versionData[0].id)
  340. }
  341. }
  342. })
  343. })
  344. appendToolBarButton("全量发布", () => {
  345. window.pageHelper.showToast("正在发布", 3000)
  346. getVersionId(versionData => {
  347. if (isNull(versionData) || versionData.length === 0) {
  348. window.pageHelper.showToast("未在YWork查询到当前分支与之对应版本,先在YWork发布清单添加当前分支")
  349. } else {
  350. if (versionData.length > 1) {
  351. let name = "";
  352. for (let i = 0; i < versionData.length; i++) {
  353. name += versionData[i].appVersion + " ";
  354. }
  355. window.pageHelper.showToast("当前分支查到了如下 " + name + " 多个版本,不能直接发布!")
  356. } else {
  357. getPublishId(versionData[0].id, publishData => {
  358. if (isNull(publishData) || isNull(publishData.publishId)) {
  359. window.pageHelper.showToast("发布清单查询失败")
  360. } else {
  361. publish(publishData.publishId, pushData => {
  362. if (isNull(pushData) || pushData.result !== true) {
  363. window.pageHelper.showToast("发布失败", 2000)
  364. } else {
  365. window.pageHelper.showToast("发布成功", 1500)
  366. }
  367. })
  368. }
  369. })
  370. }
  371. }
  372. })
  373. })
  374. appendToolBarButton("发布记录", () => {
  375. window.open("https://ops.iyunquna.com/release-record/manage?appId=" + window.pageHelper.getAppId())
  376. })
  377. })
  378.  
  379. window.pageHelper.initSetting()
  380. getAppProjectName(data => {
  381. appName = data
  382. console.log("项目名称", data)
  383. })
  384. })
  385.  
  386.  
  387. function nonNull(o) {
  388. return o !== null && o !== undefined
  389. }
  390.  
  391. function isNull(o) {
  392. return o === null || o === undefined
  393. }
  394.  
  395.  
  396. // 追加标记节点
  397. function appendFlagNode(node, flag) {
  398. const divFlag = document.createElement("div")
  399. node.appendChild(divFlag)
  400. divFlag.className = flag
  401. divFlag.style.display = "none"
  402. }
  403.  
  404. // 等待出现并监听变化
  405. function waitObserve(visibleTag, fun, attributes = true) {
  406. window.pageHelper.waitElementVisible(visibleTag, 0, () => {
  407. new MutationObserver(function () {
  408. fun()
  409. }).observe(document.querySelector(visibleTag), {
  410. attributes: attributes,
  411. childList: true,
  412. subtree: true,
  413. characterData: true
  414. })
  415. })
  416. }
  417.  
  418. function copyToClipboard(text, isJava = true) {
  419. let copyValue = localStorage.getItem("copyValue")
  420. copyValue = copyValue === null || copyValue === undefined ? '1' : copyValue
  421. if (copyValue === '1') {
  422. let textarea = document.createElement('textarea')
  423. textarea.value = text
  424. document.body.appendChild(textarea)
  425. textarea.select()
  426. document.execCommand('copy')
  427. document.body.removeChild(textarea)
  428. window.pageHelper.showToast("已拷贝 " + text, 1500)
  429. } else if (copyValue === '2') {
  430. let path = localStorage.getItem("path")
  431. path = path === null || path === undefined ? null : (path.endsWith("/") ? path : path + '/')
  432. otherReq("http://127.0.0.1:63342/api/file/" + path + "src/main/java/com/yqn/framework/composer/" + typeMap[window.pageHelper.getCurrentApiId()] +
  433. "/" + packageNameMap[window.pageHelper.getCurrentApiId()] + "/script/Script_" + text + (isJava ? ".java" : ".json"))
  434. window.pageHelper.showToast("已打开文件,如未打开,检查插件是否安装以及path是否正确", 2000)
  435. } else if (copyValue === '3') {
  436. const url = 'jetbrains://idea/navigate/reference?project=' + appName + '&fqn=com.yqn.framework.composer.' + typeMap[window.pageHelper.getCurrentApiId()] +
  437. '.' + packageNameMap[window.pageHelper.getCurrentApiId()] + '.script.Script_' + text;
  438. console.log("ziker", url)
  439. window.open(url)
  440. window.pageHelper.showToast("已打开文件,如未打开,请确认已安装Jetbrains Toolbox ", 2000)
  441. }
  442. }
  443.  
  444. // 创建按钮
  445. function createTextButton(name, listener) {
  446. const button = document.createElement("button")
  447. button.type = "button"
  448. button.id = name
  449. button.className = "ant-btn ant-btn-link perf-tracked yqn-button yqn-link-no-padding customer-button"
  450. button.style.marginRight = '5px'
  451. button.onclick = listener
  452. const span = document.createElement("span")
  453. span.textContent = name
  454. button.appendChild(span)
  455. return button
  456. }
  457.  
  458. // 创建工具栏按钮
  459. function appendToolBarButton(name, listener) {
  460. const buttonLists = document.querySelector(".app-actions")
  461. const settingButton = document.createElement("div")
  462. settingButton.style.marginLeft = '10px'
  463. const button = document.createElement("button")
  464. button.type = "button"
  465. button.id = name
  466. button.className = "ant-btn ant-btn-default perf-tracked yqn-button"
  467. button.onclick = listener
  468. const span = document.createElement("span")
  469. span.textContent = name
  470. button.appendChild(span)
  471. settingButton.appendChild(button)
  472. buttonLists.appendChild(settingButton)
  473. }
  474.  
  475. // 获取分支YWork版本ID
  476. function getVersionId(fuc) {
  477. remoteReq('/api/42070/yqn_integrate/bg/integrate_app_version/v2/query_application_version', {
  478. "appBranch": localStorage.getItem("defaultBranch")
  479. }, data => {
  480. fuc(data)
  481. })
  482. }
  483.  
  484. // 获取应用清单ID
  485. function getPublishId(versionId, fuc) {
  486. remoteReq('/api/42070/api/call/cicd/publish/get_app_list', {
  487. "appVersionId": versionId
  488. }, data => {
  489. fuc(data)
  490. })
  491. }
  492.  
  493. // 发布
  494. function publish(publishId, fuc) {
  495. remoteReq('/api/42070/api/call/cicd/app/publish', {
  496. "colorTagId": "",
  497. "env": 4,
  498. "ignorePublishClash": 0,
  499. "publishId": publishId,
  500. "appIds": [window.pageHelper.getAppId()],
  501. "ignoreBranchBehind": 0
  502. }, data => {
  503. fuc(data)
  504. })
  505. }
  506.  
  507.  
  508. const addressArr = ['', '/process', '/mq', '/job']
  509.  
  510. function getApiPackageName(fuc, apiMode = 0) {
  511. remoteReq('/api/42080/api' + addressArr[apiMode] + '/details_composer', {
  512. "id": window.pageHelper.getCurrentApiId(),
  513. }, data => {
  514. if (isNull(data)) {
  515. if (apiMode === 0) {
  516. getApiPackageName(fuc, 1)
  517. getApiPackageName(fuc, 2)
  518. getApiPackageName(fuc, 3)
  519. }
  520. return
  521. }
  522. let processDefine = JSON.parse(data.processDefine)
  523. fuc(processDefine.process)
  524. })
  525. }
  526.  
  527. // 拿流程信息
  528. function getNodeInfo(nodeName, fuc, apiMode = 0) {
  529. remoteReq('/api/42080/api' + addressArr[apiMode] + '/details_composer', {
  530. "id": window.pageHelper.getCurrentApiId(),
  531. }, data => {
  532. if (isNull(data)) {
  533. if (apiMode === 0) {
  534. getNodeInfo(nodeName, fuc, 1)
  535. getNodeInfo(nodeName, fuc, 2)
  536. getNodeInfo(nodeName, fuc, 3)
  537. }
  538. return
  539. }
  540. let processDefine = JSON.parse(data.processDefine)
  541. for (let i = 0; i < processDefine.nodes.length; i++) {
  542. if (processDefine.nodes[i].code === nodeName) {
  543. fuc(processDefine.nodes[i])
  544. break
  545. }
  546. }
  547. })
  548. }
  549.  
  550. // 拿历史执行数据
  551. function getExecuteHistory(fuc) {
  552. remoteReq('/api/42086/apiLog/list', {}, data => {
  553. if (nonNull(data) && nonNull(data.content)) {
  554. fuc(data.content)
  555. }
  556. })
  557. }
  558.  
  559. // 拿 trace 执行数据
  560. function getByTraceId(fuc, apiMode = 0) {
  561. const apiType = ['api', 'process', 'consumer', 'job']
  562. remoteReq('/api/42086/apiLog/getByTraceId', {
  563. "traceIdLike": historyTrace,
  564. "testCaseId": null,
  565. "apiTypeCode": apiMode === 0 ? "api" : apiType[apiMode]
  566. }, data => {
  567. if (nonNull(data) && nonNull(data.apiNodeLogList) && data.apiNodeLogList.length !== 0) {
  568. fuc(data.apiNodeLogList)
  569. } else if (apiMode === 0) {
  570. getByTraceId(fuc, 1)
  571. getByTraceId(fuc, 2)
  572. getByTraceId(fuc, 3)
  573. }
  574. })
  575. }
  576.  
  577. // 获取应用名称
  578. function getAppProjectName(fuc) {
  579. remoteReq('/api/42080/application/getById', {}, data => {
  580. if (nonNull(data)) {
  581. fuc(data.appName)
  582. }
  583. })
  584. }
  585.  
  586.  
  587. function remoteReq(url, model, fuc) {
  588. model.apiId = window.pageHelper.getCurrentApiId()
  589. model.appId = window.pageHelper.getAppId()
  590. if (isNull(model.env)) {
  591. model.env = "qa4"
  592. }
  593. model.page = 1
  594. model.size = 20
  595. jq.ajax({
  596. url: 'https://gw-ops.iyunquna.com' + url,
  597. method: 'POST',
  598. xhrFields: {
  599. withCredentials: true
  600. },
  601. crossDomain: true,
  602. contentType: 'application/json',
  603. data: JSON.stringify({
  604. "header": {
  605. "xSourceAppId": "63008",
  606. "guid": "6f87e073-1da1-4017-b2de-c109abcd6d123",
  607. "lang": "zh",
  608. "timezone": "Asia/Shanghai"
  609. },
  610. "model": model
  611. }),
  612. success: function (response) {
  613. if (response.code === 200) {
  614. fuc(response.data)
  615. } else {
  616. fuc(null)
  617. }
  618. },
  619. error: function (xhr, status, error) {
  620. console.log('Request failed:', error)
  621. fuc(null)
  622. }
  623. })
  624. }
  625.  
  626.  
  627. function otherReq(url) {
  628. jq.ajax(url, {
  629. method: "GET",
  630. xhrFields: {
  631. withCredentials: true
  632. },
  633. crossDomain: true
  634. })
  635. }
  636. })();
  637.