()
| 2701 | // 配置管理 |
| 2702 | // ===================================================================== |
| 2703 | async function loadConfig() { |
| 2704 | const loading = document.getElementById('configLoading'); |
| 2705 | const form = document.getElementById('configForm'); |
| 2706 | |
| 2707 | try { |
| 2708 | loading.style.display = 'block'; |
| 2709 | form.classList.add('hidden'); |
| 2710 | |
| 2711 | const response = await fetch('./config/get', { headers: getAuthHeaders() }); |
| 2712 | const data = await response.json(); |
| 2713 | |
| 2714 | if (response.ok) { |
| 2715 | AppState.currentConfig = data.config; |
| 2716 | AppState.envLockedFields = new Set(data.env_locked || []); |
| 2717 | |
| 2718 | populateConfigForm(); |
| 2719 | form.classList.remove('hidden'); |
| 2720 | showStatus('配置加载成功', 'success'); |
| 2721 | } else { |
| 2722 | showStatus(`加载配置失败: ${data.detail || data.error || '未知错误'}`, 'error'); |
| 2723 | } |
| 2724 | } catch (error) { |
| 2725 | showStatus(`网络错误: ${error.message}`, 'error'); |
| 2726 | } finally { |
| 2727 | loading.style.display = 'none'; |
| 2728 | } |
| 2729 | } |
| 2730 | |
| 2731 | function populateConfigForm() { |
| 2732 | const c = AppState.currentConfig; |
no test coverage detected