Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
133959ef74 | ||
|
|
e7ee434306 | ||
|
|
02cbda07e1 |
No files matched your search
@@ -13,6 +13,114 @@ if os.path.isdir(PROCFS):
|
||||
app = Flask(__name__, static_folder="public", static_url_path="")
|
||||
PORT = int(os.environ.get("PORT", "7031"))
|
||||
|
||||
# ---------- CardAuth hub (免费形态: 安装统计/在线/公告/版本推送,失败开放) ----------
|
||||
HUB_URL = os.environ.get("HUB_URL", "https://auth.88531.cn/api").rstrip("/")
|
||||
HUB_PROJECT_ID = os.environ.get("HUB_PROJECT_ID", "12")
|
||||
HUB_VERSION = os.environ.get("SITE_VERSION", "1.3.13")
|
||||
HUB = {"ok": False, "install_id": None, "latest": "", "update_available": False,
|
||||
"update_required": False, "download_url": "", "changelog": "",
|
||||
"announcements": [], "popup": [], "ts": 0}
|
||||
|
||||
def _hub_key():
|
||||
try:
|
||||
kf = os.environ.get("HUB_KEY_FILE", "")
|
||||
if kf and os.path.exists(kf):
|
||||
with open(kf) as f:
|
||||
k = f.read().strip()
|
||||
if k:
|
||||
return k
|
||||
except Exception:
|
||||
pass
|
||||
return os.environ.get("HUB_API_KEY", "").strip()
|
||||
|
||||
def _machine_id():
|
||||
raw = ""
|
||||
for p in ("/host/etc/machine-id", "/etc/machine-id"):
|
||||
try:
|
||||
with open(p) as f:
|
||||
raw = f.read().strip()
|
||||
if raw:
|
||||
break
|
||||
except Exception:
|
||||
continue
|
||||
if not raw:
|
||||
try:
|
||||
raw = open("/proc/sys/kernel/random/uuid").read().strip()
|
||||
except Exception:
|
||||
raw = str(time.time())
|
||||
h = hashlib.sha256(("fnos-resmon-12-" + raw).encode()).hexdigest()
|
||||
return str(int(h[:15], 16) % 10**16).zfill(16)[:16]
|
||||
|
||||
def _hub_post(path, body):
|
||||
key = _hub_key()
|
||||
if not key:
|
||||
return None
|
||||
try:
|
||||
req = urllib.request.Request(
|
||||
HUB_URL + path, data=json.dumps(body).encode(),
|
||||
headers={"Content-Type": "application/json", "X-Api-Key": key,
|
||||
"X-Project-Id": HUB_PROJECT_ID}, method="POST")
|
||||
with urllib.request.urlopen(req, timeout=8) as r:
|
||||
j = json.loads(r.read().decode())
|
||||
return j if j.get("code") == 200 else None
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def _hub_get_ann():
|
||||
try:
|
||||
u = (HUB_URL + "/public/announcements?target=client&project_id="
|
||||
+ urllib.parse.quote(HUB_PROJECT_ID) + "&limit=20")
|
||||
with urllib.request.urlopen(urllib.request.Request(u), timeout=8) as r:
|
||||
j = json.loads(r.read().decode())
|
||||
if j.get("code") != 200:
|
||||
return None
|
||||
d = j.get("data") or {}
|
||||
items = d.get("list", []) or []
|
||||
out = [a for a in items
|
||||
if a.get("project_id") is None or str(a.get("project_id")) == str(HUB_PROJECT_ID)]
|
||||
return {"all": out, "popup": d.get("popup", []) or []}
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
def _hub_loop():
|
||||
mid = _machine_id()
|
||||
last_hb, last_cu = 0, 0
|
||||
while True:
|
||||
try:
|
||||
now = time.time()
|
||||
if now - last_cu >= 6 * 3600:
|
||||
r = _hub_post("/public/installations/check-update",
|
||||
{"machine_id": mid, "client_version": HUB_VERSION,
|
||||
"device_info": "fnos-resmon/docker"})
|
||||
if r:
|
||||
d = r.get("data") or {}
|
||||
HUB.update(ok=True, install_id=d.get("install_id"),
|
||||
latest=d.get("latest_version") or "",
|
||||
update_available=bool(d.get("update_available")),
|
||||
update_required=bool(d.get("update_required")),
|
||||
download_url=d.get("download_url") or "",
|
||||
changelog=d.get("changelog") or "")
|
||||
last_cu = now
|
||||
if now - last_hb >= 30 * 60:
|
||||
r = _hub_post("/public/installations/heartbeat", {"machine_id": mid})
|
||||
if r:
|
||||
HUB["ok"] = True
|
||||
iid = (r.get("data") or {}).get("install_id")
|
||||
if iid:
|
||||
HUB["install_id"] = iid
|
||||
last_hb = now
|
||||
a = _hub_get_ann()
|
||||
if a is not None:
|
||||
HUB["announcements"] = a["all"]
|
||||
HUB["popup"] = a["popup"]
|
||||
HUB["ok"] = True
|
||||
HUB["ts"] = now
|
||||
except Exception:
|
||||
pass
|
||||
time.sleep(60)
|
||||
|
||||
threading.Thread(target=_hub_loop, daemon=True).start()
|
||||
|
||||
# ---------- host netns helpers (桥接模式用) ----------
|
||||
# 容器切桥接后,直读 /proc/net 只能看到容器自身 netns。
|
||||
# 网络类数据统一经 nsenter 进入宿主(PID 1) netns 读取,保证与 host 模式一致。
|
||||
@@ -355,6 +463,105 @@ def get_percpu():
|
||||
except Exception:
|
||||
return []
|
||||
|
||||
# ---------- CPU 性能模式: 省电/平衡/高性能(写宿主 cpufreq,失败开放) ----------
|
||||
PERF_FILE = os.environ.get("PERF_FILE", "/run/secrets/perf_mode.json")
|
||||
PERF_FILE_FALLBACKS = [PERF_FILE, "/app/perf_mode.json"]
|
||||
PERF_MODES = {
|
||||
"powersave": {"governor": "powersave", "epp": "power",
|
||||
"name": "省电模式"},
|
||||
"balanced": {"governor": "powersave", "epp": "balance_performance",
|
||||
"name": "平衡模式"},
|
||||
"performance": {"governor": "performance", "epp": "performance",
|
||||
"name": "高性能模式"},
|
||||
}
|
||||
|
||||
def _saved_perf_mode():
|
||||
for p in PERF_FILE_FALLBACKS:
|
||||
try:
|
||||
with open(p) as f:
|
||||
m = (json.load(f) or {}).get("mode", "")
|
||||
if m in PERF_MODES:
|
||||
return m
|
||||
except Exception:
|
||||
continue
|
||||
return ""
|
||||
|
||||
def _read_perf():
|
||||
gov, epp = "", ""
|
||||
try:
|
||||
with open("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor") as f:
|
||||
gov = f.read().strip()
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
with open("/sys/devices/system/cpu/cpufreq/policy0/energy_performance_preference") as f:
|
||||
epp = f.read().strip().split()[0]
|
||||
except Exception:
|
||||
pass
|
||||
mode = ""
|
||||
for k, v in PERF_MODES.items():
|
||||
if v["governor"] == gov and (not epp or v["epp"] == epp):
|
||||
mode = k
|
||||
break
|
||||
return {"governor": gov, "epp": epp, "mode": mode,
|
||||
"saved": _saved_perf_mode()}
|
||||
|
||||
def _apply_perf(mode):
|
||||
if mode not in PERF_MODES:
|
||||
return {"ok": False, "error": "未知模式"}
|
||||
want = PERF_MODES[mode]
|
||||
ok_g = fail_g = ok_e = fail_e = 0
|
||||
for p in sorted(glob.glob("/sys/devices/system/cpu/cpu[0-9]*/cpufreq/scaling_governor")):
|
||||
try:
|
||||
with open(p, "w") as f:
|
||||
f.write(want["governor"])
|
||||
ok_g += 1
|
||||
except Exception:
|
||||
fail_g += 1
|
||||
for p in sorted(glob.glob("/sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference")):
|
||||
try:
|
||||
with open(p, "w") as f:
|
||||
f.write(want["epp"])
|
||||
ok_e += 1
|
||||
except Exception:
|
||||
fail_e += 1
|
||||
if ok_g == 0 and fail_g > 0:
|
||||
return {"ok": False, "error": "调频接口不可写( governor 写入失败 )"}
|
||||
try:
|
||||
with open(PERF_FILE, "w") as f:
|
||||
json.dump({"mode": mode}, f)
|
||||
except Exception:
|
||||
try:
|
||||
with open("/app/perf_mode.json", "w") as f:
|
||||
json.dump({"mode": mode}, f)
|
||||
except Exception:
|
||||
pass
|
||||
st = _read_perf()
|
||||
st.update({"ok": True, "mode": mode, "gov_ok": ok_g, "gov_fail": fail_g,
|
||||
"epp_ok": ok_e, "epp_fail": fail_e,
|
||||
"msg": "已切换为%s,立即生效,不重启电脑" % want["name"]})
|
||||
return st
|
||||
|
||||
@app.route("/api/cpu/perf")
|
||||
def api_cpu_perf():
|
||||
return jsonify(_read_perf())
|
||||
|
||||
@app.route("/api/cpu/perf", methods=["POST"])
|
||||
def api_cpu_perf_set():
|
||||
try:
|
||||
mode = (request.get_json(force=True, silent=True) or {}).get("mode", "")
|
||||
except Exception:
|
||||
mode = ""
|
||||
r = _apply_perf(mode)
|
||||
return jsonify(r), (200 if r.get("ok") else 400)
|
||||
|
||||
try:
|
||||
_sv = _saved_perf_mode()
|
||||
if _sv:
|
||||
_apply_perf(_sv)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@app.route("/api/mem")
|
||||
def api_mem():
|
||||
vm = psutil.virtual_memory()
|
||||
@@ -1152,5 +1359,20 @@ def api_kill():
|
||||
def health():
|
||||
return jsonify({"ok": True})
|
||||
|
||||
@app.route("/api/license-config")
|
||||
def license_config():
|
||||
return jsonify({
|
||||
"version": HUB_VERSION,
|
||||
"latest": HUB.get("latest") or "",
|
||||
"update_available": bool(HUB.get("update_available")),
|
||||
"update_required": bool(HUB.get("update_required")),
|
||||
"download_url": HUB.get("download_url") or "",
|
||||
"changelog": HUB.get("changelog") or "",
|
||||
"announcement": (HUB.get("announcements") or [None])[0],
|
||||
"announcements": HUB.get("announcements") or [],
|
||||
"popup": HUB.get("popup") or [],
|
||||
"hub_ok": bool(HUB.get("ok")),
|
||||
})
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run(host="0.0.0.0", port=PORT, threaded=True)
|
||||
@@ -8,7 +8,14 @@ services:
|
||||
environment:
|
||||
- PORT=7031
|
||||
- PROCFS_PATH=/host/proc
|
||||
- SITE_VERSION=1.3.13
|
||||
- HUB_URL=https://auth.88531.cn/api
|
||||
- HUB_PROJECT_ID=12
|
||||
- HUB_KEY_FILE=/run/secrets/hub_key
|
||||
- PERF_FILE=/run/secrets/perf_mode.json
|
||||
privileged: true
|
||||
volumes:
|
||||
- /proc:/host/proc:rw
|
||||
- /sys:/host/sys:ro
|
||||
- /root/.fnos_resmon_hub_key:/run/secrets/hub_key:ro
|
||||
- /root/.fnos_resmon_perf.json:/run/secrets/perf_mode.json:rw
|
||||
+24
-3
@@ -47,6 +47,8 @@ button.refresh{background:#20a53a;color:#fff;border:none;border-radius:3px;paddi
|
||||
.corecell .cb{height:8px;background:#f0f0f0;border-radius:4px;overflow:hidden}
|
||||
.corecell .cb>i{display:block;height:100%;background:#20a53a;border-radius:4px}
|
||||
.corecell .ct{font-size:11px;color:#999;margin-top:2px;font-variant-numeric:tabular-nums}
|
||||
.perfbtn{border:1px solid #ddd;background:#fff;border-radius:6px;padding:8px 18px;font-size:14px;cursor:pointer;margin-right:8px}
|
||||
.perfbtn.cur{background:#20a53a;border-color:#20a53a;color:#fff;font-weight:700}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -56,7 +58,8 @@ button.refresh{background:#20a53a;color:#fff;border:none;border-radius:3px;paddi
|
||||
<div class="tab" data-t="disk">磁盘</div>
|
||||
<div class="tab" data-t="net">网络</div>
|
||||
<div style="margin-left:auto;display:flex;align-items:center;gap:12px;padding-right:16px;font-size:12px">
|
||||
<span style="color:#999">v1.3.11</span>
|
||||
<span id="licBell" onclick="toggleAnn()" title="公告" style="cursor:pointer;position:relative;font-size:15px">🔔<i id="licDot" style="display:none;position:absolute;top:-2px;right:-4px;width:8px;height:8px;border-radius:50%;background:#f00"></i></span>
|
||||
<span id="licVer" onclick="checkVer(true)" title="点击检查新版本" style="color:#999;cursor:pointer">v1.3.13</span>
|
||||
<label style="color:#999">刷新 <select id="ival" onchange="setIval(this.value)" style="border:1px solid #ddd;border-radius:3px;padding:2px 4px;color:#333"><option value="3">3s</option><option value="5">5s</option><option value="10">10s</option><option value="30">30s</option><option value="60">60s</option></select></label>
|
||||
<button id="pauseBtn" onclick="togglePause()" style="background:#ff9900;color:#fff;border:none;border-radius:3px;padding:3px 10px;cursor:pointer">⏸ 停止刷新</button>
|
||||
<a href="https://nav.88531.cn" target="_blank" style="color:#20a53a;text-decoration:none">资享导航站</a>
|
||||
@@ -65,6 +68,7 @@ button.refresh{background:#20a53a;color:#fff;border:none;border-radius:3px;paddi
|
||||
</div>
|
||||
<div class="card" id="summary"></div>
|
||||
<div class="cpuinfo" id="cpuinfo" style="display:none"></div>
|
||||
<div class="cpuinfo" id="cpuperf" style="display:none"></div>
|
||||
<div class="cpuinfo" id="cpusensor" style="display:none"></div>
|
||||
<div class="cpuinfo" id="cpuadvise" style="display:none"></div>
|
||||
<div class="cpuinfo" id="meminfo" style="display:none"></div>
|
||||
@@ -76,14 +80,17 @@ button.refresh{background:#20a53a;color:#fff;border:none;border-radius:3px;paddi
|
||||
<tbody id="tbody"></tbody>
|
||||
</table>
|
||||
<div id="disks"></div><div id="netextra"></div></div>
|
||||
<div id="annPanel" style="display:none;position:fixed;top:46px;right:12px;width:340px;max-height:60vh;overflow:auto;background:#fff;border:1px solid #ddd;border-radius:8px;box-shadow:0 6px 24px rgba(0,0,0,.15);z-index:1000;padding:12px 14px;font-size:13px;line-height:1.8"></div>
|
||||
<div id="annPop" style="display:none;position:fixed;right:12px;bottom:40px;width:340px;background:#fffbe6;border:1px solid #f0c36d;border-radius:8px;box-shadow:0 6px 24px rgba(0,0,0,.15);z-index:1000;padding:12px 14px;font-size:13px;line-height:1.8"></div>
|
||||
<script>
|
||||
let LIC={announcements:[],popup:[]};
|
||||
let cur='cpu';
|
||||
let sortState={key:null,dir:-1};
|
||||
function loadSort(){try{const v=JSON.parse(localStorage.getItem('fnos_sort_'+cur)||'null');if(v&&v.key){sortState=v;return}}catch(e){}sortState={key:null,dir:-1};}
|
||||
function saveSort(){try{localStorage.setItem('fnos_sort_'+cur,JSON.stringify(sortState))}catch(e){}}
|
||||
loadSort();
|
||||
let curData=null;
|
||||
document.querySelectorAll('.tab').forEach(t=>t.onclick=()=>{document.querySelectorAll('.tab').forEach(x=>x.classList.remove('active'));t.classList.add('active');cur=t.dataset.t;loadSort();document.getElementById('disks').innerHTML='';const ci=document.getElementById('cpuinfo');if(ci)ci.style.display='none';const cs=document.getElementById('cpusensor');if(cs)cs.style.display='none';const ca=document.getElementById('cpuadvise');if(ca)ca.style.display='none';const mi2=document.getElementById('meminfo');if(mi2)mi2.style.display='none';const di=document.getElementById('diskinfo');if(di)di.style.display='none';const ni=document.getElementById('netinfo');if(ni)ni.style.display='none';load(true)});
|
||||
document.querySelectorAll('.tab').forEach(t=>t.onclick=()=>{document.querySelectorAll('.tab').forEach(x=>x.classList.remove('active'));t.classList.add('active');cur=t.dataset.t;loadSort();document.getElementById('disks').innerHTML='';const ci=document.getElementById('cpuinfo');if(ci)ci.style.display='none';const cs=document.getElementById('cpusensor');if(cs)cs.style.display='none';const ca=document.getElementById('cpuadvise');if(ca)ca.style.display='none';const cp=document.getElementById('cpuperf');if(cp)cp.style.display='none';const mi2=document.getElementById('meminfo');if(mi2)mi2.style.display='none';const di=document.getElementById('diskinfo');if(di)di.style.display='none';const ni=document.getElementById('netinfo');if(ni)ni.style.display='none';load(true)});
|
||||
function fmtB(b){if(b==null)return '-';const u=['B','KB','MB','GB','TB'];let i=0;while(b>=1024&&i<4){b/=1024;i++}return b.toFixed(b>=100?0:1)+u[i]}
|
||||
function fmtR(b){return fmtB(b)+'/s'}
|
||||
function esc(s){return String(s==null?'':s).replace(/&/g,'&').replace(/</g,'<')}
|
||||
@@ -98,6 +105,10 @@ let lastAdvise=0;
|
||||
async function cpuSensor(){const el=document.getElementById('cpusensor');try{const r=await fetch('/api/sensors');const j=await r.json();el.style.display='';let h='<div class="model">🌡️ 温度 / 🌀 风扇</div>';if(j.temps&&j.temps.length){const cpu=j.temps.filter(t=>t.name.indexOf('CPU')===0);const oth=j.temps.filter(t=>t.name.indexOf('CPU')!==0);const chip=t=>{const c=t.value>=85?'#f00':(t.value>=70?'#ff9900':'#20a53a');return `<span style="display:inline-block;margin:2px 10px 2px 0">${esc(t.name)} <b style="color:${c}">${t.value}°C</b></span>`};if(cpu.length)h+='<div>'+cpu.map(chip).join('')+'</div>';if(oth.length)h+='<div class="mut">'+oth.map(chip).join('')+'</div>'}if(j.fans&&j.fans.length){h+='<div>'+j.fans.map(f=>`<span style="display:inline-block;margin:2px 10px 2px 0">🌀 ${esc(f.name)} <b>${f.value} RPM</b></span>`).join('')+'</div>'}else{h+='<div class="mut">🌀 风扇转速:宿主未暴露(家用 NAS/主板多无此传感器,属正常)</div>'}if(j.note&&!j.temps.length)h+=`<div class="mut">${esc(j.note)}</div>`;el.innerHTML=h}catch(e){el.style.display='';el.innerHTML='<div class="mut">🌡️ 温度读取失败</div>'}}
|
||||
async function cpuAdvise(){const el=document.getElementById('cpuadvise');const now=Date.now();if(now-lastAdvise<15000){if(el.innerHTML)el.style.display='';return;}lastAdvise=now;try{const r=await fetch('/api/cpu/advise');const j=await r.json();const col=j.level==='轻松'||j.level==='正常'?'#20a53a':(j.level==='偏高'?'#ff9900':'#f00');document.getElementById('cpuadvise').style.display='';document.getElementById('cpuadvise').innerHTML=`<div class="model">📊 负载诊断:<b style="color:${col}">${j.level}</b> <span class="mut">(1分钟负载 ${j.load[0]} ÷ ${j.logical}核 = 单核 ${j.per_core})</span></div><div style="margin:4px 0">${esc(j.verdict)}</div><div class="mut">如何更流畅:</div><div>${j.tips.map(t=>`<div>· ${esc(t)}</div>`).join('')}</div><div style="margin-top:6px"><button class="bigbtn" id="optBtn" onclick="optimizeSys()">🚀 一键优化系统</button> <button id="optStopBtn" onclick="stopOpt()" style="display:none;background:#f00;color:#fff;border:none;border-radius:3px;padding:6px 14px;cursor:pointer">⏹ 停止</button><div class="mut" id="optDesc" style="margin-top:4px">会做两件事:① 把内存里暂存的数据写回硬盘(sync,防断电丢数据);② 回收系统缓存占用的内存(drop caches,只清缓存、不动正在运行的程序)。全程不重启、不杀进程,页面照常刷新。</div><div class="mut" id="optStatus"></div></div>`;restoreOptUI()}catch(e){}}
|
||||
async function kill(pid,name){if(!confirm('结束进程 '+name+' (PID '+pid+') ?'))return;const r=await fetch('/api/kill',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({pid})});const j=await r.json();alert(j.ok?'已发送结束信号':('失败: '+j.error));load(true)}
|
||||
const PERF_DESC={powersave:'省电模式:限制睿频、能效优先,适合7×24待机/下载机,功耗噪音最低',balanced:'平衡模式:按负载自动升降频,日常使用推荐,性能功耗兼顾',performance:'高性能模式:火力全开,适合转码/编译/虚拟机等重负载,功耗温度最高'};
|
||||
let perfCur='';
|
||||
async function cpuPerf(){const el=document.getElementById('cpuperf');try{const r=await fetch('/api/cpu/perf');const j=await r.json();const m=j.mode||j.saved||'balanced';const key=m+'|'+(j.governor||'')+'|'+(j.epp||'');if(perfCur===key&&el.innerHTML)return;perfCur=key;el.style.display='';el.innerHTML=`<div class="model">⚡ 系统性能:<b>${m==='powersave'?'省电模式':m==='performance'?'高性能模式':'平衡模式'}</b> <span class="mut">(governor=${esc(j.governor||'-')} epp=${esc(j.epp||'-')},不重启电脑)</span></div><div style="margin-top:6px">${['powersave','balanced','performance'].map(k=>`<button class="perfbtn${m===k?' cur':''}" onclick="setPerf('${k}')">${k==='powersave'?'🌱 省电模式':k==='balanced'?'⚖️ 平衡模式':'🔥 高性能模式'}</button>`).join('')}</div><div class="mut" style="margin-top:6px">${PERF_DESC[m]||''}</div><div id="perfMsg" class="mut" style="margin-top:4px"></div>`}catch(e){}}
|
||||
async function setPerf(mode){const msg=document.getElementById('perfMsg');if(msg)msg.textContent='⏳ 正在切换…';try{const r=await fetch('/api/cpu/perf',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({mode})});const j=await r.json();if(!j.ok){if(msg)msg.textContent='❌ 切换失败:'+(j.error||'未知错误');else alert('切换失败: '+(j.error||'未知'));return}cpuPerf()}catch(e){if(msg)msg.textContent='❌ 切换失败:网络错误'}}
|
||||
function cmpVal(p,key){
|
||||
if(key==='name')return String(p.name||'');
|
||||
if(key==='desc')return String(p.desc||'');
|
||||
@@ -157,7 +168,7 @@ const I=j.info||{},P=j.percpu||[];
|
||||
document.getElementById('cpuinfo').style.display='';
|
||||
document.getElementById('cpuinfo').innerHTML=`<div class="model">${esc(I.model||'未知CPU')} <span class="mut">${esc(I.arch||'')}</span></div><div>物理 ${I.physical||'-'} 核 / 逻辑 ${I.logical||'-'} 核 · ${I.sockets?('共 '+I.sockets+' 路 × '+I.cores_per_socket+'核 × '+I.threads_per_core+'线程'):''} · 当前 ${I.freq_cur||'-'} MHz(${I.freq_min||'-'} ~ ${I.freq_max||'-'} MHz)</div><div class="mut">L1d ${esc(I.l1d||'-')} · L1i ${esc(I.l1i||'-')} · L2 ${esc(I.l2||'-')} · L3 ${esc(I.l3||'-')}</div><div class="corebar">${P.map((v,i)=>`<div class="corecell"><div class="cb"><i style="width:${Math.min(v,100)}%"></i></div><div class="ct">#${i} ${v}%</div></div>`).join('')}</div>`;
|
||||
document.getElementById('sub').textContent=`共 ${j.total} 个进程,显示占用最高的前 ${j.items.length} 个(进程CPU为单进程占用,单核满=100%,16核满=1600%,进程之和÷16≈整机占用)`;
|
||||
cpuAdvise();cpuSensor();
|
||||
cpuPerf();cpuAdvise();cpuSensor();
|
||||
renderHeader();
|
||||
renderBody();
|
||||
}else if(cur==='mem'){
|
||||
@@ -209,6 +220,16 @@ function startTimer(){if(timer)clearInterval(timer);if(!paused)timer=setInterval
|
||||
function setIval(v){ivalSec=+v;startTimer()}
|
||||
function togglePause(){paused=!paused;document.getElementById('pauseBtn').textContent=paused?'▶ 恢复刷新':'⏸ 停止刷新';startTimer()}
|
||||
startTimer();
|
||||
async function licPoll(){try{const r=await fetch('/api/license-config',{cache:'no-store'});const j=await r.json();LIC=j;
|
||||
const dot=document.getElementById('licDot');if(dot)dot.style.display=(j.announcements&&j.announcements.length)?'':'none';
|
||||
const v=document.getElementById('licVer');if(v)v.textContent='v'+(j.version||'1.3.13')+(j.update_available?' ●':'');
|
||||
if(j.popup&&j.popup.length){try{const seen=JSON.parse(localStorage.getItem('fnos_ann_seen')||'[]');const fresh=j.popup.filter(a=>seen.indexOf(a.id)<0);if(fresh.length){const a=fresh[0];const el=document.getElementById('annPop');el.innerHTML=`<div style="display:flex;justify-content:space-between;align-items:center"><b>📢 ${esc(a.title||'公告')}</b><span onclick="dismissPop(${a.id})" style="cursor:pointer;color:#999">✕</span></div><div style="margin-top:6px">${a.content||''}</div>`;el.style.display='';}}catch(e){}}
|
||||
if(document.getElementById('annPanel').style.display!=='none')renderAnn();}catch(e){}}
|
||||
function renderAnn(){const el=document.getElementById('annPanel');const list=LIC.announcements||[];el.innerHTML=list.length?(`<b>📢 公告(${list.length})</b>`+list.map(a=>`<div style="margin-top:8px;padding-top:8px;border-top:1px dashed #eee"><div><b>${esc(a.title||'')}</b></div><div style="color:#666">${a.content||''}</div></div>`).join('')):'<span style="color:#999">暂无公告</span>';}
|
||||
function toggleAnn(){const el=document.getElementById('annPanel');if(el.style.display==='none'){renderAnn();el.style.display=''}else el.style.display='none'}
|
||||
function dismissPop(id){try{const seen=JSON.parse(localStorage.getItem('fnos_ann_seen')||'[]');seen.push(id);localStorage.setItem('fnos_ann_seen',JSON.stringify(seen))}catch(e){}document.getElementById('annPop').style.display='none'}
|
||||
async function checkVer(manual){try{const r=await fetch('/api/license-config',{cache:'no-store'});const j=await r.json();LIC=j;if(j.update_available){alert('发现新版本 v'+(j.latest||'')+'\n'+(j.changelog||'')+(j.download_url?('\n下载:'+j.download_url):''))}else if(manual){alert('当前已是最新版本 v'+(j.version||''))}}catch(e){if(manual)alert('版本检查失败,稍后重试')}}
|
||||
licPoll();setInterval(licPoll,10*60*1000);
|
||||
</script>
|
||||
<footer style="position:fixed;bottom:0;left:0;right:0;text-align:center;padding:6px;font-size:12px;color:#999;background:#fff;border-top:1px solid #eee;z-index:999">
|
||||
<a href="https://nav.88531.cn" target="_blank" rel="noopener">资享导航站</a> ·
|
||||
|
||||
Reference in new issue
Block a user