From 7bc99fd1ba234de4dc0802d07508619d85f98a6b Mon Sep 17 00:00:00 2001 From: jzy <928294064@qq.com> Date: Sat, 27 Sep 2025 20:06:49 +0800 Subject: [PATCH] yangshi --- gyxtp/src/api/api/graph.js | 8 +- gyxtp/src/view/small.vue | 114 +++++++++----- .../web/controller/system/ZhyPointController.java | 168 ++++++++++++++++++++- .../api/controller/TestXiaoTuPuController.java | 13 +- .../com/ruoyi/api/service/impl/PointService.java | 95 ++++++++++++ ruoyi-ui/src/views/system/SysPoint/index.vue | 38 ++++- test3.csv | 2 +- 7 files changed, 383 insertions(+), 55 deletions(-) diff --git a/gyxtp/src/api/api/graph.js b/gyxtp/src/api/api/graph.js index 9439114..2de05bb 100644 --- a/gyxtp/src/api/api/graph.js +++ b/gyxtp/src/api/api/graph.js @@ -99,8 +99,12 @@ export const getPointInfoByUUID = (param) => { export const getReInfoByNameAndType = (name,type) => { return request({ - url: '/api/test/getReInfoByNameAndType/'+name+"/"+type, - method: 'get', + url: '/api/test/getReInfoByNameAndType', + method: 'post', + data:{ + name:name, + type:type + } }); }; export const getDocInfoBylinkIds = (param) => { diff --git a/gyxtp/src/view/small.vue b/gyxtp/src/view/small.vue index fb6fe04..991088a 100644 --- a/gyxtp/src/view/small.vue +++ b/gyxtp/src/view/small.vue @@ -198,7 +198,7 @@ export default { toolBarPositionV: 'bottom', // ✅ 正确设置:使用贝塞尔曲线 - defaultLineShape: 2, // 2 = 贝塞尔曲线(Bezier),3 = 平滑曲线 + defaultLineShape: 1, // 2 = 贝塞尔曲线(Bezier),3 = 平滑曲线 layout: { layoutName: 'force', @@ -407,58 +407,93 @@ export default { getColor(type){ let res = "rgb(227,203,0)" if (type=="author"){ - res = "rgb(255,203,0)" + res = "#ff8c00" } if (type=="agency"){ - res = "rgb(0,255,0)" + res = "rgb(64, 158, 255)" } if (type=="keyword"){ - res = "rgb(0,0,255)" + res = "#ffd602" } return res }, getPointData(){ getpoinByName(this.getpoinName).then((res) => { - let nodes = [] - let links = [] - for (let i = 0;i { + const from = link.from; + const to = link.to; + const num = link.num || 0; // 安全取值 + console.log(num) + + // 无向图:from 和 to 都累加 num + totalNumMap[from] = (totalNumMap[from] || 0) + num; + totalNumMap[to] = (totalNumMap[to] || 0) + num; + }); + +// 确保孤立节点也有默认值(避免 undefined) + res.nodes.forEach(node => { + if (!totalNumMap[node.id]) { + totalNumMap[node.id] = 0; } + }); +// Step 2: 生成节点,宽高根据 totalNum 动态计算 + for (let i = 0; i < res.nodes.length; i++) { + const node = res.nodes[i]; - nodes.push(t_data) + // 跳过关键词节点且 text 不匹配的情况 + if (node.type === "keyword" && node.text !== this.getpoinName) { + continue; + } + + // 获取该节点的总 num 值 + const totalNum = totalNumMap[node.id]; + + // 根据 totalNum 计算尺寸(可调参数) + const baseSize = 120; // 最小尺寸 + const sizePerNum = 40; // 每单位 num 增加的尺寸 + const maxSize = 300; // 最大尺寸限制 + + let width = baseSize + sizePerNum * totalNum; + width = Math.min(width, maxSize); // 限制最大值 + const height = width; // 保持正方形 + + const t_data = { + id: node.id, + text: node.text, + width: width, + height: height, + color: this.getColor(node.type), + fontColor: '#fff', + styleClass:"nodeClass" + }; + + nodes.push(t_data); } - // console.log(res.links) - for (let i = 0;i