File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " relay-monitor" ,
3- "version" : " 1.7.1 " ,
3+ "version" : " 1.7.2 " ,
44 "private" : true ,
55 "description" : " 监控 sub2api / new-api 中转站余额的网页面板" ,
66 "type" : " module" ,
Original file line number Diff line number Diff line change @@ -1713,6 +1713,15 @@ $("#refreshBtn").onclick = (e) => doRefreshAll(e.currentTarget);
17131713// 后台数据更新只在这两个数据视图上触发重绘
17141714const isDataView = ( ) => state . view === "dashboard" || state . view === "stations" ;
17151715
1716+ // 按当前视图刷新数据:用量/我的站点只替换正文区域,筛选控件不受影响;
1717+ // 设置/通知页有表单,跳过自动重绘
1718+ function refreshCurrentView ( ) {
1719+ if ( isDataView ( ) ) return reload ( ) . catch ( ( ) => { } ) ;
1720+ if ( state . view === "usage" ) return loadUsage ( true ) ;
1721+ if ( state . view === "own" ) return loadOwn ( true ) ;
1722+ return Promise . resolve ( ) ;
1723+ }
1724+
17161725async function doRefreshAll ( btn ) {
17171726 btn ?. classList . add ( "spin" ) ;
17181727 try {
@@ -1740,9 +1749,14 @@ async function loadNotifications() {
17401749function startAuto ( ) {
17411750 if ( autoTimer ) clearInterval ( autoTimer ) ;
17421751 const sec = Math . max ( 10 , state . settings . refreshIntervalSec || 60 ) ;
1743- autoTimer = setInterval ( ( ) => { if ( isDataView ( ) ) reload ( ) . catch ( ( ) => { } ) ; } , sec * 1000 ) ;
1752+ autoTimer = setInterval ( refreshCurrentView , sec * 1000 ) ;
17441753}
17451754
1755+ // 切回浏览器标签页时立即刷新一次,不用等下个周期
1756+ document . addEventListener ( "visibilitychange" , ( ) => {
1757+ if ( ! document . hidden && state . user && $ ( "#loginScreen" ) . hidden ) refreshCurrentView ( ) ;
1758+ } ) ;
1759+
17461760async function bootData ( ) {
17471761 const meta = await api . meta ( ) ;
17481762 state . types = meta . types ;
You can’t perform that action at this time.
0 commit comments