diff --git a/vue/src/components/GraphToolbar.vue b/vue/src/components/GraphToolbar.vue
index 9ae4173..b83a14d 100644
--- a/vue/src/components/GraphToolbar.vue
+++ b/vue/src/components/GraphToolbar.vue
@@ -127,9 +127,14 @@ export default {
},
exportToSVGManual() {
- const graph = this.graph;
- if (!graph) return;
+ const graph = this._graph || this.graph;
+ if (!graph) {
+ this.$message.error("未找到图表实例");
+ return;
+ }
+
const { nodes, edges } = graph.getData();
+ // 1. 计算画布边界,确保所有节点都在视口内
const bBox = graph.getCanvas().getRoot().getRenderBounds();
const padding = 60;
const minX = bBox.min[0] - padding;
@@ -139,7 +144,6 @@ export default {
const vWidth = maxX - minX;
const vHeight = maxY - minY;
- // 1. 定义与问答页面一致的颜色映射(用于兜底和逻辑计算)
const colorMap = {
'Disease': { fill: '#EF4444', stroke: '#B91C1C', edge: '#EF4444' },
'Drug': { fill: '#91cc75', stroke: '#047857', edge: '#91cc75' },
@@ -148,39 +152,101 @@ export default {
'Other': { fill: '#59d1d4', stroke: '#40999b', edge: '#59d1d4' }
};
+ // 2. 预收集颜色用于生成对应的箭头定义
+ const usedColors = new Set();
+ edges.forEach(edge => {
+ const s = nodes.find(n => n.id === edge.source);
+ const sourceType = s?.data?.label || 'Other';
+ const color = edge.style?.stroke || colorMap[sourceType]?.edge || '#cccccc';
+ usedColors.add(color);
+ });
+
let svgContent = ``;
- // 保存文件逻辑保持不变...
+ // 6. 导出文件
try {
- const blob = new Blob([svgContent], {type: 'image/svg+xml;charset=utf-8'});
+ const blob = new Blob([svgContent], { type: 'image/svg+xml;charset=utf-8' });
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
- link.download = `矢量图谱_${Date.now()}.svg`;
+ link.download = `医疗图谱导出_${Date.now()}.svg`;
+ document.body.appendChild(link);
link.click();
+ document.body.removeChild(link);
URL.revokeObjectURL(url);
- this.$message.success('全量矢量图导出成功');
+ this.$message.success('高精度矢量图导出成功');
} catch (err) {
this.$message.error('导出失败');
}
diff --git a/vue/src/system/GraphDemo.vue b/vue/src/system/GraphDemo.vue
index f80e6ee..fee8ee3 100644
--- a/vue/src/system/GraphDemo.vue
+++ b/vue/src/system/GraphDemo.vue
@@ -4,113 +4,113 @@
-
-
-
-
-

-
-
-
-
+
+
+
+

+
+
+
+
-
{{ item.label }}
+ class="color-block"
+ @click="toggleCategory(item.key)"
+ >
+
{{ item.label }}
+
+
+
+