JJJJJllll commited on
Commit
291d3ab
·
1 Parent(s): 7a4ec7f

fix all black

Browse files
Files changed (1) hide show
  1. app.py +33 -6
app.py CHANGED
@@ -114,21 +114,48 @@ with gr.Blocks(
114
  position: fixed;
115
  inset: 0;
116
  background: #0b1020;
117
- z-index: 9999;
 
118
  transition: opacity .3s ease;
119
  }
 
120
  </style>
121
  <div id="dark-loader"></div>
122
  <script>
123
- window.addEventListener("DOMContentLoaded", ()=>{
124
- const cover = document.getElementById("dark-loader");
125
- // Safari 下延迟 0.5s 再淡出,确保 Gradio 已渲染
126
- setTimeout(()=>{ cover.style.opacity="0"; cover.style.pointerEvents="none"; }, 800);
127
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  </script>
129
  """)
130
 
131
 
 
132
  gr.HTML(topbar())
133
 
134
  with gr.Row():
 
114
  position: fixed;
115
  inset: 0;
116
  background: #0b1020;
117
+ z-index: 2147483647; /* 顶层 */
118
+ opacity: 1;
119
  transition: opacity .3s ease;
120
  }
121
+ #dark-loader.hidden { opacity: 0; pointer-events: none; }
122
  </style>
123
  <div id="dark-loader"></div>
124
  <script>
125
+ (function(){
126
+ const cover = document.getElementById('dark-loader');
127
+ if (!cover) return;
128
+
129
+ function hideCover(){
130
+ if (!cover || cover.classList.contains('hidden')) return;
131
+ cover.classList.add('hidden');
132
+ cover.addEventListener('transitionend', ()=> cover.remove(), { once:true });
133
+ }
134
+
135
+ // 1) 如果文档已经加载完成,直接安排一个微延迟隐藏
136
+ if (document.readyState !== 'loading') {
137
+ setTimeout(hideCover, 300);
138
+ }
139
+
140
+ // 2) 兜底:页面 load 后再尝试一次
141
+ window.addEventListener('load', ()=> setTimeout(hideCover, 300));
142
+
143
+ // 3) 关键:等待 gradio-app 的 shadowRoot 和 .gradio-container 出现
144
+ const t0 = Date.now();
145
+ const iv = setInterval(()=>{
146
+ const host = document.querySelector('gradio-app');
147
+ const ready = host && host.shadowRoot && host.shadowRoot.querySelector('.gradio-container');
148
+ if (ready || Date.now() - t0 > 5000) { // 最多等 5s
149
+ hideCover();
150
+ clearInterval(iv);
151
+ }
152
+ }, 50);
153
+ })();
154
  </script>
155
  """)
156
 
157
 
158
+
159
  gr.HTML(topbar())
160
 
161
  with gr.Row():