netcare debug工具

使用说明:在service_debug中添加全局搜索;

  1. // ==UserScript==
  2. // @name netcare debug工具
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.3
  5. // @description 使用说明:在service_debug中添加全局搜索;
  6. // @author longfei 30003589
  7. // @match *://gdedev.icta138.huawei.com:38443/*
  8. // @match *://gdesit.icta138.huawei.com:38443/*
  9. // @match *://netcare-uat.huawei.com/*
  10. // @match *://netcare.huawei.com/*
  11. // @match *://netcare-de.gts.huawei.com/*
  12. // @new 2023-07-31
  13. // @license MIT
  14. // ==/UserScript==
  15. // https://gf.qytechs.cn/zh-CN/scripts/472115-netcare-debug%E5%B7%A5%E5%85%B7
  16.  
  17. (function () {
  18. 'use strict';
  19. if (!location.href.includes('MaintenanceEngineerService/service_debug')) {
  20. return false;
  21. }
  22. var style = document.createElement('style');
  23. style.type = 'text/css';
  24. style.innerHTML = `
  25. .ui-body .main-content{ margin-left:5px;width: 440px;text-align: left; flex-shrink: 0}
  26. .ui-body .vigour-center-panel.center_panel_wrap {width: auto;}
  27. .main-content .red {color: red;}
  28. .main-content .modules span {cursor: pointer;}
  29. .main-content .modules .cur-module {color: red;}
  30. .main-content h4 {font-weight: bold;margin-bottom: 4px;}
  31. .main-content .ops span {cursor: pointer; margin-left: 5px; color: #366bfc;}
  32. .main-content .myFollow {position: relative;}
  33. .main-content .myFollow ul {position:absolute; border: 1px solid #ccc; top: 18px; left: 0px; display: none; z-index: 1000; line-height: 2; background-color: #fff; padding: 0 6px;}
  34. .main-content .myFollow:hover ul {display: block;}
  35. .main-content .page-all {width: 100%; max-height:250px; overflow-x: hidden;}
  36. .main-content .service-all {width: 100%; max-height:250px; overflow-x: hidden;}
  37. .main-content .service-all li a {display: inline-block; max-width: 390px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;}
  38. .main-content .service-all span {cursor: pointer; color: #366bfc;vertical-align: top;}
  39. `;
  40. document.head.appendChild(style);
  41. setTimeout(function () {
  42. // 开发域后台
  43. document.querySelector('.ui-body').style.display = 'flex';
  44. document.querySelector('.ui-body').insertAdjacentHTML('afterbegin', `<div id="myComp"></div>`);
  45. let opts = {
  46. el: '#myComp',
  47. template: `<div class="main-content">
  48. <ul>
  49. <li style="text-align: center"><h3>---------gde24全局搜索快捷方式-----------</h3></li>
  50. <li>
  51. <strong>切换环境:</strong>&nbsp;
  52. <select v-model="host" @change="changeEnv" readonly>
  53. <option value="https://gdedev.icta138.huawei.com:38443">dev</option>
  54. <option value="https://gdesit.icta138.huawei.com:38443">sit</option>
  55. <option value="https://netcare-uat.huawei.com">uat</option>
  56. <option value="https://netcare.huawei.com">pro</option>
  57. </select>
  58. </li>
  59. <li class="conmmon-link">
  60. <strong>常用链接:</strong>
  61. <a href="/portal-web/portal/homepage.html?isStudio=true#adc.studio_develop.project_mgt" target="_blank">工程管理</a>
  62. <a href="/adc-ui/spl-plus/MaintenanceEngineerService/MaintenanceEngineerService/service_debug" target="_blank">服务调试</a>
  63. <a href="/adc-ui/spl-plus/MaintenanceEngineerService/MaintenanceEngineerService/tql_query" target="_blank">tql查询</a>
  64. <a href="/adc-ui/spl-plus/MaintenanceEngineerService/MaintenanceEngineerService/service_search" target="_blank">服务查询</a>
  65. <a href="/adc-ui/spl-plus/MaintenanceEngineerService/MaintenanceEngineerService/rest_invoke" target="_blank">入站服务</a>
  66. </li>
  67. <li>
  68. <strong>全局搜索:</strong>
  69. <el-select v-model="type" multiple placeholder="搜索类型" clearable style="width: 150px">
  70. <el-option v-for="itm in ['PAGE', 'SERVICE', 'MODEL', 'I18N', 'PAGE_SCRIPT']" :key="itm" :value="itm" :label="itm"></el-option>
  71. </el-select>
  72. <el-select v-model="pr" placeholder="指定工程" filterable clearable>
  73. <el-option v-for="itm in projects" :key="itm" :value="itm.name" :label="itm.name"></el-option>
  74. </el-select>
  75. <el-select v-model="keyword" filterable remote placeholder="搜索关键字" :remote-method="search" @change="changeSer" style="width: 400px">
  76. <el-option v-for="item in options" :key="item" :label="'【' + item.type + '】 ' + item.project_name + '/' + item.module_name + '/' + item.element_name" :value="item.element_name" />
  77. </el-select>
  78. <p class="ops">
  79. <a :href="'/adc-studio-web/service/app-service/index.html?serviceId=' + service_id + '&projectName=' + project.name + '&moduleName=' + module" target="_blank">调试</a>
  80. <span @click="copyService">复制服务</span>
  81. <span @click="searchParam(service_id)">查询参数</span>
  82. <span @click="copyParam">复制参数</span>
  83. </p>
  84. </li>
  85. <li>
  86. <strong>我的关注:</strong>&nbsp;
  87. <span class="myFollow">单击可跳转</span>
  88. </li>
  89. <li>
  90. <strong>切换工程</strong>
  91. <el-select v-model="prj" filterable placeholder="切换工程" @change="changeProject">
  92. <el-option v-for="itm in projects" :key="itm.id" :value="itm.name">{{ itm?.name }}</el-option>
  93. </el-select>
  94. {{ projects.length }}个
  95. </li>
  96. <li @click="showModule = !showModule">
  97. <h4>模块 {{ modules.length }}个,点击可切换 {{ showModule ? '▲' : '▼' }}</h4>
  98. </li>
  99. <ul v-show="showModule" class="modules">
  100. <li v-for="itm in modules" :key="itm">
  101. <span :class="[module === itm.name ? 'cur-module' : '']" @click="() => ((module = itm.name), changeModule())">{{ itm.name }}</span>
  102. </li>
  103. </ul>
  104. <li>
  105. <strong @click="showService = !showService">服务 {{ serviceTotal }}个, 点击可调试 {{ showService ? '▲' : '▼' }}</strong>
  106. <input placeholder="服务过滤" v-model="filter" @input="filterService" style="width: 180px;" />
  107. </li>
  108. <ul v-show="showService" class="service-all">
  109. <li v-for="itm in servicesFilter" :key="itm">
  110. <a :href="'/adc-studio-web/service/app-service/index.html?serviceId=' + itm.id + '&projectName=' + project.name + '&moduleName=' + module" :title="itm.service_name" target="_blank">
  111. {{ itm.service_name }}
  112. </a>
  113. <span @click="copySer(project.name + '/' + module + '/' + itm.service_name, itm.id)">复制</span>
  114. </li>
  115. </ul>
  116. <li @click="showPage = !showPage">
  117. <h4>页面 {{ pageTotal }}个, 点击可打开或编辑 {{ showPage ? '▲' : '▼' }}</h4>
  118. </li>
  119. <ul v-show="showPage" class="page-all">
  120. <li v-for="itm in pages" :key="itm">
  121. <a :href="'/adc-ui/spl-plus/' + project.name + '/' + module + '/' + itm.name" target="_blank">{{ itm.name }}</a>
  122. &nbsp;&nbsp;
  123. <a :href="'/adc-studio-web/ui/studio/spl-designer.html?projectName='+project.name+'&moduleName='+module+'&namespace=page&pageMode=edit&pageName='+itm.name" target="_blank">编辑</a>
  124. </li>
  125. </ul>
  126. <li @click="showModel = !showModel">
  127. <h4>模型 {{ models.length }}个, 点击可打开 {{ showModel ? '▲' : '▼' }}</h4>
  128. </li>
  129. <ul v-show="showModel">
  130. <li v-for="itm in models" :key="itm">
  131. <a :href="'/adc-studio-web/model/app-model-form-list/index.html?projectName=' + project.name + '&moduleName=' + module" target="_blank">{{ itm.model_name }}</a>
  132. </li>
  133. </ul>
  134. </ul>
  135. </div>`,
  136. data() {
  137. return {
  138. type: ['SERVICE'],
  139. pr: '',
  140. service_id: '',
  141. prj: '',
  142. keyword: '',
  143. options: [],
  144. portalApp: [],
  145. portal: '1',
  146. showModule: true,
  147. showPage: false,
  148. showModel: false,
  149. showService: false,
  150. modules: [],
  151. module: '',
  152. pages: [],
  153. pageTotal: 0,
  154. models: [],
  155. services: [],
  156. servicesFilter: [],
  157. filter: '',
  158. serviceTotal: 0,
  159. projects: [],
  160. project: {},
  161. host: `https://gdedev.icta138.huawei.com:38443`,
  162. env: 'dev'
  163. };
  164. },
  165. mounted() {
  166. window._ap = this;
  167. this.getModules();
  168. this.host = location.origin;
  169. axios.get('/adc-studio-project-mgt/web/rest/v1/projects?sort=updateTime%3Adesc&extendFields=LOGO%2CFAVORITE&start=0&limit=50&favorite=true').then(res => {
  170. document
  171. .querySelector('.main-content .myFollow')
  172. .insertAdjacentHTML(
  173. 'beforeend',
  174. '<ul class="myFollow">' + res.data.data.map(i => `<li><a href="/adc-studio-web/project-mgt/project/resource-designer.html?project_id=${i.id}">${i.display_name}</a>`).join('')
  175. );
  176. });
  177. },
  178. methods: {
  179. search(key) {
  180. if (!key) {
  181. return;
  182. }
  183. axios
  184. .post('/adc-studio-project-mgt/web/rest/v1/project/global-element/search', {
  185. keyword: key,
  186. project_name: this.prj,
  187. module_name: [],
  188. type: this.type, //PAGE,SERVICE, MODEL
  189. start: 0,
  190. limit: 100
  191. })
  192. .then(r => (this.options = r.data?.data));
  193. },
  194. searchParam(service_id) {
  195. service_id = service_id || this.service_id
  196. axios.get(`/adc-studio-service/web/rest/v1/app/service/query-by-id/${service_id}`).then(res=>{
  197. let param = res.flow.steps?.input?.input?.properties || res.flow.steps?.input_node?.input?.properties;
  198. let p ={}
  199. let types = {
  200. string: '',
  201. integer: 0,
  202. number: 0,
  203. array: [],
  204. object: {}
  205. }
  206. if (param) {
  207. param.reduce((a,b) => (a[b.name] = types[b.type]||'', a), p)
  208. }
  209. this.param = p;
  210. console.log('param:', p)
  211. jsonEdit.input = JSON.stringify(p, null, ' ');
  212. })
  213. },
  214. copyParam() {
  215. navigator.clipboard.writeText(JSON.stringify(this.param, null, ' '))
  216. },
  217. changeSer(ser) {
  218. let res = this.options.find(itm => itm.element_name === ser);
  219. this.service_id = res?.element_id;
  220. this.changeProject(res.project_name);
  221. },
  222. copyService() {
  223. let pj = this.options.find(itm => itm.element_name === this.keyword);
  224. this.copy(`/adc-service/web/rest/v1/services/${pj.project_name}/${pj.module_name}/${pj.element_name}`);
  225. },
  226. copy(text) {
  227. const input = document.createElement('textarea');
  228. input.value = text;
  229. document.body.appendChild(input);
  230. input.select();
  231. document.execCommand('copy');
  232. document.body.removeChild(input);
  233. },
  234. copySer(t, id) {
  235. this.service_id = id;
  236. this.copy(t);
  237. },
  238. getModules() {
  239. axios.get(`/adc-studio-project-mgt/web/rest/v1/projects?sort=updateTime%3Adesc&extendFields=LOGO%2CFAVORITE&start=0&limit=100&favorite=false`).then(r => {
  240. this.projects = r.data.data;
  241. });
  242. },
  243. changeEnv() {
  244. location.href = this.host + location.pathname;
  245. },
  246. async changeProject(pj) {
  247. this.project = this.projects.find(itm => itm.name === pj);
  248. // modules
  249. await axios.get(`/adc-studio-project-mgt/web/rest/v1/project/${this.project?.id}/modules`).then(r => {
  250. this.modules = r.data;
  251. this.module = this.modules[0].name;
  252. });
  253. this.changeModule();
  254. },
  255. filterService() {
  256. if (!this.filter) {
  257. this.servicesFilter = this.services
  258. } else {
  259. this.servicesFilter = this.services.filter(i=>i.service_name.includes(this.filter))
  260. }
  261. },
  262. changeModule() {
  263. if (!this.module) {
  264. return;
  265. }
  266. // service
  267. axios
  268. .post(`/adc-studio-service/web/rest/v1/app/service/query`, {
  269. start: 1,
  270. limit: 200,
  271. module_name: this.module,
  272. project_name: this.project.name,
  273. brief: true,
  274. active: true
  275. })
  276. .then(r => {
  277. this.services = r.instances;
  278. this.servicesFilter = r.instances;
  279. this.serviceTotal = r.total;
  280. });
  281. // page
  282. axios
  283. .get(
  284. `/adc-studio-ui/web/rest/v1/page-core/page/${this.project.name}/${this.module}?sort=name&dir=ASC&page=0&pageSize=200&moduleName=${this.module}&projectName=${this.project.name}&name=&type=responsive-web`
  285. )
  286. .then(r => {
  287. this.pages = r.data;
  288. this.pageTotal = r.total;
  289. });
  290. // model
  291. axios
  292. .post(`/adc-studio-model/web/rest/v1/models/query-model-no-prop`, {
  293. project_name: this.project.name,
  294. module_name: this.module,
  295. model_name: '',
  296. model_type: '',
  297. active: '',
  298. start: 0,
  299. limit: 100
  300. })
  301. .then(r => {
  302. this.models = r.data;
  303. });
  304. }
  305. }
  306. };
  307. if (Vue.version.startsWith(2)) {
  308. new Vue(opts);
  309. } else {
  310. // 不行
  311. }
  312. }, 700);
  313. window._getGlobal = () => {
  314. let iframe = document.createElement('iframe');
  315. iframe.onload = function () {
  316. window.glb = {};
  317. var iframeKeys = iframe.contentWindow;
  318. Object.keys(window).forEach(function (key) {
  319. if (!(key in iframeKeys)) {
  320. glb[key] = window[key];
  321. }
  322. });
  323. console.log('glb:', glb)
  324. iframe.remove();
  325. };
  326. iframe.src = 'about:blank';
  327. document.body.appendChild(iframe);
  328. }
  329. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址