Pārlūkot izejas kodu

逻辑图 上传图片问题处理

hbchen 8 mēneši atpakaļ
vecāks
revīzija
fd37afa659

+ 6 - 8
src/views/sandbox_manage/common/mindmap.js

@@ -58,8 +58,7 @@ export default {
             refY2: -8,
             width: 16,
             height: 16,
-            'xlink:href':
-              'https://gw.alipayobjects.com/mdn/rms_43231b/afts/img/A*SYCuQ6HHs5cAAAAAAAAAAAAAARQnAQ',
+            'xlink:href':require('@/assets/img/icons/add_blue_new.png'),
             event: 'add:topic:left',
             class: 'left-topic-image',
           },
@@ -70,8 +69,7 @@ export default {
             refY2: -8,
             width: 16,
             height: 16,
-            'xlink:href':
-              'https://gw.alipayobjects.com/mdn/rms_43231b/afts/img/A*SYCuQ6HHs5cAAAAAAAAAAAAAARQnAQ',
+            'xlink:href':require('@/assets/img/icons/add_blue_new.png'),
             event: 'add:topic:right',
             class: 'right-topic-image',
           },
@@ -124,8 +122,7 @@ export default {
             refY2: -8,
             width: 16,
             height: 16,
-            'xlink:href':
-              'https://gw.alipayobjects.com/mdn/rms_43231b/afts/img/A*SYCuQ6HHs5cAAAAAAAAAAAAAARQnAQ',
+            'xlink:href':require('@/assets/img/icons/add_blue_new.png'),
             event: 'add:topic:left',
             class: 'left-topic-image',
           },
@@ -178,8 +175,9 @@ export default {
             refY2: -8,
             width: 16,
             height: 16,
-            'xlink:href':
-              'https://gw.alipayobjects.com/mdn/rms_43231b/afts/img/A*SYCuQ6HHs5cAAAAAAAAAAAAAARQnAQ',
+            'xlink:href':require('@/assets/img/icons/add_blue_new.png'),
+            // 'xlink:href':
+            // 'https://gw.alipayobjects.com/mdn/rms_43231b/afts/img/A*SYCuQ6HHs5cAAAAAAAAAAAAAARQnAQ',
             event: 'add:topic:right',
             class: 'right-topic-image',
           },

+ 12 - 27
src/views/sandbox_manage/index_new_version.vue

@@ -998,6 +998,11 @@ import { myGraph } from './common/gragh';
             },{
               preserveDimensions:true,//让svg为实际图片大小
               beforeSerialize:(svg)=>{
+                let shouldRemoveElement = svg.querySelectorAll('.right-topic-image,.left-topic-image')
+                for (let i = 0; i < shouldRemoveElement.length; i++) {
+                  const element = shouldRemoveElement[i];
+                  element.remove()
+                }
                 // const zoom = this.graph.zoom();
                 const {x,y,width,height} = this.graph.getContentBBox(cells)
                 // let {tx,ty} = this.graph.translate() // 画布偏移量
@@ -1017,20 +1022,7 @@ import { myGraph } from './common/gragh';
                 // gNode.appendChild(textNode)
                   },
               copyStyles:false,
-              stylesheet: `
-                  svg{
-                      background-color:white;
-                  }
-                .x6-port {
-                    visibility: hidden;
-                }
-                .left-topic-image{
-                  visibility:hidden;
-                }
-                .right-topic-image{
-                  visibility: hidden;
-                }
-                ` 
+              stylesheet: `svg{background-color:white;} .x6-port{visibility: hidden;}` 
             })
           }
         })
@@ -1093,6 +1085,11 @@ import { myGraph } from './common/gragh';
       },{
         preserveDimensions:true,//让svg为实际图片大小
         beforeSerialize:(svg)=>{
+          let shouldRemoveElement = svg.querySelectorAll('.right-topic-image,.left-topic-image')
+          for (let i = 0; i < shouldRemoveElement.length; i++) {
+            const element = shouldRemoveElement[i];
+            element.remove()
+          }
           const {x,y,width,height} = this.graph.getContentBBox(cells)
           // let {tx,ty} = this.graph.translate()
           //给导出的svg增加一点宽高
@@ -1110,19 +1107,7 @@ import { myGraph } from './common/gragh';
           // gNode.appendChild(textNode)
             },
           copyStyles:false,
-          stylesheet: `
-            svg{
-                background-color:white;
-            }
-          .x6-port {
-              visibility: hidden;
-          }
-          .left-topic-image{
-            visibility:hidden;
-          }
-          .right-topic-image{
-            visibility: hidden;
-          }` 
+          stylesheet: `svg{background-color:white;} .x6-port{visibility: hidden;}` 
         })
       },500),
       //==============================画布

+ 13 - 28
src/views/sandbox_manage/sandFlowNew/index.vue

@@ -879,6 +879,12 @@ import addLInkDia from './components/addLInkDia.vue';
         },{
           preserveDimensions:false,//让svg为实际图片大小
           beforeSerialize:(svg)=>{
+            let shouldRemoveElement = svg.querySelectorAll('.right-topic-image,.left-topic-image')
+            for (let i = 0; i < shouldRemoveElement.length; i++) {
+              const element = shouldRemoveElement[i];
+              element.remove()
+            }
+
             const {x,y,width,height} = this.graph.getContentBBox(cells)
             // let {tx,ty} = this.graph.translate()
             //给导出的svg增加一点宽高
@@ -887,7 +893,6 @@ import addLInkDia from './components/addLInkDia.vue';
             //设置viewBox使图像居中
             svg.setAttribute('viewBox',`${x-25} ${y-25} ${width+50} ${height+50}`)
             // let gNode = svg.getElementsByClassName('x6-graph-svg-viewport')[0]
-            // console.log(leftImg,rightImg,'rightImg');
 
             // let textNode = document.createElement('text')
             // textNode.setAttribute('x',x-tx+width-90)
@@ -898,19 +903,7 @@ import addLInkDia from './components/addLInkDia.vue';
             // gNode.appendChild(textNode)
               },
           copyStyles:false,
-          stylesheet: `
-              svg{
-                  background-color:white;
-              }
-            .x6-port {
-                visibility: hidden;
-            }
-            .left-topic-image{
-              visibility:hidden;
-            }
-            .right-topic-image{
-              visibility: hidden;
-            }` 
+          stylesheet: `svg{background-color:white;} .x6-port{visibility: hidden;}` 
             
         })
       },500),
@@ -972,6 +965,11 @@ import addLInkDia from './components/addLInkDia.vue';
         },{
           preserveDimensions:true,//让svg为实际图片大小
           beforeSerialize:(svg)=>{
+            let shouldRemoveElement = svg.querySelectorAll('.right-topic-image,.left-topic-image')
+            for (let i = 0; i < shouldRemoveElement.length; i++) {
+              const element = shouldRemoveElement[i];
+              element.remove()
+            }
             // const zoom = this.graph.zoom();
             const {x,y,width,height} = this.graph.getContentBBox(cells)
             // let {tx,ty} = this.graph.translate() // 画布偏移量
@@ -991,20 +989,7 @@ import addLInkDia from './components/addLInkDia.vue';
             // gNode.appendChild(textNode)
               },
           copyStyles:false,
-          stylesheet: `
-              svg{
-                  background-color:white;
-              }
-            .x6-port {
-                visibility: hidden;
-            }
-            .left-topic-image{
-              visibility:hidden;
-            }
-            .right-topic-image{
-              visibility: hidden;
-            }
-            ` 
+          stylesheet: `svg{background-color:white;} .x6-port{visibility: hidden;}` 
         })
           
       },500),