فهرست منبع

1:嵌入页面地址跳转,改变地址的bizId
2:监听思维导图事件,动态改变iframe样式

mambachenhao_i@didiglobal.com 4 سال پیش
والد
کامیت
4346d332a3
1فایلهای تغییر یافته به همراه27 افزوده شده و 1 حذف شده
  1. 27 1
      src/views/useCase/components/requirementCase.vue

+ 27 - 1
src/views/useCase/components/requirementCase.vue

@@ -2,6 +2,7 @@
   <section v-if="bizId !== -1" v-loading="loading" class="case-main">
     <iframe
       id="useCaseIframe"
+      :class="{ 'full-screen': fullScreen}"
       frameborder="0"
       scrolling="no"
       :src="src"
@@ -18,7 +19,8 @@ export default {
     return {
       ifr: null,
       srcHost: '/case/caseList/zhihui/',
-      loading: true
+      loading: true,
+      fullScreen: false, // 是否全屏
     }
   },
   computed: {
@@ -49,6 +51,21 @@ export default {
         this.loading = false
         this.loaded()
       }
+      if(e.data && e.data.event){
+        const { event, payload } = e.data;
+        // 链接跳转时发送message的data
+        if (event === 'case-link') {
+          this.$store.dispatch('global/setBizId', payload.site)
+          // 获取当前打开页面地址
+          const websiteUrl =  window.location.href.replace(/bizId=.*/,`bizId=${payload.site}`);
+          // 改变浏览器历史URL
+          window.history.pushState({url: websiteUrl, title: document.title}, document.title, websiteUrl)
+        }
+        // 全屏操作时发送message的data
+        if (event === 'case-operations') {
+          this.fullScreen = payload.fullScreen
+        }
+      }
     }, false)
   },
   beforeDestroy() {
@@ -77,4 +94,13 @@ export default {
   width: 100%;
   height: 100vh;
 }
+.full-screen {
+  position: fixed;
+  left: 0;
+  right: 0;
+  top: 0;
+  bottom: 0;
+  z-index: 999;
+}
+
 </style>