Bläddra i källkod

编辑器:预览区域重新提取到组件树较上层的地方

任一存 3 år sedan
förälder
incheckning
a2fd25ab7b

+ 9 - 0
packages/code/src/config/menu.js

@@ -5,6 +5,7 @@ const PCMenu = [
     icon: "settings",
     link: "/base",
     name: "base",
+    hasPreviewArea: false,
     hidden: false,
   },
   {
@@ -12,6 +13,8 @@ const PCMenu = [
     icon: "navigation",
     link: "/navigation",
     name: "navigation",
+    hasPreviewArea: true,
+    previewAreaExtraLeft: 300,
     hidden: false,
   },
   {
@@ -19,6 +22,8 @@ const PCMenu = [
     icon: "viewpoint",
     link: "/screen",
     name: "screen",
+    hasPreviewArea: true,
+    previewAreaExtraLeft: 0,
     hidden: false
   },
   {
@@ -26,6 +31,8 @@ const PCMenu = [
     icon: "hot",
     link: "/hotspot",
     name: "hotspot",
+    hasPreviewArea: true,
+    previewAreaExtraLeft: 0,
     hidden: false
   },
   {
@@ -33,6 +40,8 @@ const PCMenu = [
     icon: "explanation",
     link: "/explanation",
     name: "explanation",
+    hasPreviewArea: true,
+    previewAreaExtraLeft: 0,
     hidden: false
   }
 ];

+ 18 - 0
packages/code/src/framework/EditorMain.vue

@@ -3,6 +3,15 @@
   <main class="app-main">
     <!-- 左侧菜单栏 -->
     <app-menu class="app-menu"></app-menu>
+    <!-- 作品预览区域。无论切换至哪个菜单页面,始终存在。-->
+    <div
+      class="app-player"
+      ref="layer"
+      v-show="$route.meta.hasPreviewArea"
+      :style="{
+        left: $route.meta.previewAreaExtraLeft + 58 + 'px'
+      }"
+    />
     <!-- 其余 -->
     <div class="app-view">
       <keep-alive>
@@ -31,9 +40,18 @@ export default {
   flex: 1 1 auto;
   height: 1px;
   width: 100%;
+  position: relative;
   > .app-menu {
     flex: 0 0 auto;
   }
+  > .app-player {
+    position: absolute;
+    top: 0;
+    height: 100%;
+    left: 58px;
+    right: 274px;
+    background-color: yellow;
+  }
   > .app-view {
     position: relative;
     flex: 1 0 auto;

+ 0 - 188
packages/code/src/framework/core/core-v1.2.vue

@@ -1,188 +0,0 @@
-<template>
-  <div class="pano-body">
-    <div class="none-center" v-show="!activeItem">请先上传或添加场景素材</div>
-
-    <div v-show="activeItem" id="pano"></div>
-    <template v-if="showSnapshot&&activeItem">
-      <snapshot></snapshot>
-      <button class="ui-button submit" @click="onClick">将当前视角设为初始画面</button>
-    </template>
-  </div>
-</template>
-
-<script>
-// 会广播initView,用于初始-右侧初始化面组件screen/setting.vue里面更新画面截图。
-// 会广播toggleFlash,用于初始-场景预览界面取景框组件snapshot.vue呈现闪白效果。
-// 会监听currentPcode广播,用于与下方的toolbar里切换选中场景事件做同步。
-// 会监听addhotspot广播,用于与热点页面的添加热点事件做同步。
-
-import * as krfn from "@/core/index.js";
-import { uploadCover } from "@/api";
-import { $waiting } from '@/components/shared/loading'
-import { mapGetters } from "vuex";
-
-import Snapshot from "@/components/Snapshot";
-
-let __krfn = krfn.default;
-export default {
-  components: { Snapshot },
-  data() {
-    return {
-      activeItem: '',
-    };
-  },
-  computed: {
-    ...mapGetters({
-      info: "info",
-    }),
-    //用于确保只在初始画面设置页面显示取景框
-    showSnapshot() {
-      return this.$route.name == "screen";
-    },
-  },
-  methods: {
-    // 找到info.scenes中与当前选中场景对应的那一个场景,把当前选中场景的数据拷贝进去。
-    updateInfo(){
-      let iidx = this.info.scenes.findIndex(item=>this.activeItem.sceneCode == item.sceneCode)
-      if (iidx>-1) {
-        this.info.scenes[iidx] = {
-          ...this.activeItem
-        }
-      }
-      this.$store.commit("SetInfo", this.info);
-    },
-    onClick() {
-      this.$bus.emit('toggleFlash',true)
-      let canvas = $("#krpanoSWFObject canvas")[0];
-      let krpano = document.getElementById('krpanoSWFObject');
-      let data = __krfn.utils.setInitView(krpano, canvas);
-
-      console.log(data.url);
-
-      uploadCover(
-        { file: data.url, filename: "initCover.jpg" },
-        res => {
-          if (res.code==0) {
-            this.activeItem.icon = res.data
-            this.activeItem.initVisual= {
-              hlookat: data.hlookat,
-              vlookat: data.vlookat
-            }
-            this.$bus.emit('toggleFlash',false)
-            this.$bus.emit("initView", res.data);
-            this.updateInfo()
-            this.$msg.success("设置成功")
-            this.$store.commit("SetInfo", this.info);
-          }
-        });
-    },
-    // 间接被热点设置页面的添加热点事件导致的addhotspot广播触发。
-    addhotspot(param) {
-      let krpano = document.getElementById('krpanoSWFObject');
-      __krfn.utils.addhotspot(krpano, param, true);
-    }
-  },
-  watch:{
-    // 控制切换路由时全景图中热点的显隐
-    '$route.name':function(newVal){
-        let krpano = document.getElementById('krpanoSWFObject');
-        __krfn.utils.toggleHotspot(krpano,newVal!='screen');
-    },
-    // 会被currentPcode广播间接触发,导致全景图更新。
-    activeItem:{
-      handler(newVal) {
-        if (newVal) {
-          this.$nextTick(()=>{
-            this.$bus.emit("initView", newVal.icon);
-          })
-        }
-        $('#pano').empty();
-        window.vrInitFn = ()=>{
-            $waiting.hide()
-              var krpano = document.getElementById('krpanoSWFObject');
-            __krfn.utils.initHotspot(krpano,newVal&&newVal.someData,true);
-            __krfn.utils.toggleHotspot(krpano,this.$route.name!='screen');
-        }
-        window.vrViewFn = ()=>{
-          try {
-            let tmp = newVal.initVisual
-            var krpano = document.getElementById('krpanoSWFObject');
-            krpano.set('view.vlookat',tmp.vlookat);
-            krpano.set('view.hlookat',tmp.hlookat);
-          } catch (error) {
-            error
-          }
-        }
-               
-        var settings = {
-          'events[skin_events].onxmlcomplete':'js(window.vrViewFn());',
-          'events[skin_events].onloadcomplete': 'js(window.vrInitFn());'
-        };
-        if(newVal){
-            removepano('#pano')
-            $waiting.show()
-            embedpano({
-            // http://oss-xiaoan.oss-cn-shenzhen.aliyuncs.com/720yun_fd_manage/fd720_Va0LrkXW3/vtour/tour.xml
-            // xml: "%HTMLPATH%/static/template/tour.xml",
-            xml: `${this.$cdn}/720yun_fd_manage/${newVal.sceneCode}/vtour/tour.xml`,
-            swf: "%HTMLPATH%/static/template/tour.swf",
-            target: "pano",
-            html5: "auto",
-            mobilescale: 1,
-            vars:settings,
-            webglsettings: { preserveDrawingBuffer: true },
-            passQueryParameters: true,
-          });
-          // $waiting.hide()
-        }
-      },
-      immediate: true
-    }
-  },
-  mounted() {
-    window.__krfn = __krfn;
-   
-    this.$bus.on('currentPcode',data=>{
-      this.activeItem = data
-    })
-    
-    this.$bus.on("addhotspot", data => {
-      this.addhotspot(data);
-    });
-  },
-};
-</script>
-
-<style lang="less" scoped>
-.pano-body {
-  background: blue;
-  width: 100%;
-  position: relative;
-  height: 100%;
-  .none-center{
-    position: absolute;
-    top: 50%;
-    left: 50%;
-    transform: translate(-50%,-50%);
-  }
-  #pano {
-    width: 100%;
-    height: 100%;
-  }
-  .btn {
-    position: absolute;
-    top: 20px;
-    left: 20px;
-    background: #000;
-    cursor: pointer;
-  }
-  .ui-button {
-    position: absolute;
-    bottom: 20px;
-    min-width: 200px;
-    left: 50%;
-    transform: translateX(-50%);
-    z-index: 99;
-  }
-}
-</style>

+ 2 - 0
packages/code/src/router/editorRouter.js

@@ -21,6 +21,8 @@ PCMenu.forEach(item => {
     path: `${item.link}`,
     meta: {
       loading: null,
+      hasPreviewArea: item.hasPreviewArea,
+      previewAreaExtraLeft: item.previewAreaExtraLeft,
     },
     component: () => import(`../views/${item.name}/index.vue`)
   });

+ 5 - 26
packages/code/src/views/explanation/index.vue

@@ -1,27 +1,16 @@
 <template>
   <div class="editor-explanation">
-    <div
-      class="app-player"
-      ref="layer"
-    >
-      <Core/>
-      <Toolbar class="navigation-toolbar"></Toolbar>
-    </div>
     <ExplanationSettings class="explanation-settings"></ExplanationSettings>
   </div>
 </template>
 
 <script>
 import ExplanationSettings from "./explanationSettings.vue";
-import Core from "@/framework/core/core-v1.2.vue";
-import Toolbar from "@/framework/Toolbar.vue";
 
 export default {
   name: "EditorExplanation",
   components: {
     ExplanationSettings,
-    Core,
-    Toolbar,
   },
 };
 </script>
@@ -29,23 +18,13 @@ export default {
 <style lang="less" scoped>
 .editor-explanation {
   height: 100%;
-  display: flex;
-  .app-player {
-    flex: 1 1 auto;
-    padding: 10px;
-    position: relative;
-    height: 100%;
-    .navigation-toolbar {
-      position: absolute;
-      left: 10%;
-      right: 10%;
-      top: 70%;
-      bottom: 10%;
-    }
-  }
+  position: relative;
   .explanation-settings {
+    position: absolute;
+    right: 0;
     width: 274px;
-    flex: 0 0 auto;
+    top: 0;
+    height: 100%;
   }
 }
 </style>

+ 8 - 27
packages/code/src/views/hotspot/index.vue

@@ -1,16 +1,7 @@
 <template>
   <!-- 编辑器-热点 -->
   <div class="editor-hotspot">
-    <!-- 内嵌的全景场景预览区域 -->
-    <div
-      class="app-player"
-      ref="layer"
-    >
-      <Core/>
-      <toolbar class="navigation-toolbar"></toolbar>
-    </div>
-    <setting @select="handleSelectScene"></setting>
-    <!-- <toolbar></toolbar> -->
+    <setting class="hotspot-settings" @select="handleSelectScene"></setting>
     <div class="dialog" v-if="show">
       <Select
         @updateList="undatePano"
@@ -49,18 +40,14 @@
   </div>
 </template>
 <script>
-import Setting from "./Setting";
+import Setting from "./Setting.vue";
 import Select from "@/components/select";
-import Core from "@/framework/core/core-v1.2.vue";
-import Toolbar from "@/framework/Toolbar.vue";
 
 export default {
   name: "home",
   components: {
     Setting,
     Select,
-    Core,
-    Toolbar,
   },
   mounted(){
     
@@ -119,19 +106,13 @@ export default {
 <style lang="less" scoped>
 .editor-hotspot {
   height: 100%;
-  display: flex;
-  .app-player {
-    flex: 1 1 auto;
-    padding: 10px;
-    position: relative;
+  position: relative;
+  .hotspot-settings {
+    position: absolute;
+    right: 0;
+    width: 274px;
+    top: 0;
     height: 100%;
-    .navigation-toolbar {
-      position: absolute;
-      left: 10%;
-      right: 10%;
-      top: 70%;
-      bottom: 10%;
-    }
   }
   .dialog {
     position: fixed;

+ 9 - 27
packages/code/src/views/navigation/index.vue

@@ -1,13 +1,6 @@
 <template>
   <div class="editor-navigation">
     <GroupSettings class="group-settings-area"/>
-    <div
-      class="app-player"
-      ref="layer"
-    >
-      <Core/>
-      <Toolbar class="navigation-toolbar"></Toolbar>
-    </div>
     <InitialSceneSettings class="initial-scene-settings-area"></InitialSceneSettings>
   </div>
 </template>
@@ -15,16 +8,12 @@
 <script>
 import InitialSceneSettings from "./initialSceneSettings.vue";
 import GroupSettings from "./groupSettings.vue";
-import Core from "@/framework/core/core-v1.2.vue";
-import Toolbar from "@/framework/Toolbar.vue";
 
 export default {
   name: "EditorNavigation",
   components: {
     InitialSceneSettings,
     GroupSettings,
-    Core,
-    Toolbar,
   },
 };
 </script>
@@ -32,27 +21,20 @@ export default {
 <style lang="less" scoped>
 .editor-navigation {
   height: 100%;
-  display: flex;
+  position: relative;
   .group-settings-area {
+    position: absolute;
+    left: 0;
     width: 300px;
-    flex: 0 0 auto;
-  }
-  .app-player {
-    flex: 1 1 auto;
-    padding: 10px;
-    position: relative;
-    height: 100%;
-    .navigation-toolbar {
-      position: absolute;
-      left: 10%;
-      right: 10%;
-      top: 70%;
-      bottom: 10%;
-    }
+    top: 0;
+    height: 100%; 
   }
   .initial-scene-settings-area {
+    position: absolute;
+    right: 0;
     width: 274px;
-    flex: 0 0 auto;
+    top: 0;
+    height: 100%;
   }
 }
 </style>

+ 5 - 29
packages/code/src/views/screen/index.vue

@@ -1,30 +1,16 @@
 <template>
   <!-- 编辑器-初始 -->
   <div class="view-screen">
-    <!-- 内嵌的全景场景预览区域 -->
-    <div
-      class="app-player"
-      ref="layer"
-    >
-      <Core/>
-      <Toolbar class="navigation-toolbar"></Toolbar>
-    </div>
-    <!-- 初始和热点 底部的 全景场景列表 -->
-    <!-- <toolbar></toolbar> -->
     <setting class="setting-panel"></setting>
   </div>
 </template>
 <script>
 import Setting from "./Setting.vue";
-import Core from "@/framework/core/core-v1.2.vue";
-import Toolbar from "@/framework/Toolbar.vue";
 
 export default {
   name: "editor-initial-setting",
   components: {
     Setting,
-    Core,
-    Toolbar,
   }
 };
 </script>
@@ -32,23 +18,13 @@ export default {
 <style lang="less" scoped>
 .view-screen {
   height: 100%;
-  display: flex;
-  .app-player {
-    flex: 1 1 auto;
-    padding: 10px;
-    position: relative;
-    height: 100%;
-    .navigation-toolbar {
-      position: absolute;
-      left: 10%;
-      right: 10%;
-      top: 70%;
-      bottom: 10%;
-    }
-  }
+  position: relative;
   .setting-panel {
+    position: absolute;
+    top: 0;
+    height: 100%;
+    right: 0;
     width: 274px;
-    flex: 0 0 auto;
   }
 }
 </style>