优化
This commit is contained in:
@@ -34,6 +34,14 @@
|
||||
if (settings.page_name) {
|
||||
document.title = settings.page_name;
|
||||
}
|
||||
|
||||
// Handle page name visibility
|
||||
if (settings.show_page_name === 0) {
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const lt = document.getElementById('logoText');
|
||||
if (lt) lt.style.display = 'none';
|
||||
});
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</head>
|
||||
@@ -448,6 +456,14 @@
|
||||
<label for="siteTitleInput">标题 (大屏左上角显示名称)</label>
|
||||
<input type="text" id="siteTitleInput" placeholder="例:数据可视化展示大屏">
|
||||
</div>
|
||||
<div class="form-group" style="margin-top: 15px;">
|
||||
<label for="showPageNameInput">是否显示左上角标题</label>
|
||||
<select id="showPageNameInput"
|
||||
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">显示 (Show)</option>
|
||||
<option value="0">隐藏 (Hide)</option>
|
||||
</select>
|
||||
</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">
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
serverSourceOption: document.getElementById('serverSourceOption'),
|
||||
faviconUrlInput: document.getElementById('faviconUrlInput'),
|
||||
logoUrlDarkInput: document.getElementById('logoUrlDarkInput'),
|
||||
showPageNameInput: document.getElementById('showPageNameInput'),
|
||||
// Site Settings
|
||||
modalTabs: document.querySelectorAll('.modal-tab'),
|
||||
tabContents: document.querySelectorAll('.tab-content'),
|
||||
@@ -1679,6 +1680,7 @@
|
||||
if (dom.psFilingInput) dom.psFilingInput.value = settings.ps_filing || '';
|
||||
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";
|
||||
|
||||
// Apply to UI
|
||||
applySiteSettings(settings);
|
||||
@@ -1712,8 +1714,10 @@
|
||||
if (settings.page_name) {
|
||||
document.title = settings.page_name;
|
||||
}
|
||||
if (settings.title) {
|
||||
dom.logoText.textContent = settings.title;
|
||||
if (dom.logoText) {
|
||||
if (settings.title) dom.logoText.textContent = settings.title;
|
||||
// Handle visibility toggle
|
||||
dom.logoText.style.display = (settings.show_page_name === 0) ? 'none' : 'block';
|
||||
}
|
||||
|
||||
// Logo Icon
|
||||
@@ -1817,6 +1821,7 @@
|
||||
logo_url: dom.logoUrlInput ? dom.logoUrlInput.value.trim() : '',
|
||||
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,
|
||||
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',
|
||||
|
||||
@@ -80,6 +80,7 @@ async function checkAndFixDatabase() {
|
||||
}
|
||||
};
|
||||
|
||||
await addColumn('show_page_name', "ALTER TABLE site_settings ADD COLUMN show_page_name TINYINT(1) DEFAULT 1 AFTER page_name");
|
||||
await addColumn('show_95_bandwidth', "ALTER TABLE site_settings ADD COLUMN show_95_bandwidth TINYINT(1) DEFAULT 0 AFTER default_theme");
|
||||
await addColumn('p95_type', "ALTER TABLE site_settings ADD COLUMN p95_type VARCHAR(20) DEFAULT 'tx' AFTER show_95_bandwidth");
|
||||
await addColumn('blackbox_source_id', "ALTER TABLE site_settings ADD COLUMN blackbox_source_id INT AFTER p95_type");
|
||||
@@ -126,6 +127,7 @@ async function createTable(tableName) {
|
||||
CREATE TABLE IF NOT EXISTS site_settings (
|
||||
id INT PRIMARY KEY DEFAULT 1,
|
||||
page_name VARCHAR(255) DEFAULT '数据可视化展示大屏',
|
||||
show_page_name TINYINT(1) DEFAULT 1,
|
||||
title VARCHAR(255) DEFAULT '数据可视化展示大屏',
|
||||
logo_url TEXT,
|
||||
logo_url_dark TEXT,
|
||||
|
||||
@@ -410,6 +410,7 @@ const serveIndex = async (req, res) => {
|
||||
// Fetch settings
|
||||
let settings = {
|
||||
page_name: '数据可视化展示大屏',
|
||||
show_page_name: 1,
|
||||
title: '数据可视化展示大屏',
|
||||
logo_url: null,
|
||||
logo_url_dark: null,
|
||||
@@ -565,6 +566,7 @@ app.get('/api/settings', async (req, res) => {
|
||||
if (rows.length === 0) {
|
||||
return res.json({
|
||||
page_name: '数据可视化展示大屏',
|
||||
show_page_name: 1,
|
||||
title: '数据可视化展示大屏',
|
||||
logo_url: null,
|
||||
logo_url_dark: null,
|
||||
@@ -595,7 +597,7 @@ app.post('/api/settings', requireAuth, async (req, res) => {
|
||||
|
||||
// 2. Destructure fields from body
|
||||
const {
|
||||
page_name, title, logo_url, logo_url_dark, favicon_url,
|
||||
page_name, show_page_name, title, logo_url, logo_url_dark, favicon_url,
|
||||
default_theme, show_95_bandwidth, p95_type,
|
||||
icp_filing, ps_filing
|
||||
} = req.body;
|
||||
@@ -603,6 +605,7 @@ app.post('/api/settings', requireAuth, async (req, res) => {
|
||||
// 3. Prepare parameters, prioritizing body but falling back to current
|
||||
const settings = {
|
||||
page_name: page_name !== undefined ? page_name : (current.page_name || '数据可视化展示大屏'),
|
||||
show_page_name: show_page_name !== undefined ? (show_page_name ? 1 : 0) : (current.show_page_name !== undefined ? current.show_page_name : 1),
|
||||
title: title !== undefined ? title : (current.title || '数据可视化展示大屏'),
|
||||
logo_url: logo_url !== undefined ? logo_url : (current.logo_url || null),
|
||||
logo_url_dark: logo_url_dark !== undefined ? logo_url_dark : (current.logo_url_dark || null),
|
||||
@@ -621,13 +624,14 @@ app.post('/api/settings', requireAuth, async (req, res) => {
|
||||
// 4. Update database
|
||||
await db.query(
|
||||
`INSERT INTO site_settings (
|
||||
id, page_name, title, logo_url, logo_url_dark, favicon_url,
|
||||
id, page_name, show_page_name, title, logo_url, logo_url_dark, favicon_url,
|
||||
default_theme, show_95_bandwidth, p95_type,
|
||||
blackbox_source_id, latency_source, latency_dest, latency_target,
|
||||
icp_filing, ps_filing
|
||||
) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
) VALUES (1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
page_name = VALUES(page_name),
|
||||
show_page_name = VALUES(show_page_name),
|
||||
title = VALUES(title),
|
||||
logo_url = VALUES(logo_url),
|
||||
logo_url_dark = VALUES(logo_url_dark),
|
||||
@@ -642,7 +646,7 @@ app.post('/api/settings', requireAuth, async (req, res) => {
|
||||
icp_filing = VALUES(icp_filing),
|
||||
ps_filing = VALUES(ps_filing)`,
|
||||
[
|
||||
settings.page_name, settings.title, settings.logo_url, settings.logo_url_dark, settings.favicon_url,
|
||||
settings.page_name, settings.show_page_name, settings.title, settings.logo_url, settings.logo_url_dark, settings.favicon_url,
|
||||
settings.default_theme, settings.show_95_bandwidth, settings.p95_type,
|
||||
settings.blackbox_source_id, settings.latency_source, settings.latency_dest, settings.latency_target,
|
||||
settings.icp_filing, settings.ps_filing
|
||||
|
||||
Reference in New Issue
Block a user