From 5e20cc7c98560e345508f3dfc2cbdb7e46ee01ec Mon Sep 17 00:00:00 2001 From: wjl2023 Date: Wed, 27 May 2026 16:29:28 +0800 Subject: [PATCH 1/7] feat(token): replace native datetime-local with Flatpickr datepicker - Add Flatpickr CDN (CSS + JS + zh locale) to index.html - Change input type to text with .tok-date class - Add Flatpickr theme override using CSS variables (light + dark) - Initialize Flatpickr instances with ISO dateFormat for Safari compat - Update reset button to use fp.clear() API --- frontends/desktop/static/app.js | 8 ++++--- frontends/desktop/static/index.html | 8 +++++-- frontends/desktop/static/styles.css | 36 ++++++++++++++++++++++++++--- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/frontends/desktop/static/app.js b/frontends/desktop/static/app.js index ca004fe..333831e 100644 --- a/frontends/desktop/static/app.js +++ b/frontends/desktop/static/app.js @@ -2405,10 +2405,12 @@ function tokRenderTable(records) { } async function loadTokenPage(){await tokPollBridge();const f=tokGetFiltered();const all=tokLoadHistory();tokRenderStats(f,all);tokRenderTable(f);} -if(tokSince)tokSince.addEventListener('change',()=>{_tokPage=0;loadTokenPage();}); -if(tokUntil)tokUntil.addEventListener('change',()=>{_tokPage=0;loadTokenPage();}); +/* Flatpickr 初始化 */ +const _fpOpts = { enableTime:true, time_24hr:true, dateFormat:'Y-m-d\\TH:i', locale:window.flatpickr?.l10ns?.[document.documentElement.lang==='en'?'default':'zh']||'default', allowInput:false, onChange(){ _tokPage=0; loadTokenPage(); } }; +const fpSince = tokSince ? flatpickr(tokSince, _fpOpts) : null; +const fpUntil = tokUntil ? flatpickr(tokUntil, _fpOpts) : null; const tokResetBtn=document.getElementById('tok-reset'); -if(tokResetBtn)tokResetBtn.addEventListener('click',()=>{if(tokSince)tokSince.value='';if(tokUntil)tokUntil.value='';_tokPage=0;loadTokenPage();}); +if(tokResetBtn)tokResetBtn.addEventListener('click',()=>{if(fpSince)fpSince.clear();if(fpUntil)fpUntil.clear();_tokPage=0;loadTokenPage();}); nav.addEventListener('click',(e)=>{const item=e.target.closest('.nav-item');if(item&&item.dataset.page==='token')loadTokenPage();if(item&&item.dataset.page==='channels')renderChannelList(gaServiceStore.list());if(item&&item.dataset.page==='status')loadStatusPanel();}); /* ═══════════════ 自定义预设 ═══════════════ */ const CP_KEY = 'ga_custom_presets'; diff --git a/frontends/desktop/static/index.html b/frontends/desktop/static/index.html index 2ffc4c4..b85f69b 100644 --- a/frontends/desktop/static/index.html +++ b/frontends/desktop/static/index.html @@ -8,6 +8,10 @@ + + + +