netcare debug工具

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

目前为 2023-07-31 提交的版本。查看 最新版本

// ==UserScript==
// @name         netcare debug工具
// @namespace    http://tampermonkey.net/
// @version      0.1.0
// @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
// ==/UserScript==
// https://gf.qytechs.cn/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')) {
      return false;
    }
    var style = document.createElement('style');
    style.type = 'text/css';
    style.innerHTML = `
      .ui-body {display: flex;}
      .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', `<div id="myComp"></div>`);
    let opts = {
      el: '#myComp',
      template: `<div class="main-content">
          <ul>
            <li style="text-align: center"><h3>---------gde24全局搜索快捷方式-----------</h3></li>
            <li>
              <strong>切换环境:</strong>&nbsp;
              <select v-model="host" @change="changeEnv" readonly>
                <option value="https://gdedev.icta138.huawei.com:38443">dev</option>
                <option value="https://gdesit.icta138.huawei.com:38443">sit</option>
                <option value="https://netcare-uat.huawei.com">uat</option>
                <option value="https://netcare.huawei.com">pro</option>
              </select>
            </li>
            <li class="conmmon-link">
               <strong>常用链接:</strong>
               <a :href="'/portal-web/portal/homepage.html?isStudio=true#adc.studio_develop.project_mgt'" target="_blank">工程管理</a>
               <a :href="'/adc-ui/spl-plus/MaintenanceEngineerService/MaintenanceEngineerService/service_debug'" target="_blank">服务调试</a>
               <a :href="'/adc-ui/spl-plus/MaintenanceEngineerService/MaintenanceEngineerService/tql_query'" target="_blank">tql查询</a>
               <a :href="'/adc-ui/spl-plus/MaintenanceEngineerService/MaintenanceEngineerService/service_search'" target="_blank">服务查询</a>
               <a :href="'/adc-ui/spl-plus/MaintenanceEngineerService/MaintenanceEngineerService/rest_invoke'" target="_blank">入站服务</a>
            </li>
            <li>
              <strong>全局搜索:</strong>
              <el-select v-model="type" multiple placeholder="搜索类型" clearable style="width: 150px">
                <el-option v-for="itm in ['PAGE', 'SERVICE', 'MODEL', 'I18N', 'PAGE_SCRIPT']" :key="itm" :value="itm" :label="itm"></el-option>
              </el-select>
              <el-select v-model="pr" placeholder="指定工程" filterable clearable>
                <el-option v-for="itm in projects" :key="itm" :value="itm.name" :label="itm.name"></el-option>
              </el-select>
              <el-select v-model="keyword" filterable remote placeholder="搜索关键字" :remote-method="search" @change="changeSer" style="width: 400px">
                <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" />
              </el-select>

              <span @click="copyService" style="cursor: pointer; margin: 0 12px">复制服务</span>
              <a :href="'/adc-studio-web/service/app-service/index.html?serviceId=' + service_id + '&projectName=' + project.name + '&moduleName=' + module" target="_blank">调试</a>
            </li>
            <li>
              <strong>我的关注:</strong>&nbsp;
              <span class="myFollow">单击可跳转</span>
            </li>
            <li>
              <strong>切换工程</strong>
              <el-select v-model="prj" filterable placeholder="切换工程" @change="changeProject">
                <el-option v-for="itm in projects" :key="itm.id" :value="itm.name">{{ itm?.name }}</el-option>
              </el-select>
              {{ projects.length }}个
            </li>
            <li @click="showModule = !showModule">
              <h4>模块 {{ modules.length }}个,点击可切换 {{ showModule ? '▲' : '▼' }}</h4>
            </li>
            <ul v-show="showModule" class="modules">
              <li v-for="itm in modules" :key="itm">
                <span :class="[module === itm.name ? 'cur-module' : '']" @click="() => ((module = itm.name), changeModule())">{{ itm.name }}</span>
              </li>
            </ul>
            <li @click="showPage = !showPage">
              <h4>页面 {{ pageTotal }}个, 点击可打开或编辑 {{ showPage ? '▲' : '▼' }}</h4>
            </li>
            <ul v-show="showPage">
              <li v-for="itm in pages" :key="itm">
                <a :href="'/adc-ui/spl-plus/' + project.name + '/' + module + '/' + itm.name" target="_blank">{{ itm.name }}</a>
                &nbsp;&nbsp;
                <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>
              </li>
            </ul>
            <li @click="showModel = !showModel">
              <h4>模型 {{ models.length }}个, 点击可打开 {{ showModel ? '▲' : '▼' }}</h4>
            </li>
            <ul v-show="showModel">
              <li v-for="itm in models" :key="itm">
                <a :href="'/adc-studio-web/model/app-model-form-list/index.html?projectName=' + project.name + '&moduleName=' + module" target="_blank">{{ itm.model_name }}</a>
              </li>
            </ul>
            <li @click="showService = !showService">
              <h4>服务 {{ serviceTotal }}个, 点击可调试 {{ showService ? '▲' : '▼' }}</h4>
            </li>
            <ul v-show="showService">
              <li v-for="itm in services" :key="itm">
                <a :href="'/adc-studio-web/service/app-service/index.html?serviceId=' + itm.id + '&projectName=' + project.name + '&moduleName=' + module" target="_blank">
                  {{ itm.service_name }}
                </a>
              </li>
            </ul>
          </ul>
        </div>`,
      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',
              '<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('')
            );
        });
      },
      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);
})();

QingJ © 2025

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