chenlei 4 godzin temu
rodzic
commit
b38226f15f

+ 1 - 0
public/js/Hot.js

@@ -1918,6 +1918,7 @@ window.initHot = function(model){
             docFragment.appendChild(li);
              
         }) 
+        window.hotList = hots
         setTimeout(()=>{        
             var ul = document.querySelector('#hotListContent ul');
             ul && ul.appendChild(docFragment);   

+ 11 - 0
src/index/views/home/index.scss

@@ -31,6 +31,17 @@
   }
 }
 
+.home-iframe {
+  width: 100%;
+  height: 100%;
+
+  iframe {
+    width: 100%;
+    height: 100%;
+    display: block;
+  }
+}
+
 #player {
   position: absolute;
   left: 0;

+ 29 - 0
src/index/views/home/index.tsx

@@ -32,16 +32,45 @@ export default defineComponent({
     Popup,
   },
   setup() {
+    let isInIframe = false;
+    try {
+      isInIframe = window.self !== window.top;
+    } catch {
+      // 如果由于跨域/安全限制导致访问 window.top 抛错,则保守按 iframe 渲染内容
+      isInIframe = true;
+    }
+
+    const iframeSrc = (() => {
+      try {
+        const url = new URL(window.location.href);
+        // 强制内部脚本按 autoplay 分支继续加载,避免 iframe 嵌入模式卡住进度条
+        url.searchParams.set('play', '1');
+        return url.toString();
+      } catch {
+        return window.location.href;
+      }
+    })();
+
     const baseStore = useBaseStore();
     const { manageJsLoaded } = storeToRefs(baseStore);
     const hotJsLoaded = ref(false);
 
     return {
+      iframeSrc,
+      isInIframe,
       manageJsLoaded,
       hotJsLoaded,
     };
   },
   render() {
+    if (!this.isInIframe) {
+      return (
+        <div class="home home-iframe">
+          <iframe src={this.iframeSrc} title="home-iframe" />
+        </div>
+      );
+    }
+
     return (
       <div class="home">
         {/* 进度条加载 */}