浏览代码

搬不完的砖

任一存 2 年之前
父节点
当前提交
b069febdeb
共有 3 个文件被更改,包括 17 次插入28 次删除
  1. 1 1
      public/chart.html
  2. 2 2
      public/chart4app.html
  3. 14 25
      src/views/History.vue

+ 1 - 1
public/chart.html

@@ -290,7 +290,7 @@
             layout: 'force',
             layout: 'force',
             // 力引导布局是模拟弹簧电荷模型在每两个节点之间添加一个斥力,每条边的两个节点之间添加一个引力
             // 力引导布局是模拟弹簧电荷模型在每两个节点之间添加一个斥力,每条边的两个节点之间添加一个引力
             force: {
             force: {
-              // initLayout: 'circular', // 进行力引导布局前的初始化布局,初始化布局会影响到力引导的效果。默认不进行任何布局,使用节点中提供的 x, y 作为节点的位置。如果不存在的话会随机生成一个位置。也可以选择使用环形布局 'circular'。
+              initLayout: 'circular', // 进行力引导布局前的初始化布局,初始化布局会影响到力引导的效果。默认不进行任何布局,使用节点中提供的 x, y 作为节点的位置。如果不存在的话会随机生成一个位置。也可以选择使用环形布局 'circular'。
               // repulsion: 100, // 节点之间的斥力因子。傻逼文档把edgeLength当数组用的用法写到这上边了。
               // repulsion: 100, // 节点之间的斥力因子。傻逼文档把edgeLength当数组用的用法写到这上边了。
               repulsion: 300, // 节点之间的斥力因子。傻逼文档把edgeLength当数组用的用法写到这上边了。
               repulsion: 300, // 节点之间的斥力因子。傻逼文档把edgeLength当数组用的用法写到这上边了。
               // gravity: 0.1, // 节点受到的向中心的引力因子。该值越大节点越往中心点靠拢。
               // gravity: 0.1, // 节点受到的向中心的引力因子。该值越大节点越往中心点靠拢。

+ 2 - 2
public/chart4app.html

@@ -251,7 +251,7 @@
         }
         }
       }
       }
       showAll()
       showAll()
-      window.parent.postMessage('fetch data done', '*')
+      window.vuplex.postMessage('fetch data done', '*')
     })
     })
     
     
     let myChart = null
     let myChart = null
@@ -298,7 +298,7 @@
             layout: 'force',
             layout: 'force',
             // 力引导布局是模拟弹簧电荷模型在每两个节点之间添加一个斥力,每条边的两个节点之间添加一个引力
             // 力引导布局是模拟弹簧电荷模型在每两个节点之间添加一个斥力,每条边的两个节点之间添加一个引力
             force: {
             force: {
-              // initLayout: 'circular', // 进行力引导布局前的初始化布局,初始化布局会影响到力引导的效果。默认不进行任何布局,使用节点中提供的 x, y 作为节点的位置。如果不存在的话会随机生成一个位置。也可以选择使用环形布局 'circular'。
+              initLayout: 'circular', // 进行力引导布局前的初始化布局,初始化布局会影响到力引导的效果。默认不进行任何布局,使用节点中提供的 x, y 作为节点的位置。如果不存在的话会随机生成一个位置。也可以选择使用环形布局 'circular'。
               // repulsion: 100, // 节点之间的斥力因子。傻逼文档把edgeLength当数组用的用法写到这上边了。
               // repulsion: 100, // 节点之间的斥力因子。傻逼文档把edgeLength当数组用的用法写到这上边了。
               repulsion: 300, // 节点之间的斥力因子。傻逼文档把edgeLength当数组用的用法写到这上边了。
               repulsion: 300, // 节点之间的斥力因子。傻逼文档把edgeLength当数组用的用法写到这上边了。
               // gravity: 0.1, // 节点受到的向中心的引力因子。该值越大节点越往中心点靠拢。
               // gravity: 0.1, // 节点受到的向中心的引力因子。该值越大节点越往中心点靠拢。

+ 14 - 25
src/views/History.vue

@@ -109,39 +109,28 @@ export default {
     const activeTimeIdx = ref(null)
     const activeTimeIdx = ref(null)
     const activeCorpId = ref('')
     const activeCorpId = ref('')
 
 
-    // loading相关
     const loadingInstance = ElLoading.service({
     const loadingInstance = ElLoading.service({
       background: 'transparent',
       background: 'transparent',
     })
     })
-    function onIframeMessageForLoading(e) {
-      if (e.data === 'fetch data done') {
-        loadingInstance.close()
-      }
-    }
-    window.addEventListener('message', onIframeMessageForLoading)
-    onBeforeUnmount(() => {
-      window.removeEventListener('message', onIframeMessageForLoading)
-    })
 
 
     function onIframeMessage(e) {
     function onIframeMessage(e) {
-      if (e.data.msg !== 'node-selected') {
-        return
-      }
       console.log(e)
       console.log(e)
-      if (e.data.nodeLevel === 0) {
-        activeTimeIdx.value = null
-        activeCorpId.value = null
-      } else if (e.data.nodeLevel === 1) {
-        activeTimeIdx.value = e.data.nodeStageIdx
-        activeCorpId.value = null
-      } else if (e.data.nodeLevel === 2) {
-        activeTimeIdx.value = e.data.nodeStageIdx
-        activeCorpId.value = e.data.nodeId
+      if (e.data === 'fetch data done') {
+        loadingInstance.close()
+      } else if (e.data.msg == 'node-selected') {
+        if (e.data.nodeLevel === 0) {
+          activeTimeIdx.value = null
+          activeCorpId.value = null
+        } else if (e.data.nodeLevel === 1) {
+          activeTimeIdx.value = e.data.nodeStageIdx
+          activeCorpId.value = null
+        } else if (e.data.nodeLevel === 2) {
+          activeTimeIdx.value = e.data.nodeStageIdx
+          activeCorpId.value = e.data.nodeId
+        }
       }
       }
     }
     }
-    onMounted(() => {
-      window.addEventListener('message', onIframeMessage)
-    })
+    window.addEventListener('message', onIframeMessage)
     onBeforeUnmount(() => {
     onBeforeUnmount(() => {
       window.removeEventListener('message', onIframeMessage)
       window.removeEventListener('message', onIframeMessage)
     })
     })