wws пре 1 година
родитељ
комит
a236dd9de7

+ 2 - 0
deploy.sh

@@ -0,0 +1,2 @@
+yarn build
+scp -r dist/* ubuntu@114.132.216.202:/opt/1panel/apps/openresty/openresty/www/sites/e.meitu.asia/index

+ 1 - 0
package.json

@@ -9,6 +9,7 @@
   },
   "dependencies": {
     "@polyv/live-watch-sdk": "^1.9.2",
+    "@polyv/web-view-bridge": "^0.1.0-rc.1",
     "babel-plugin-import": "^1.13.8",
     "core-js": "^3.8.3",
     "lib-flexible": "^0.3.2",

+ 53 - 2
src/components/live-header/LiveHeader.vue

@@ -1,9 +1,11 @@
 <script>
 import LiveNotice from "@/components/notcie/LiveNotice.vue";
+import TestSmallWin from "@/components/test-small-win/TestSmallWin.vue";
+// import {WebViewBridge} from "@polyv/web-view-bridge";
 
 export default {
   name: "LiveHeader",
-  components: {LiveNotice},
+  components: {TestSmallWin, LiveNotice},
   props: {
     // 是否全屏
     isFullScreen: {
@@ -11,6 +13,53 @@ export default {
       default: false,
     }
   },
+  data() {
+    return {
+      webviewBridge: null,
+      show: false,
+    }
+  },
+  async mounted() {
+    /*this.webviewBridge = new WebViewBridge();
+
+    console.log("webviewBridge", this.webviewBridge)
+
+
+    //初始化
+    await this.webviewBridge.connectWebViewBridge();
+    // webview 被小窗化
+    this.webviewBridge.on('changeToSmall', (event) => {
+      console.log("event:changeToSmall:", event)
+    });
+
+    // webview 取消小窗化
+    this.webviewBridge.on('changeToNormal', (event) => {
+      console.log("event:changeToNormal:", event)
+    });
+
+    this.webviewBridge.on('callWebViewEvent', (event) => {
+      console.log("event:callWebViewEvent:", event)
+    });*/
+  },
+  methods: {
+    // 进入小窗
+    handleSmallWindow() {
+      this.webviewBridge?.sendData('clickProduct', {
+        newPage: false,
+        ...{width: 375, height: 180,}
+      });
+    },
+
+    // 退出小窗
+    handleExitSmallWindow() {
+      this.webviewBridge?.sendData('changeToNormal', {});
+    },
+
+    // 关闭页面
+    handleCloseWindow() {
+      this.webviewBridge?.sendData('closeWindow', {});
+    }
+  },
   computed: {
     headerClass() {
       return this.isFullScreen ? 'horiz' : "vertical"
@@ -35,7 +84,7 @@ export default {
       </div>
 
       <div class="header-r">
-        <img src="@/assets/fenestrule.png" class="header-r-icon" />
+        <img src="@/assets/fenestrule.png" class="header-r-icon" @click="show = true" />
         <img src="@/assets/more.png" class="header-r-icon" />
       </div>
     </div>
@@ -47,6 +96,8 @@ export default {
       <img src="@/assets/undulate.png" class="undulate-icon" />
       <span>直播中</span>
     </div>
+
+    <test-small-win :show="show"/>
   </div>
 </template>
 

+ 94 - 0
src/components/test-small-win/TestSmallWin.vue

@@ -0,0 +1,94 @@
+<script>
+import {WebViewBridge} from '@polyv/web-view-bridge';
+
+export default {
+  name: "TestSmallWin",
+  props: {
+    show: {
+      type: Boolean,
+      default: false,
+    }
+  },
+  data() {
+    return {
+      muted: true,
+      webviewBridge: null
+    }
+  },
+  async mounted() {
+    setTimeout(() => {
+      this.muted = false;
+    }, 1000)
+
+    this.webviewBridge = new WebViewBridge();
+
+    console.log("webviewBridge", this.webviewBridge)
+
+
+    //初始化
+    await this.webviewBridge.connectWebViewBridge();
+    // webview 被小窗化
+    this.webviewBridge.on('changeToSmall', (event) => {
+      console.log("event:changeToSmall:", event)
+    });
+
+    // webview 取消小窗化
+    this.webviewBridge.on('changeToNormal', (event) => {
+      console.log("event:changeToNormal:", event)
+    });
+
+    this.webviewBridge.on('callWebViewEvent', (event) => {
+      console.log("event:callWebViewEvent:", event)
+    });
+  },
+  methods: {
+    handleSmallWindow() {
+      this.webviewBridge?.sendData('clickProduct', {
+        newPage: false,
+        ...{width: 375, height: 180,}
+      });
+    },
+
+    handleExitSmallWindow() {
+      this.webviewBridge?.sendData('changeToNormal', {});
+    },
+
+
+    handleCloseWindow() {
+      this.webviewBridge?.sendData('closeWindow', {});
+    }
+  },
+  watch: {
+    show: {
+      handler(val) {
+        if(val) {
+          this.handleSmallWindow();
+        }
+      }
+    }
+  }
+}
+</script>
+
+<template>
+  <div v-show="show"
+      style="display: flex; align-items: center; justify-content: center;flex-direction: column;width:100vw;height: 100vh;">
+    <div @click="handleSmallWindow" style="height: 48px">进入小窗</div>
+    <div @click="handleExitSmallWindow" style="height: 48px">退出小窗</div>
+    <div @click="handleCloseWindow" style="height: 48px">关闭页面</div>
+  </div>
+</template>
+
+<style scoped>
+
+.icon {
+  width: 28px;
+  height: 28px;
+}
+
+.video {
+  width: 100vw;
+  height: 300px;
+}
+
+</style>

+ 3 - 3
src/router/index.js

@@ -18,8 +18,8 @@ const routes = [
     component: () => import( '../views/live/VerticalLive.vue')
   },
   {
-    path: '/test',
-    component: () => import( '../views/test/Test.vue')
+    path: '/demo',
+    component: () => import( '../views/test/Test1.vue')
   },
   {
     path: '/feed',
@@ -34,7 +34,7 @@ const routes = [
 ]
 
 const router = new VueRouter({
-  mode: 'history',
+  mode: 'hash',
   base: process.env.BASE_URL,
   routes
 })

+ 82 - 0
src/views/test/Test1.vue

@@ -0,0 +1,82 @@
+<script>
+import {WebViewBridge} from '@polyv/web-view-bridge';
+
+export default {
+  name: "TestPage",
+  data() {
+    return {
+      muted: true,
+      webviewBridge: null
+    }
+  },
+  async mounted() {
+    setTimeout(() => {
+      this.muted = false;
+    }, 1000)
+
+    this.webviewBridge = new WebViewBridge();
+
+    console.log("webviewBridge", this.webviewBridge)
+
+
+    //初始化
+    await this.webviewBridge.connectWebViewBridge();
+    // webview 被小窗化
+    this.webviewBridge.on('changeToSmall', (event) => {
+      console.log("event:changeToSmall:", event)
+    });
+
+    // webview 取消小窗化
+    this.webviewBridge.on('changeToNormal', (event) => {
+      console.log("event:changeToNormal:", event)
+    });
+
+    this.webviewBridge.on('callWebViewEvent', (event) => {
+      console.log("event:callWebViewEvent:", event)
+    });
+  },
+  methods: {
+    handlePlay() {
+      this.$refs.video.play();
+    },
+    handleSmallWindow() {
+      this.webviewBridge?.sendData('clickProduct', {
+        newPage: false,
+        ...{width: 375, height: 180,}
+      });
+    },
+
+    handleExitSmallWindow() {
+      this.webviewBridge?.sendData('changeToNormal', {});
+    },
+
+
+     handleCloseWindow() {
+      this.webviewBridge?.sendData('closeWindow', {});
+    }
+  }
+}
+</script>
+
+<template>
+  <div
+      style="display: flex; align-items: center; justify-content: center;flex-direction: column;width:100vw;height: 100vh;">
+    <div @click="handleSmallWindow" style="height: 48px">进入小窗</div>
+    <div @click="handleExitSmallWindow" style="height: 48px">退出小窗</div>
+    <div @click="handleCloseWindow" style="height: 48px">关闭页面</div>
+  </div>
+</template>
+
+<style scoped>
+
+.icon {
+  width: 28px;
+  height: 28px;
+}
+
+.video {
+  width: 100vw;
+  height: 300px;
+}
+
+</style>

+ 5 - 0
yarn.lock

@@ -1103,6 +1103,11 @@
   resolved "https://npm-registry.polyv.net/@polyv%2flive-watch-sdk/-/live-watch-sdk-1.9.2.tgz#3a71f1a9de05e60305ccc56066be73aa1a782c88"
   integrity sha512-I0YIajYEDEL4hdm0lKHMXLdJEBqhTzDGdz9eER9pq30ya/aCxKknivXYteyJsXFBtnMgpszImEUKTyWvS589Pg==
 
+"@polyv/web-view-bridge@^0.1.0-rc.1":
+  version "0.1.0-rc.1"
+  resolved "https://registry.npmmirror.com/@polyv/web-view-bridge/-/web-view-bridge-0.1.0-rc.1.tgz#398db844c64ba9bac2e9de5de142f97d9ac4b326"
+  integrity sha512-iXFl40dzPip74Mp1/UES8f1d3Si5vx+5n0LtMjjUDCQAoT6gOMOjaYdZxqCtcMzxT5P2TuZDsDPY3JNN3OoV+g==
+
 "@sideway/address@^4.1.5":
   version "4.1.5"
   resolved "https://registry.npmmirror.com/@sideway/address/-/address-4.1.5.tgz#4bc149a0076623ced99ca8208ba780d65a99b9d5"