Spaces:
Running
Running
CassiopeiaCode
commited on
Commit
·
68b69f4
1
Parent(s):
0948a00
fix: 修复删除配置面板后的JavaScript错误
Browse files- 移除baseUrl、authHeader、setHealth和ping函数
- 简化api函数,直接使用相对路径
- 移除DOMContentLoaded中的ping调用
- frontend/index.html +2 -28
frontend/index.html
CHANGED
|
@@ -307,34 +307,9 @@ function switchTab(name) {
|
|
| 307 |
document.getElementById('tab-' + name).classList.add('active');
|
| 308 |
}
|
| 309 |
|
| 310 |
-
function baseUrl(){ return document.getElementById('base').value.trim(); }
|
| 311 |
-
function authHeader(){
|
| 312 |
-
const v = document.getElementById('auth').value.trim();
|
| 313 |
-
return v ? ('Bearer ' + v) : '';
|
| 314 |
-
}
|
| 315 |
-
function setHealth(text, ok=true) {
|
| 316 |
-
const el = document.getElementById('health');
|
| 317 |
-
el.textContent = text;
|
| 318 |
-
el.style.color = ok ? 'var(--ok)' : 'var(--danger)';
|
| 319 |
-
}
|
| 320 |
-
|
| 321 |
function api(path){
|
| 322 |
-
const
|
| 323 |
-
|
| 324 |
-
const p = typeof path === 'string' ? path : '';
|
| 325 |
-
const pathClean = ('/' + p.replace(/^\/+/, '')).replace(/\/{2,}/g, '/');
|
| 326 |
-
return (baseClean ? baseClean : '') + pathClean;
|
| 327 |
-
}
|
| 328 |
-
|
| 329 |
-
async function ping(){
|
| 330 |
-
try{
|
| 331 |
-
const r = await fetch(api('/healthz'));
|
| 332 |
-
const j = await r.json();
|
| 333 |
-
if (j && j.status === 'ok') setHealth('Healthy', true);
|
| 334 |
-
else setHealth('Unhealthy', false);
|
| 335 |
-
} catch(e){
|
| 336 |
-
setHealth('Error', false);
|
| 337 |
-
}
|
| 338 |
}
|
| 339 |
|
| 340 |
function renderAccounts(list){
|
|
@@ -619,7 +594,6 @@ async function send() {
|
|
| 619 |
|
| 620 |
window.addEventListener('DOMContentLoaded', () => {
|
| 621 |
loadAccounts();
|
| 622 |
-
ping();
|
| 623 |
});
|
| 624 |
</script>
|
| 625 |
</body>
|
|
|
|
| 307 |
document.getElementById('tab-' + name).classList.add('active');
|
| 308 |
}
|
| 309 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
function api(path){
|
| 311 |
+
const pathClean = ('/' + (path || '').replace(/^\/+/, '')).replace(/\/{2,}/g, '/');
|
| 312 |
+
return pathClean;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
}
|
| 314 |
|
| 315 |
function renderAccounts(list){
|
|
|
|
| 594 |
|
| 595 |
window.addEventListener('DOMContentLoaded', () => {
|
| 596 |
loadAccounts();
|
|
|
|
| 597 |
});
|
| 598 |
</script>
|
| 599 |
</body>
|