Kietcudo commited on
Commit
a4b882b
·
verified ·
1 Parent(s): 7280a59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -11
app.py CHANGED
@@ -810,7 +810,7 @@ LEAF_HERO_HEAD = r"""
810
  else if (edge === 1) { x = width - rng() * width * 0.25; y = rng() * height; }
811
  else if (edge === 2) { x = rng() * width; y = rng() * height * 0.2; }
812
  else { x = rng() * width; y = height - rng() * height * 0.2; }
813
- BORDER_LEAVES.push({ x, y, size: 40 + rng() * 60, baseAngle: (rng() - 0.5) * 1.2, swaySpeed: 0.4 + rng() * 0.8, swayAmp: 0.06 + rng() * 0.1, phase: rng() * TAU, color: LEAF_GREENS[Math.floor(rng() * LEAF_GREENS.length)], alpha: 0.35 + rng() * 0.45 });
814
  }
815
  }
816
  function drawBorderLeaves(t) {
@@ -854,7 +854,7 @@ LEAF_HERO_HEAD = r"""
854
  const T = 1.05, p = (clk % T) / T, g = (x, mu, s) => Math.exp(-((x - mu) * (x - mu)) / (2 * s * s));
855
  return Math.min(1, g(p, 0.07, 0.045) + 0.58 * g(p, 0.27, 0.05));
856
  }
857
- function crossBaseR() { return Math.max(30, Math.min(width, height) * 0.066); }
858
 
859
  // Tia sáng xoay quanh chữ thập
860
  function drawRays(clk, env) {
@@ -995,7 +995,7 @@ LEAF_HERO_HEAD = r"""
995
  }
996
 
997
  shots.sort((a, b) => b.depth - a.depth);
998
- const sizeScale = Math.min(width, height) / 500;
999
  const drawShot = (o, index) => {
1000
  const depth = Math.min(1.3, Math.max(0.5, o.s)), size = o.el.p.size * depth * sizeScale, bright = (o.el.p.glow ?? 1) * k, R = size * 3;
1001
  ctx.globalAlpha = Math.min(0.7, 0.5 * bright); ctx.drawImage(glowSprite(o.el.p.color), o.x - R, o.y - R, R * 2, R * 2); ctx.globalAlpha = 1;
@@ -1210,13 +1210,15 @@ custom_css = """
1210
  opacity: 0; pointer-events: none; transition: opacity 0.6s ease;
1211
  }
1212
  body.leaf-on #leaf-bg { opacity: 1; }
1213
- body.leaf-on { background: #e8f5d6 !important; margin: 0; padding: 0;
1214
  font-family: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
1215
- body.leaf-on .gradio-container { background: transparent !important; font-family: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important; }
 
 
1216
  #login_wrapper h1, #login_wrapper p, #login_wrapper label, #login_wrapper label span, #login_wrapper input, #login_wrapper textarea, #login_wrapper button { font-family: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important; }
1217
 
1218
  #login_wrapper {
1219
- position: relative; z-index: 2; min-height: 100vh;
1220
  display: flex !important; align-items: center !important; justify-content: flex-start !important;
1221
  padding: 0 6vw 0 13vw !important; box-sizing: border-box;
1222
  }
@@ -1228,7 +1230,12 @@ body.leaf-on .gradio-container { background: transparent !important; font-family
1228
  background: transparent !important; padding: 0 !important;
1229
  border: none !important; box-shadow: none !important;
1230
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
 
1231
  }
 
 
 
 
1232
  @media (max-width: 767px) {
1233
  #login_wrapper { padding: 12vh 1.5rem 0 !important; align-items: flex-start !important; }
1234
  #login_content_col { max-width: 100% !important; }
@@ -1247,7 +1254,7 @@ body.leaf-on .gradio-container { background: transparent !important; font-family
1247
  font-size: clamp(1.5rem, 2.6vw, 2.1rem); color: #16281a; }
1248
  .lv4-accent { background: linear-gradient(120deg, #34d399, #059669 55%, #2d7a12);
1249
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
1250
- .lv4-sub { margin: .6rem 0 .2rem; font-size: .92rem; color: #3d5233; }
1251
  @keyframes lv4-beat { 0%,100%{transform:scale(1);} 6%{transform:scale(1.22);} 12%{transform:scale(1);} 26%{transform:scale(1.13);} 34%{transform:scale(1);} }
1252
  @media (prefers-reduced-motion: reduce){ .lv4-heart{ animation: none; } }
1253
 
@@ -1269,7 +1276,7 @@ body.leaf-on .gradio-container { background: transparent !important; font-family
1269
 
1270
  /* Nút lớn KÍCH HOẠT PHIÊN XÉT NGHIỆM */
1271
  #login_wrapper .scan-btn {
1272
- border-radius: 14px !important; min-height: 56px !important; margin-top: 8px !important; width: 100% !important;
1273
  font-size: 15px !important; font-weight: 800 !important; letter-spacing: .08em !important; text-transform: uppercase !important;
1274
  color: #fff !important; border: none !important; cursor: pointer;
1275
  background: linear-gradient(135deg, #10b981, #047857) !important;
@@ -1280,7 +1287,7 @@ body.leaf-on .gradio-container { background: transparent !important; font-family
1280
  #login_wrapper .scan-btn:active { transform: translateY(0); }
1281
 
1282
  /* Tài khoản thử nghiệm */
1283
- .lv4-demo { margin-top: 1.4rem; font-size: .8rem; color: #5f7255; }
1284
  .lv4-demo-title { display: block; margin-bottom: .5rem; font-weight: 600; color: #3d5233; }
1285
  .lv4-demo-row { display: flex; align-items: center; gap: .5rem; }
1286
  .lv4-chip { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace !important; font-size: .78rem; font-weight: 600;
@@ -1307,13 +1314,13 @@ with gr.Blocks(title="Bệnh Viện Cây Trồng - Hệ Thống Chẩn Đoán AI
1307
  </div>
1308
  <div class="lv4-copy">
1309
  <h1 class="lv4-title">Trung tâm Chẩn đoán &amp; Điều trị Bệnh <span class="lv4-accent">Cây trồng</span> Công nghệ cao</h1>
1310
- <p class="lv4-sub">Cổng kết nối Trợ lý Bác sĩ AI xét nghiệm tế bào lá.</p>
1311
  </div>
1312
  </div>
1313
  """)
1314
  username_input = gr.Textbox(label="Tên đăng nhập", placeholder="Nhập tên đăng nhập", max_lines=1)
1315
  password_input = gr.Textbox(label="Mật khẩu", type="password", placeholder="••••••••", max_lines=1)
1316
- error_output = gr.HTML("")
1317
  btn_login = gr.Button("Kích hoạt phiên xét nghiệm", variant="primary", elem_classes="scan-btn")
1318
  gr.HTML("""
1319
  <div class="lv4-demo">
 
810
  else if (edge === 1) { x = width - rng() * width * 0.25; y = rng() * height; }
811
  else if (edge === 2) { x = rng() * width; y = rng() * height * 0.2; }
812
  else { x = rng() * width; y = height - rng() * height * 0.2; }
813
+ BORDER_LEAVES.push({ x, y, size: (40 + rng() * 60) * 0.95, baseAngle: (rng() - 0.5) * 1.2, swaySpeed: 0.4 + rng() * 0.8, swayAmp: 0.06 + rng() * 0.1, phase: rng() * TAU, color: LEAF_GREENS[Math.floor(rng() * LEAF_GREENS.length)], alpha: 0.35 + rng() * 0.45 });
814
  }
815
  }
816
  function drawBorderLeaves(t) {
 
854
  const T = 1.05, p = (clk % T) / T, g = (x, mu, s) => Math.exp(-((x - mu) * (x - mu)) / (2 * s * s));
855
  return Math.min(1, g(p, 0.07, 0.045) + 0.58 * g(p, 0.27, 0.05));
856
  }
857
+ function crossBaseR() { return Math.max(27, Math.min(width, height) * 0.0594); } /* nhỏ hơn 10% */
858
 
859
  // Tia sáng xoay quanh chữ thập
860
  function drawRays(clk, env) {
 
995
  }
996
 
997
  shots.sort((a, b) => b.depth - a.depth);
998
+ const sizeScale = Math.min(width, height) / 500 * 0.95; /* lá nhỏ hơn 5% */
999
  const drawShot = (o, index) => {
1000
  const depth = Math.min(1.3, Math.max(0.5, o.s)), size = o.el.p.size * depth * sizeScale, bright = (o.el.p.glow ?? 1) * k, R = size * 3;
1001
  ctx.globalAlpha = Math.min(0.7, 0.5 * bright); ctx.drawImage(glowSprite(o.el.p.color), o.x - R, o.y - R, R * 2, R * 2); ctx.globalAlpha = 1;
 
1210
  opacity: 0; pointer-events: none; transition: opacity 0.6s ease;
1211
  }
1212
  body.leaf-on #leaf-bg { opacity: 1; }
1213
+ body.leaf-on { background: #e8f5d6 !important; margin: 0; padding: 0; height: 100vh; overflow: hidden !important;
1214
  font-family: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
1215
+ html:has(body.leaf-on) { overflow: hidden !important; }
1216
+ body.leaf-on .gradio-container { background: transparent !important; padding: 0 !important; min-height: 0 !important; max-width: none !important; font-family: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important; }
1217
+ body.leaf-on footer { display: none !important; }
1218
  #login_wrapper h1, #login_wrapper p, #login_wrapper label, #login_wrapper label span, #login_wrapper input, #login_wrapper textarea, #login_wrapper button { font-family: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important; }
1219
 
1220
  #login_wrapper {
1221
+ position: relative; z-index: 2; min-height: 100vh; height: 100vh; overflow: hidden;
1222
  display: flex !important; align-items: center !important; justify-content: flex-start !important;
1223
  padding: 0 6vw 0 13vw !important; box-sizing: border-box;
1224
  }
 
1230
  background: transparent !important; padding: 0 !important;
1231
  border: none !important; box-shadow: none !important;
1232
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
1233
+ display: flex !important; flex-direction: column !important; gap: 10px !important;
1234
  }
1235
+ /* Khối sát nhau: bỏ margin thừa của Gradio, thu gọn ô lỗi rỗng */
1236
+ #login_wrapper .block, #login_wrapper .form { margin: 0 !important; }
1237
+ #login_error { margin: 0 !important; min-height: 0 !important; padding: 0 !important; }
1238
+ #login_error:empty { display: none !important; }
1239
  @media (max-width: 767px) {
1240
  #login_wrapper { padding: 12vh 1.5rem 0 !important; align-items: flex-start !important; }
1241
  #login_content_col { max-width: 100% !important; }
 
1254
  font-size: clamp(1.5rem, 2.6vw, 2.1rem); color: #16281a; }
1255
  .lv4-accent { background: linear-gradient(120deg, #34d399, #059669 55%, #2d7a12);
1256
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
1257
+ .lv4-sub { margin: .45rem 0 0; font-size: .92rem; color: #3d5233; }
1258
  @keyframes lv4-beat { 0%,100%{transform:scale(1);} 6%{transform:scale(1.22);} 12%{transform:scale(1);} 26%{transform:scale(1.13);} 34%{transform:scale(1);} }
1259
  @media (prefers-reduced-motion: reduce){ .lv4-heart{ animation: none; } }
1260
 
 
1276
 
1277
  /* Nút lớn KÍCH HOẠT PHIÊN XÉT NGHIỆM */
1278
  #login_wrapper .scan-btn {
1279
+ border-radius: 14px !important; min-height: 54px !important; margin-top: 2px !important; width: 100% !important;
1280
  font-size: 15px !important; font-weight: 800 !important; letter-spacing: .08em !important; text-transform: uppercase !important;
1281
  color: #fff !important; border: none !important; cursor: pointer;
1282
  background: linear-gradient(135deg, #10b981, #047857) !important;
 
1287
  #login_wrapper .scan-btn:active { transform: translateY(0); }
1288
 
1289
  /* Tài khoản thử nghiệm */
1290
+ .lv4-demo { margin-top: .8rem; font-size: .8rem; color: #5f7255; }
1291
  .lv4-demo-title { display: block; margin-bottom: .5rem; font-weight: 600; color: #3d5233; }
1292
  .lv4-demo-row { display: flex; align-items: center; gap: .5rem; }
1293
  .lv4-chip { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace !important; font-size: .78rem; font-weight: 600;
 
1314
  </div>
1315
  <div class="lv4-copy">
1316
  <h1 class="lv4-title">Trung tâm Chẩn đoán &amp; Điều trị Bệnh <span class="lv4-accent">Cây trồng</span> Công nghệ cao</h1>
1317
+ <p class="lv4-sub">Xác thực để mở phiên xét nghiệm mô lá.</p>
1318
  </div>
1319
  </div>
1320
  """)
1321
  username_input = gr.Textbox(label="Tên đăng nhập", placeholder="Nhập tên đăng nhập", max_lines=1)
1322
  password_input = gr.Textbox(label="Mật khẩu", type="password", placeholder="••••••••", max_lines=1)
1323
+ error_output = gr.HTML("", elem_id="login_error")
1324
  btn_login = gr.Button("Kích hoạt phiên xét nghiệm", variant="primary", elem_classes="scan-btn")
1325
  gr.HTML("""
1326
  <div class="lv4-demo">