添加设置项
This commit is contained in:
@@ -507,6 +507,15 @@
|
||||
<option value="0">隐藏 (Hide)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group" style="margin-top: 15px;">
|
||||
<label for="requireLoginForServerDetailsInput">服务器详情是否仅登录后可查看</label>
|
||||
<select id="requireLoginForServerDetailsInput"
|
||||
style="padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: var(--radius-sm); color: var(--text-primary); width: 100%;">
|
||||
<option value="1">仅登录后可查看</option>
|
||||
<option value="0">允许公开查看</option>
|
||||
</select>
|
||||
<p style="font-size: 0.72rem; color: var(--text-muted); margin-top: 6px;">开启后,未登录访客仍可看到大屏总览,但点击单台服务器时需要先登录。</p>
|
||||
</div>
|
||||
<div class="form-group" style="margin-top: 15px;">
|
||||
<label for="logoUrlInput">Logo URL (白天/默认,支持图片链接)</label>
|
||||
<input type="url" id="logoUrlInput" placeholder="https://example.com/logo_light.png">
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
faviconUrlInput: document.getElementById('faviconUrlInput'),
|
||||
logoUrlDarkInput: document.getElementById('logoUrlDarkInput'),
|
||||
showPageNameInput: document.getElementById('showPageNameInput'),
|
||||
requireLoginForServerDetailsInput: document.getElementById('requireLoginForServerDetailsInput'),
|
||||
// Site Settings
|
||||
modalTabs: document.querySelectorAll('.modal-tab'),
|
||||
tabContents: document.querySelectorAll('.tab-content'),
|
||||
@@ -417,6 +418,10 @@
|
||||
const job = row.getAttribute('data-job');
|
||||
const source = row.getAttribute('data-source');
|
||||
if (instance && job && source) {
|
||||
if (requiresLoginForServerDetails() && !user) {
|
||||
promptLogin('登录后可查看服务器详细指标');
|
||||
return;
|
||||
}
|
||||
openServerDetail(instance, job, source);
|
||||
}
|
||||
}
|
||||
@@ -528,6 +533,7 @@
|
||||
if (dom.defaultThemeInput) dom.defaultThemeInput.value = window.SITE_SETTINGS.default_theme || 'dark';
|
||||
if (dom.show95BandwidthInput) dom.show95BandwidthInput.value = window.SITE_SETTINGS.show_95_bandwidth ? "1" : "0";
|
||||
if (dom.p95TypeSelect) dom.p95TypeSelect.value = window.SITE_SETTINGS.p95_type || 'tx';
|
||||
if (dom.requireLoginForServerDetailsInput) dom.requireLoginForServerDetailsInput.value = window.SITE_SETTINGS.require_login_for_server_details ? "1" : "0";
|
||||
if (dom.icpFilingInput) dom.icpFilingInput.value = window.SITE_SETTINGS.icp_filing || '';
|
||||
if (dom.psFilingInput) dom.psFilingInput.value = window.SITE_SETTINGS.ps_filing || '';
|
||||
if (dom.logoUrlDarkInput) dom.logoUrlDarkInput.value = window.SITE_SETTINGS.logo_url_dark || '';
|
||||
@@ -692,6 +698,11 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
function requiresLoginForServerDetails() {
|
||||
if (!window.SITE_SETTINGS) return true;
|
||||
return !!window.SITE_SETTINGS.require_login_for_server_details;
|
||||
}
|
||||
|
||||
function renderLogoImage(url) {
|
||||
if (!dom.logoIconContainer) return;
|
||||
const safeUrl = sanitizeAssetUrl(url);
|
||||
@@ -1895,6 +1906,7 @@
|
||||
if (dom.logoUrlDarkInput) dom.logoUrlDarkInput.value = settings.logo_url_dark || '';
|
||||
if (dom.faviconUrlInput) dom.faviconUrlInput.value = settings.favicon_url || '';
|
||||
if (dom.showPageNameInput) dom.showPageNameInput.value = settings.show_page_name !== undefined ? settings.show_page_name.toString() : "1";
|
||||
if (dom.requireLoginForServerDetailsInput) dom.requireLoginForServerDetailsInput.value = settings.require_login_for_server_details ? "1" : "0";
|
||||
|
||||
// Handle Theme Priority: localStorage > Site Default
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
@@ -2016,6 +2028,7 @@
|
||||
logo_url_dark: dom.logoUrlDarkInput ? dom.logoUrlDarkInput.value.trim() : '',
|
||||
favicon_url: dom.faviconUrlInput ? dom.faviconUrlInput.value.trim() : '',
|
||||
show_page_name: dom.showPageNameInput ? parseInt(dom.showPageNameInput.value) : 1,
|
||||
require_login_for_server_details: dom.requireLoginForServerDetailsInput ? (dom.requireLoginForServerDetailsInput.value === "1") : true,
|
||||
default_theme: dom.defaultThemeInput ? dom.defaultThemeInput.value : 'dark',
|
||||
show_95_bandwidth: dom.show95BandwidthInput ? (dom.show95BandwidthInput.value === "1") : false,
|
||||
p95_type: dom.p95TypeSelect ? dom.p95TypeSelect.value : 'tx',
|
||||
|
||||
Reference in New Issue
Block a user