From c3654543950a553566faf7adf0ed244ab3e0183c Mon Sep 17 00:00:00 2001 From: Jacky Date: Sun, 9 Aug 2026 00:34:31 +0800 Subject: [PATCH] fix: keep admin theme contrast consistent --- backend/common/test_frontend_assets.py | 14 ++++ backend/static/admin/css/hulumath_admin.css | 75 +++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/backend/common/test_frontend_assets.py b/backend/common/test_frontend_assets.py index 6e185e7..fd44998 100644 --- a/backend/common/test_frontend_assets.py +++ b/backend/common/test_frontend_assets.py @@ -20,3 +20,17 @@ def test_app_css_答题提交按钮可见且长弹窗可滚动(): assert "background: var(--green); color: white; text-align: center" in source assert "max-height: calc(100dvh - 30px)" in source assert "overflow-y: auto" in source + + +def test_admin_css_深色系统下仍保持完整浅色主题(): + source = (STATIC_ROOT / "admin" / "css" / "hulumath_admin.css").read_text( + encoding="utf-8" + ) + + assert "color-scheme: light" in source + assert "--body-fg: #17211b" in source + assert "--body-bg: #f3f1e9" in source + assert "--darkened-bg: #ebeae3" in source + assert "background-color: #ffffff !important" in source + assert ".theme-toggle" in source + assert "display: none" in source diff --git a/backend/static/admin/css/hulumath_admin.css b/backend/static/admin/css/hulumath_admin.css index 6b64a4d..e4bd57b 100644 --- a/backend/static/admin/css/hulumath_admin.css +++ b/backend/static/admin/css/hulumath_admin.css @@ -1,4 +1,5 @@ :root { + color-scheme: light; --hulu-ink: #17211b; --hulu-green: #196548; --hulu-green-dark: #124d37; @@ -8,18 +9,44 @@ --hulu-line: #dfe2da; --hulu-muted: #6b756e; --primary: #196548; + --primary-fg: #ffffff; --secondary: #17211b; --accent: #cce85b; + --body-fg: #17211b; + --body-bg: #f3f1e9; + --body-quiet-color: #6b756e; + --body-loud-color: #0d1510; --header-bg: #17211b; --header-color: #ffffff; + --header-branding-color: #ffffff; + --header-link-color: #ffffff; + --breadcrumbs-fg: #f3f1e9; --breadcrumbs-bg: #235f47; --breadcrumbs-link-fg: #f3f1e9; --link-fg: #196548; --link-hover-color: #124d37; + --link-selected-fg: #124d37; + --hairline-color: #e4e6df; + --border-color: #ccd2ca; + --error-fg: #b84136; + --message-success-bg: #dcefe5; + --message-warning-bg: #fff1c7; + --message-error-bg: #f8deda; + --darkened-bg: #ebeae3; + --selected-bg: #e2e9e2; + --selected-row: #dce9df; + --button-fg: #ffffff; --button-bg: #196548; --button-hover-bg: #124d37; --default-button-bg: #17211b; --default-button-hover-bg: #2c3931; + --close-button-bg: #667169; + --close-button-hover-bg: #3e4942; + --delete-button-bg: #b84136; + --delete-button-hover-bg: #913128; + --object-tools-fg: #ffffff; + --object-tools-bg: #196548; + --object-tools-hover-bg: #124d37; } body { @@ -27,6 +54,10 @@ body { color: var(--hulu-ink); } +.theme-toggle { + display: none; +} + #header { min-height: 70px; padding: 0 28px; @@ -125,6 +156,19 @@ div.breadcrumbs { background: #ebeae3; } +#nav-sidebar .module, +#nav-sidebar .module table, +#nav-sidebar .module th, +#nav-sidebar .module td { + background: var(--hulu-panel); + color: var(--hulu-ink); +} + +#nav-sidebar .module td, +#nav-sidebar .module th { + border-color: var(--hulu-line); +} + #nav-sidebar .current-app .section, #nav-sidebar .current-model { background: rgba(25, 101, 72, .1); @@ -164,6 +208,14 @@ select, border-radius: 8px !important; } +input:not([type=submit]):not([type=button]):not([type=checkbox]):not([type=radio]), +textarea, +select, +.vTextField { + background-color: #ffffff !important; + color: var(--hulu-ink) !important; +} + input:focus, textarea:focus, select:focus { @@ -172,6 +224,29 @@ select:focus { outline: none; } +.form-row, +.submit-row { + border-color: var(--hulu-line); + background: var(--hulu-panel); +} + +.form-row label, +.form-row p, +.form-row .help, +.form-row div.help, +.form-row div.help li { + color: var(--hulu-muted); +} + +.form-row label { + color: #334039; + font-weight: 600; +} + +.submit-row { + border: 1px solid var(--hulu-line); +} + .button, input[type=submit], input[type=button], -- 2.54.0