From f0407f3a98a47b653edf123bfdaa09e66f0559b2 Mon Sep 17 00:00:00 2001 From: hmo Date: Mon, 27 Jul 2026 09:42:06 +0800 Subject: [PATCH] =?UTF-8?q?fix(ui):=20=E5=8F=B3=E4=B8=8A=E8=A7=92=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E6=94=B9=E4=B8=BA=E5=90=8C=E6=97=B6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E6=95=B0=E6=8D=AE=E6=97=B6=E9=97=B4+?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=88=B7=E6=96=B0=E6=97=B6=E9=97=B4=EF=BC=8C?= =?UTF-8?q?=E5=90=84=E5=B8=A6=E5=9B=BE=E6=A0=87=E5=92=8C=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 14 +++++++++++++- static/index.html | 11 +++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/server.py b/server.py index 73f49b0d..514b28fb 100644 --- a/server.py +++ b/server.py @@ -280,10 +280,22 @@ def get_watch(): d.pop('_pos', None) d.pop('_rr', None) + # 数据最新更新时间(price_monitor/live_prices) + _data_time = "" + try: + _dtc = sqlite3.connect("/home/hmo/MoFin/data/mofin.db") + _r = _dtc.execute("SELECT MAX(updated_at) FROM live_prices").fetchone() + if _r and _r[0]: + _data_time = str(_r[0]) + _dtc.close() + except Exception: + pass + return json.dumps({"stocks": results, "count": len(results), "cash": _cash, "total_assets": _total, "budget_pct": round(_budget_pct, 2), - "rec_used_pct": round(_cum, 2)}, ensure_ascii=False) + "rec_used_pct": round(_cum, 2), + "data_time": _data_time}, ensure_ascii=False) @app.route("/api/strategy_history/") diff --git a/static/index.html b/static/index.html index c8e13046..bdf9424f 100644 --- a/static/index.html +++ b/static/index.html @@ -265,16 +265,23 @@ async function fetchJSON(url) { async function refreshAll() { document.getElementById('tab-overview').classList.add('loading'); - const [overview, portfolio, watchlist, reports] = await Promise.all([ + const [overview, portfolio, watchlist, reports, watchData] = await Promise.all([ fetchJSON('/api/overview'), fetchJSON('/api/portfolio'), fetchJSON('/api/watchlist'), fetchJSON('/api/reports'), + fetchJSON('/api/watch'), ]); portfolioData = portfolio; watchlistData = watchlist; reportsData = Array.isArray(reports) ? reports : []; - document.getElementById('updateTime').textContent = '更新 ' + new Date().toLocaleTimeString('zh-CN', {hour:'2-digit',minute:'2-digit'}); + // 右上角时间显示:来源时间说明 + let timeParts = ['⏱页面 ' + new Date().toLocaleTimeString('zh-CN', {hour:'2-digit',minute:'2-digit'})]; + if (watchData && watchData.data_time) { + const dt = watchData.data_time.slice(5,16); + timeParts.unshift('📡价格 ' + dt); + } + document.getElementById('updateTime').textContent = timeParts.join(' | '); document.getElementById('tab-overview').classList.remove('loading'); renderTab(document.querySelector('.tab-btn.active')?.dataset?.tab || 'overview'); }