// ==UserScript== // @name netcare debug工具 // @namespace http://tampermonkey.net/ // @version 0.1.3 // @description 使用说明:在service_debug中添加全局搜索; // @author longfei 30003589 // @match *://gdedev.icta138.huawei.com:38443/* // @match *://gdesit.icta138.huawei.com:38443/* // @match *://netcare-uat.huawei.com/* // @match *://netcare.huawei.com/* // @match *://netcare-de.gts.huawei.com/* // @new 2023-07-31 // @license MIT // @downloadURL none // ==/UserScript== // https://greasyfork.org/zh-CN/scripts/472115-netcare-debug%E5%B7%A5%E5%85%B7 (function () { 'use strict'; if (!location.href.includes('MaintenanceEngineerService/service_debug')) { return false; } var style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = ` .ui-body .main-content{ margin-left:5px;width: 440px;text-align: left; flex-shrink: 0} .ui-body .vigour-center-panel.center_panel_wrap {width: auto;} .main-content .red {color: red;} .main-content .modules span {cursor: pointer;} .main-content .modules .cur-module {color: red;} .main-content h4 {font-weight: bold;margin-bottom: 4px;} .main-content .ops span {cursor: pointer; margin-left: 5px; color: #366bfc;} .main-content .myFollow {position: relative;} .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;} .main-content .myFollow:hover ul {display: block;} .main-content .page-all {width: 100%; max-height:250px; overflow-x: hidden;} .main-content .service-all {width: 100%; max-height:250px; overflow-x: hidden;} .main-content .service-all li a {display: inline-block; max-width: 390px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;} .main-content .service-all span {cursor: pointer; color: #366bfc;vertical-align: top;} `; document.head.appendChild(style); setTimeout(function () { // 开发域后台 document.querySelector('.ui-body').style.display = 'flex'; document.querySelector('.ui-body').insertAdjacentHTML('afterbegin', `
`); let opts = { el: '#myComp', template: `
  • ---------gde24全局搜索快捷方式-----------

  • 切换环境: 
  • 常用链接: 工程管理 服务调试 tql查询 服务查询 入站服务
  • 全局搜索:

    调试 复制服务 查询参数 复制参数

  • 我的关注:  单击可跳转
  • 切换工程 {{ itm?.name }} {{ projects.length }}个
  • 模块 {{ modules.length }}个,点击可切换 {{ showModule ? '▲' : '▼' }}

    • {{ itm.name }}
  • 服务 {{ serviceTotal }}个, 点击可调试 {{ showService ? '▲' : '▼' }}
    • {{ itm.service_name }} 复制
  • 页面 {{ pageTotal }}个, 点击可打开或编辑 {{ showPage ? '▲' : '▼' }}

    • {{ itm.name }}    编辑
  • 模型 {{ models.length }}个, 点击可打开 {{ showModel ? '▲' : '▼' }}

    • {{ itm.model_name }}
`, data() { return { type: ['SERVICE'], pr: '', service_id: '', prj: '', keyword: '', options: [], portalApp: [], portal: '1', showModule: true, showPage: false, showModel: false, showService: false, modules: [], module: '', pages: [], pageTotal: 0, models: [], services: [], servicesFilter: [], filter: '', serviceTotal: 0, projects: [], project: {}, host: `https://gdedev.icta138.huawei.com:38443`, env: 'dev' }; }, mounted() { window._ap = this; this.getModules(); this.host = location.origin; axios.get('/adc-studio-project-mgt/web/rest/v1/projects?sort=updateTime%3Adesc&extendFields=LOGO%2CFAVORITE&start=0&limit=50&favorite=true').then(res => { document .querySelector('.main-content .myFollow') .insertAdjacentHTML( 'beforeend', '
    ' + res.data.data.map(i => `
  • ${i.display_name}`).join('') ); }); }, methods: { search(key) { if (!key) { return; } axios .post('/adc-studio-project-mgt/web/rest/v1/project/global-element/search', { keyword: key, project_name: this.prj, module_name: [], type: this.type, //PAGE,SERVICE, MODEL start: 0, limit: 100 }) .then(r => (this.options = r.data?.data)); }, searchParam(service_id) { service_id = service_id || this.service_id axios.get(`/adc-studio-service/web/rest/v1/app/service/query-by-id/${service_id}`).then(res=>{ let param = res.flow.steps?.input?.input?.properties || res.flow.steps?.input_node?.input?.properties; let p ={} let types = { string: '', integer: 0, number: 0, array: [], object: {} } if (param) { param.reduce((a,b) => (a[b.name] = types[b.type]||'', a), p) } this.param = p; console.log('param:', p) jsonEdit.input = JSON.stringify(p, null, ' '); }) }, copyParam() { navigator.clipboard.writeText(JSON.stringify(this.param, null, ' ')) }, changeSer(ser) { let res = this.options.find(itm => itm.element_name === ser); this.service_id = res?.element_id; this.changeProject(res.project_name); }, copyService() { let pj = this.options.find(itm => itm.element_name === this.keyword); this.copy(`/adc-service/web/rest/v1/services/${pj.project_name}/${pj.module_name}/${pj.element_name}`); }, copy(text) { const input = document.createElement('textarea'); input.value = text; document.body.appendChild(input); input.select(); document.execCommand('copy'); document.body.removeChild(input); }, copySer(t, id) { this.service_id = id; this.copy(t); }, getModules() { axios.get(`/adc-studio-project-mgt/web/rest/v1/projects?sort=updateTime%3Adesc&extendFields=LOGO%2CFAVORITE&start=0&limit=100&favorite=false`).then(r => { this.projects = r.data.data; }); }, changeEnv() { location.href = this.host + location.pathname; }, async changeProject(pj) { this.project = this.projects.find(itm => itm.name === pj); // modules await axios.get(`/adc-studio-project-mgt/web/rest/v1/project/${this.project?.id}/modules`).then(r => { this.modules = r.data; this.module = this.modules[0].name; }); this.changeModule(); }, filterService() { if (!this.filter) { this.servicesFilter = this.services } else { this.servicesFilter = this.services.filter(i=>i.service_name.includes(this.filter)) } }, changeModule() { if (!this.module) { return; } // service axios .post(`/adc-studio-service/web/rest/v1/app/service/query`, { start: 1, limit: 200, module_name: this.module, project_name: this.project.name, brief: true, active: true }) .then(r => { this.services = r.instances; this.servicesFilter = r.instances; this.serviceTotal = r.total; }); // page axios .get( `/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` ) .then(r => { this.pages = r.data; this.pageTotal = r.total; }); // model axios .post(`/adc-studio-model/web/rest/v1/models/query-model-no-prop`, { project_name: this.project.name, module_name: this.module, model_name: '', model_type: '', active: '', start: 0, limit: 100 }) .then(r => { this.models = r.data; }); } } }; if (Vue.version.startsWith(2)) { new Vue(opts); } else { // 不行 } }, 700); window._getGlobal = () => { let iframe = document.createElement('iframe'); iframe.onload = function () { window.glb = {}; var iframeKeys = iframe.contentWindow; Object.keys(window).forEach(function (key) { if (!(key in iframeKeys)) { glb[key] = window[key]; } }); console.log('glb:', glb) iframe.remove(); }; iframe.src = 'about:blank'; document.body.appendChild(iframe); } })();