MCPcopy Create free account
hub / github.com/cppla/ServerStatus / ensureAdminChecked

Function ensureAdminChecked

web/js/app.js:595–608  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

593 return data;
594}
595async 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}
609function setAdminStatus(text, cls){
610 const el = $('adminStatus');
611 el.className = 'admin-status' + (cls ? ' ' + cls : '');

Callers 1

bindTabsFunction · 0.85

Calls 3

apiFunction · 0.85
setAdminStatusFunction · 0.85
loadConfigFunction · 0.85

Tested by

no test coverage detected