2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
|
|
import{d as U,af as te,o as Q,al as J,a as oe,X as Z,b as v,c as C,e as o,r as N,a4 as ee,i as m,f as a,w as s,j as D,ad as ae,g as A,av as ne,aw as le,ax as se,V as G,a2 as W,t as w,U as F,ay as ie,W as K,n as re,h as H,a5 as X,az as de,aA as ue,v as pe,E as ce,aa as _e,aB as ge}from"./index-CXRNRwY6.js";import{i as me}from"./index-Bb6yjXMn.js";import{_ as M}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{a as fe}from"./index-BYeSIZFz.js";const ve={class:"graph-canvas"},j="#07C160",B="#f59e0b",ye="#9ca3af",Y="#c0c4cc",q="#3b82f6",he=U({__name:"GraphCanvas",props:{graphData:{},loading:{type:Boolean}},emits:["node-click"],setup(y,{expose:c,emit:h}){const d=y,S=h,g=N(null);let l=null,b=null,u=[],i=[],_={nodeTypes:["issue","action"],relationTypes:["LEADS_TO","RELATES_TO","CAN_JUMP_TO"]},n="";function z(){return{tooltip:{formatter:r=>r.dataType==="node"?`<b>${r.data.name}</b><br/>类型: ${r.data.nodeType}`:r.dataType==="edge"?r.data.relationType||"关系":r.name},legend:[{data:[{name:"Issue",itemStyle:{color:j}},{name:"Action",itemStyle:{color:B}},{name:"Relation",itemStyle:{color:ye,opacity:.3}}],orient:"vertical",right:10,top:10,selected:{Issue:!0,Action:!0,Relation:!1},textStyle:{fontSize:12}}],series:[{type:"graph",layout:"force",roam:!0,focusNodeAdjacency:!0,force:{repulsion:300,gravity:.1,edgeLength:[100,250],layoutAnimation:!0},categories:[{name:"Issue",itemStyle:{color:j}},{name:"Action",itemStyle:{color:B}}],label:{show:!0,position:"right",fontSize:11,color:"#303133"},lineStyle:{color:Y,width:1.5,curveness:.3},emphasis:{focus:"adjacency",lineStyle:{width:4},label:{show:!0}},data:[],links:[]}]}}function $(r){u=(r.nodes||[]).map(p=>({id:p.id,name:p.name||p.id,nodeType:p.type,category:p.type==="issue"?0:1,symbolSize:p.type==="issue"?28:22,itemStyle:{color:p.type==="issue"?j:B},properties:p.properties||{},rawData:p,draggable:!0})),i=(r.links||[]).map(p=>({source:p.source,target:p.target,relationType:p.type,weight:p.weight,lineStyle:{color:Y,width:Math.max(.5,(p.weight||1)*1.5),curveness:.3},rawData:p}))}function O(){const r=u.filter(f=>_.nodeTypes.includes(f.nodeType)),p=new Set(r.map(f=>f.id)),E=i.filter(f=>_.relationTypes.includes(f.relationType)&&p.has(f.source)&&p.has(f.target));let x;return n?x=r.map(f=>f.name.toLowerCase().includes(n.toLowerCase())?{...f,itemStyle:{...f.itemStyle,borderColor:q,borderWidth:3,shadowBlur:10,shadowColor:q}}:{...f,itemStyle:{...f.itemStyle,opacity:.15}}):x=r,{nodes:x,links:E}}function e(){if(!l)return;const{nodes:r,links:p}=O();l.setOption({series:[{data:r,links:p}]})}function t(){if(!g.value||!d.graphData)return;l||(l=me(g.value),l.on("click",x=>{var f;x.dataType==="node"&&((f=x.data)!=null&&f.rawData)&&S("node-click",x.data.rawData)})),$(d.graphData);const r=z(),{nodes:p,links:E}=O();r.series[0].data=p,r.series[0].links=E,l.setOption(r,!0)}function k(r){n=(r==null?void 0:r.trim())||"",e()}function R(){n="",e()}function I(){l==null||l.resize()}function L(r){_={...r},e()}function T(){l&&l.dispatchAction({type:"graphRoam",seriesIndex:0,zoom:1.3,originX:l.getWidth()/2,originY:l.getHeight()/2})}function V(){l&&l.dispatchAction({type:"graphRoam",seriesIndex:0,zoom:1/1.3,originX:l.getWidth()/2,originY:l.getHeight()/2})}function P(){l&&l.dispatchAction({type:"restore"})}return c({highlightSearch:k,restoreAllNodes:R,resize:I,applyFilter:L,zoomIn:T,zoomOut:V,zoomReset:P}),te(()=>d.graphData,()=>{J(()=>t())},{deep:!0}),Q(()=>{d.graphData&&J(()=>t()),g.value&&(b=new ResizeObserver(()=>{l==null||l.resize()}),b.observe(g.value))}),oe(()=>{b==null||b.disconnect(),b=null,l&&(l.dispose(),l=null)}),(r,p)=>{const E=ee("loading");return Z((v(),C("div",ve,[o("div",{ref_key:"chartContainer",ref:g,class:"graph-canvas__chart"},null,512)])),[[E,y.loading]])}}}),be=M(he,[["__scopeId","data-v-c818f9fe"]]),we={class:"graph-toolbar"},Ce={class:"graph-toolbar__group"},ke={class:"graph-toolbar__group"},Te={class:"graph-toolbar__group"},Se=U({__name:"GraphToolbar",emits:["search","filter-change","zoom-in","zoom-out","zoom-reset"],setup(y,{emit:c}){const h=c,d=N(""),S=N(["issue","action"]),g=N(["LEADS_TO","RE
|