()
| 593 | return data; |
| 594 | } |
| 595 | async function ensureAdminChecked(){ |
| 596 | if(S.admin._checking) return; |
| 597 | S.admin._checking = true; |
| 598 | try{ |
| 599 | const health = await api('/api/health', { auth:false }); |
| 600 | S.admin.enabled = !!health.enabled; |
| 601 | setAdminStatus(health.enabled ? '管理 API 已启用,输入 token 后可编辑配置。' : '管理 API 未启用:请在容器环境变量设置 ADMIN_TOKEN。', health.enabled ? '' : 'err'); |
| 602 | if(S.admin.enabled && S.admin.token) await loadConfig(); |
| 603 | }catch(err){ |
| 604 | setAdminStatus('无法连接管理 API:' + err.message, 'err'); |
| 605 | }finally{ |
| 606 | S.admin._checking = false; |
| 607 | } |
| 608 | } |
| 609 | function setAdminStatus(text, cls){ |
| 610 | const el = $('adminStatus'); |
| 611 | el.className = 'admin-status' + (cls ? ' ' + cls : ''); |
no test coverage detected