优化安装脚本

This commit is contained in:
CN-JS-HuiBai
2026-04-05 15:23:08 +08:00
parent d7f8db89a3
commit 035ebd8d40
6 changed files with 181 additions and 23 deletions

View File

@@ -395,9 +395,12 @@
style="padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary);">
<option value="dark">默认夜间模式</option>
<option value="light">默认白天模式</option>
<option value="auto">跟随浏览器/系统</option>
</select>
</div>
<div class="form-group" style="margin-top: 15px; display: flex; align-items: center; gap: 10px;">
<input type="checkbox" id="show95BandwidthInput" style="width: 18px; height: 18px; cursor: pointer;">
<label for="show95BandwidthInput" style="cursor: pointer; user-select: none;">24h趋势图默认显示 95计费线</label>
</div>
<div class="form-actions" style="margin-top: 25px; display: flex; justify-content: flex-end;">
<button class="btn btn-add" id="btnSaveSiteSettings">保存设置</button>
</div>

View File

@@ -48,6 +48,7 @@
logoText: document.getElementById('logoText'),
logoIconContainer: document.getElementById('logoIconContainer'),
defaultThemeInput: document.getElementById('defaultThemeInput'),
show95BandwidthInput: document.getElementById('show95BandwidthInput'),
// Auth & Theme elements
themeToggle: document.getElementById('themeToggle'),
sunIcon: document.querySelector('.sun-icon'),
@@ -218,6 +219,7 @@
dom.siteTitleInput.value = window.SITE_SETTINGS.title || '';
dom.logoUrlInput.value = window.SITE_SETTINGS.logo_url || '';
dom.defaultThemeInput.value = window.SITE_SETTINGS.default_theme || 'dark';
dom.show95BandwidthInput.checked = !!window.SITE_SETTINGS.show_95_bandwidth;
}
loadSiteSettings();
@@ -903,9 +905,19 @@
// Update inputs
dom.pageNameInput.value = settings.page_name || '';
dom.siteTitleInput.value = settings.title || '';
dom.logoUrlInput.value = settings.logo_url || '';
dom.defaultThemeInput.value = settings.default_theme || 'dark';
if (settings.title) dom.siteTitleInput.value = settings.title;
if (settings.logo_url) dom.logoUrlInput.value = settings.logo_url;
if (settings.default_theme) dom.defaultThemeInput.value = settings.default_theme;
if (settings.show_95_bandwidth !== undefined) {
dom.show95BandwidthInput.checked = !!settings.show_95_bandwidth;
if (networkChart) {
networkChart.showP95 = !!settings.show_95_bandwidth;
if (dom.legendP95) {
dom.legendP95.classList.toggle('disabled', !networkChart.showP95);
}
networkChart.draw();
}
}
// Apply to UI
applySiteSettings(settings);
@@ -957,6 +969,17 @@
</svg>
`;
}
// P95 setting
if (settings.show_95_bandwidth !== undefined) {
if (networkChart) {
networkChart.showP95 = !!settings.show_95_bandwidth;
if (dom.legendP95) {
dom.legendP95.classList.toggle('disabled', !networkChart.showP95);
}
networkChart.draw();
}
}
}
async function saveSiteSettings() {
@@ -970,7 +993,8 @@
page_name: dom.pageNameInput.value.trim(),
title: dom.siteTitleInput.value.trim(),
logo_url: dom.logoUrlInput.value.trim(),
default_theme: dom.defaultThemeInput.value
default_theme: dom.defaultThemeInput.value,
show_95_bandwidth: dom.show95BandwidthInput.checked ? 1 : 0
};
dom.btnSaveSiteSettings.disabled = true;