Estazz commited on
Commit
1c6af9d
·
verified ·
1 Parent(s): 05cfbde

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -2
app.py CHANGED
@@ -5,6 +5,36 @@ import os
5
  # ===== 你的自定义模块 =====
6
  from config import API_KEY, APP_TITLE, CHATBOT_HEIGHT, MIN_WIDTH_LEFT, MIN_WIDTH_RIGHT
7
  from styles import POKER_THEME_CSS
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  from ai_service import design_poker_game
9
  # 优先尝试原生流式;没有则自动回退为伪流式
10
  try:
@@ -145,10 +175,13 @@ def export_history_to_markdown(history):
145
 
146
  # ==================== Gradio 界面(Poker Skin) ====================
147
  with gr.Blocks(
148
- theme=gr.themes.Soft(),
149
  title=APP_TITLE,
150
- css=POKER_THEME_CSS
 
151
  ) as demo:
 
 
152
  # 顶部 Hero
153
  gr.HTML("""
154
  <div class="hero">
 
5
  # ===== 你的自定义模块 =====
6
  from config import API_KEY, APP_TITLE, CHATBOT_HEIGHT, MIN_WIDTH_LEFT, MIN_WIDTH_RIGHT
7
  from styles import POKER_THEME_CSS
8
+
9
+ # Extra CSS to force dark & counter browser auto-invert
10
+ EXTRA_FIX_CSS = '''/* === Force dark site and neutralize browser-side auto-invert === */
11
+ html, body{ background-color:#0b1220 !important; color-scheme: dark !important; }
12
+ /* When browser/extension applies global invert, add a counter-invert on our app root */
13
+ html.force-dark-fix #app-root{ filter: invert(1) hue-rotate(180deg) !important; }'''
14
+ # Redirect to ?__theme=dark
15
+ FORCE_DARK_REDIRECT = '''<script>
16
+ (function(){
17
+ try{
18
+ const url=new URL(window.location.href);
19
+ if(url.searchParams.get("__theme")!=="dark"){
20
+ url.searchParams.set("__theme","dark");
21
+ window.location.replace(url.toString());
22
+ }
23
+ }catch(e){}
24
+ })();
25
+ </script>'''
26
+ # Detect browser force-dark and set html class
27
+ DETECT_FORCE_DARK = '''<script>
28
+ (function(){
29
+ try{
30
+ const html=document.documentElement;
31
+ const cs=getComputedStyle(html);
32
+ const hasGlobalFilter=(cs.filter && cs.filter!=="none");
33
+ const darkReaderOn=!!document.querySelector('style#dark-reader-style')||!!document.querySelector('meta[name="darkreader"]');
34
+ if(hasGlobalFilter||darkReaderOn){ html.classList.add('force-dark-fix'); }
35
+ }catch(e){}
36
+ })();
37
+ </script>'''
38
  from ai_service import design_poker_game
39
  # 优先尝试原生流式;没有则自动回退为伪流式
40
  try:
 
175
 
176
  # ==================== Gradio 界面(Poker Skin) ====================
177
  with gr.Blocks(
178
+ theme=gr.themes.Soft(primary_hue='emerald', neutral_hue='slate'),
179
  title=APP_TITLE,
180
+ css=POKER_THEME_CSS + EXTRA_FIX_CSS,
181
+ elem_id='app-root'
182
  ) as demo:
183
+ gr.HTML(FORCE_DARK_REDIRECT)
184
+ gr.HTML(DETECT_FORCE_DARK)
185
  # 顶部 Hero
186
  gr.HTML("""
187
  <div class="hero">