From db2443273fb437b3195361d759d637d5b2bdbfa0 Mon Sep 17 00:00:00 2001 From: dekun Date: Mon, 15 Jun 2026 13:04:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=B1=E8=89=B2=E6=B5=85=E8=89=B2=E4=B8=BB?= =?UTF-8?q?=E9=A2=98=E5=88=87=E6=8D=A2=EF=BC=9B=E5=8E=BB=E6=8E=89=E6=96=B0?= =?UTF-8?q?=E6=B5=AA=E8=A1=8C=E6=83=85=E5=BE=BD=E7=AB=A0=EF=BC=9B=E7=A7=91?= =?UTF-8?q?=E6=8A=80=E6=84=9F=E5=8D=A1=E7=89=87=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Cursor --- static/js/theme.js | 36 +++++ templates/base.html | 301 +++++++++++++++++++++++++++++++++------- templates/keys.html | 6 +- templates/login.html | 134 ++++++++++++++---- templates/plans.html | 11 +- templates/records.html | 2 +- templates/settings.html | 18 +-- templates/stats.html | 12 +- 8 files changed, 418 insertions(+), 102 deletions(-) create mode 100644 static/js/theme.js diff --git a/static/js/theme.js b/static/js/theme.js new file mode 100644 index 0000000..3113231 --- /dev/null +++ b/static/js/theme.js @@ -0,0 +1,36 @@ +(function () { + var KEY = 'qihuo-theme'; + + function apply(theme) { + document.documentElement.setAttribute('data-theme', theme); + try { + localStorage.setItem(KEY, theme); + } catch (e) { /* ignore */ } + var btn = document.getElementById('theme-toggle'); + if (btn) { + btn.setAttribute('data-active', theme); + btn.setAttribute('aria-label', theme === 'light' ? '切换到深色' : '切换到浅色'); + } + } + + var saved = null; + try { + saved = localStorage.getItem(KEY); + } catch (e) { /* ignore */ } + + if (saved === 'light' || saved === 'dark') { + apply(saved); + } else { + var prefersLight = window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches; + apply(prefersLight ? 'light' : 'dark'); + } + + document.addEventListener('DOMContentLoaded', function () { + var btn = document.getElementById('theme-toggle'); + if (!btn) return; + btn.addEventListener('click', function () { + var cur = document.documentElement.getAttribute('data-theme') || 'dark'; + apply(cur === 'dark' ? 'light' : 'dark'); + }); + }); +})(); diff --git a/templates/base.html b/templates/base.html index 5b1193d..6fd31e2 100644 --- a/templates/base.html +++ b/templates/base.html @@ -4,24 +4,178 @@ {% block title %}国内期货监控系统{% endblock %} + -