// ==UserScript== // @name netcare debug工具 // @namespace http://tampermonkey.net/ // @version 0.1.1 // @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 let iframe = document.createElement('iframe'); iframe.onload = function () { top.glb = {}; var iframeKeys = iframe.contentWindow; Object.keys(top).forEach(function (key) { if (!(key in iframeKeys)) { glb[key] = top[key]; } }); iframe.remove(); }; iframe.src = 'about:blank'; document.body.appendChild(iframe); (function () { 'use strict'; setTimeout(function () { // 开发域后台 if (!location.href.includes('MaintenanceEngineerService/service_debug')) { return false; } var style = document.createElement('style'); style.type = 'text/css'; style.innerHTML = ` .ui-body {display: flex; padding-left:5px;} .ui-body .main-content{width: 440px;text-align: left;} .main-content .red {color: red;} .main-content h4 {font-weight: bold;margin-bottom: 4px;cursor: pointer;} .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;} `; document.head.appendChild(style); document.querySelector('.ui-body').insertAdjacentHTML('afterbegin', `
`); let opts = { el: '#myComp', template: `
  • ---------gde24全局搜索快捷方式-----------

  • 切换环境: 
  • 常用链接: 工程管理 服务调试 tql查询 服务查询 入站服务
  • 全局搜索: 复制服务 调试
  • 我的关注:  单击可跳转
  • 切换工程 {{ itm?.name }} {{ projects.length }}个
  • 模块 {{ modules.length }}个,点击可切换 {{ showModule ? '▲' : '▼' }}

    • {{ itm.name }}
  • 页面 {{ pageTotal }}个, 点击可打开或编辑 {{ showPage ? '▲' : '▼' }}

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

    • {{ itm.model_name }}
  • 服务 {{ serviceTotal }}个, 点击可调试 {{ showService ? '▲' : '▼' }}

    • {{ itm.service_name }}
`, data() { return { type: [], pr: '', service_id: '', prj: '', keyword: '', options: [], portalApp: [], portal: '1', showModule: true, showPage: true, showModel: false, showService: false, modules: [], module: '', pages: [], pageTotal: 0, models: [], services: [], serviceTotal: 0, projects: [], project: {}, host: `https://gdedev.icta138.huawei.com:38443`, env: 'dev' }; }, created() { 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)); }, 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); let copyToClipboard = text => { const input = document.createElement('textarea'); input.value = text; document.body.appendChild(input); input.select(); document.execCommand('copy'); document.body.removeChild(input); }; copyToClipboard(`/adc-service/web/rest/v1/services/${pj.project_name}/${pj.module_name}/${pj.element_name}`); }, 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(); }, 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.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: 10 }) .then(r => { this.models = r.data; }); } } }; if (Vue.version.startsWith(2)) { new Vue(opts); } else { // 不行 } }, 2000); })();