zhangwei 2 роки тому
батько
коміт
6bad7b3760
3 змінених файлів з 46 додано та 8 видалено
  1. 18 2
      src/entry/content_iframe.js
  2. 2 2
      src/manifest.json
  3. 26 4
      src/view/iframe/tool-box/card.vue

+ 18 - 2
src/entry/content_iframe.js

@@ -16,22 +16,39 @@ history.replaceState = _historyWrap('replaceState')
 window.addEventListener('hashchange', function () {
     getRouterType()
 })
+// document.querySelector('iframe').addEventListener('hashchange', function () {
+//     getRouterType()
+// })
 
 window.addEventListener('popstate', function () {
     getRouterType()
 })
 
+// document.querySelector('iframe').addEventListener('popstate', function () {
+//     getRouterType()
+// })
+
 window.addEventListener('pushState', function () {
     getRouterType()
 })
 
+// document.querySelector('iframe').addEventListener('pushState', function () {
+//     getRouterType()
+// })
+
 window.addEventListener('replaceState', function () {
     getRouterType()
 })
+// document.querySelector('iframe').addEventListener('replaceState', function () {
+//     getRouterType()
+// })
+
 
 let router_data = []
 
+
 const getRouterType = () => {
+    console.log('type', history?.state?.key)
     let key = history?.state?.key
     if (!key) {
         return
@@ -51,5 +68,4 @@ const getRouterType = () => {
         type = 'first'
     }
     return type
-}
-
+}

+ 2 - 2
src/manifest.json

@@ -2,8 +2,8 @@
     "manifest_version": 3,
     "name": "DeNet",
     "description": "Growing more twitter followers with Denet",
-    "version": "1.1.5.2",
-    "denet_app_version_code": "16",
+    "version": "1.1.6",
+    "denet_app_version_code": "17",
     "background": {
         "service_worker": "/js/background.js"
     },

+ 26 - 4
src/view/iframe/tool-box/card.vue

@@ -2,8 +2,8 @@
     <div class="denet-toolbox" :class="{ 'pre-view': pre_view }">
         <div class="head">
             <div class="handle">
-                <img :src="require('@/assets/svg/icon-iframe-left.svg')" />
-                <img :src="require('@/assets/svg/icon-iframe-right.svg')" />
+                <img :src="require('@/assets/svg/icon-iframe-left.svg')" @click="clickBack" />
+                <img :src="require('@/assets/svg/icon-iframe-right.svg')" @click="clickGo" />
             </div>
             <span></span>
             <div v-show="state.show_btn && state.status == 'iframe'">
@@ -16,7 +16,7 @@
         </div>
         <div class="content" v-else>
             <iframe :src="state.iframe_url" v-show="state.status == 'iframe'" ref="dom_iframe" frameborder="0"
-                scrolling="yes" allow="camera *;microphone *"></iframe>
+                id="test1" name="test1" scrolling="yes" allow="camera *;microphone *"></iframe>
             <!-- sandbox="allow-same-origin allow-scripts allow-popups allow-top-navigation allow-forms allow-modals allow-popups-to-escape-sandbox" -->
             <!-- 网页错误 -->
             <div class="state" v-show="state.status == '网页错误'">
@@ -145,8 +145,29 @@ onMounted(() => {
 
 })
 
+const clickGo = () => {
+    window.history.forward();
+}
+
+const clickBack = () => {
+    window.history.back();
+}
+
 // detail函数
 const getDetail = () => {
+    let iframe = dom_iframe.value
+    iframe.onerror = () => {
+        state.status = '网页错误'
+    }
+    iframe.onload = () => {
+        if (state.status == '加载' || state.status == 'iframe') {
+            state.show_btn = true
+            state.status = 'iframe'
+        }
+    }
+    iframe.contentWindow.onpopstate = () => {
+        console.log('onpopstate')
+    }
     getPostDetail({
         params: {
             postId: state.postId
@@ -165,7 +186,8 @@ const getDetail = () => {
             if (state.detail.viewBgImagePath) {
                 state.cover_url = state.detail.viewBgImagePath
             }
-            state.iframe_url = state.detail.convertUrl
+            // state.iframe_url = state.detail.convertUrl
+            state.iframe_url = 'https://www.twitter.com'
         } else {
             state.status = '网页错误'
         }