@easyv-find events abnormal

easyv 查找事件异常组件

  1. // ==UserScript==
  2. // @name @easyv-find events abnormal
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.2
  5. // @description easyv 查找事件异常组件
  6. // @author You
  7. // @match https://easyv.cloud/workspace/
  8. // @icon https://www.google.com/s2/favicons?domain=dtstack.net
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (async function() {
  13. 'use strict';
  14. console.info('fetch loading....')
  15. const result = await fetch('https://easyv.cloud/api/easyv/v3/screen/export?id=356479').then(function(res){ return res.json() });
  16. console.log(result);
  17. main(result.data);
  18. // Your code here...
  19. })();
  20.  
  21. async function main(data){
  22. data.componentsConfig && filterComponentsConfig(data.componentsConfig)
  23.  
  24. if(data.panelConfig && data.panelConfig.length){
  25. data.panelConfig.forEach(d=>{
  26. d.stateConfig?.length && d.stateConfig.forEach(d=>{
  27. d && main(d);
  28. })
  29. })
  30. }
  31. }
  32.  
  33.  
  34.  
  35. function filterComponentsConfig(componentsConfig){
  36. const events = componentsConfig.map(d=>{ return { events:JSON.parse(d.events),id:d.id } }).filter(d=>d.events.length);
  37. const actions = events.map(d=>{
  38. return {events:d.events.filter(d=> !d.id),id:d.id}
  39. }).flat(2).filter(d=>d.events.length);
  40. console.log(actions)
  41. // const actions
  42. }