修复前端量级无法显示数据,增加清风审核和大神 CMS 的 Cookie 输入修改为可选

This commit is contained in:
ui-beam-9
2025-04-22 08:13:41 +08:00
parent 3e1ece2556
commit d5b93c12e2
9 changed files with 325 additions and 804 deletions

View File

@@ -827,7 +827,8 @@
</div>
<div class="container">
<div class="panel">
<!-- Breeze工单系统 -->
<div class="panel" id="breeze-panel">
<div class="panel-header">
<h2>清风审核</h2>
<div class="last-update" id="breeze-last-update">最后更新: 暂无</div>
@@ -864,7 +865,8 @@
</div>
</div>
<div class="panel">
<!-- CMS工单系统 -->
<div class="panel" id="cms-panel">
<div class="panel-header">
<h2>大神CMS</h2>
<div class="last-update" id="cms-last-update">最后更新: 暂无</div>
@@ -924,7 +926,6 @@
<div class="data-total">
<div class="label">折算总计</div>
<div class="value" id="cms-daily-weighted">-</div>
</div>
</div>
</div>
</div>
@@ -932,63 +933,6 @@
<!-- CMS系数设置对话框 -->
<div id="settings-dialog" class="dialog">
<div class="dialog-content">
<span class="close" onclick="document.getElementById('settings-dialog').style.display='none'">&times;</span>
<h2>CMS系数设置</h2>
<div class="settings-form">
<div class="form-group">
<label for="cms-coefficient-comment">评论系数:</label>
<input type="number" id="cms-coefficient-comment" step="0.01" min="0" max="100" />
</div>
<div class="form-group">
<label for="cms-coefficient-feed">动态系数:</label>
<input type="number" id="cms-coefficient-feed" step="0.01" min="0" max="100" />
</div>
<div class="form-group">
<label for="cms-coefficient-complaint">举报系数:</label>
<input type="number" id="cms-coefficient-complaint" step="0.01" min="0" max="100" />
</div>
<button id="save-settings-button">保存</button>
</div>
</div>
</div>
<!-- Breeze系数设置对话框 -->
<div id="breeze-settings-dialog" class="dialog">
<div class="dialog-content">
<span class="close"
onclick="document.getElementById('breeze-settings-dialog').style.display='none'">&times;</span>
<h2>Breeze系数设置</h2>
<div class="settings-form" id="breeze-settings-form">
<!-- 系数输入字段将在JS中动态生成 -->
<div class="form-group loading">
<p>正在加载系数数据...</p>
</div>
<button id="save-breeze-settings-button">保存</button>
</div>
</div>
</div>
<!-- 版本更新通知弹窗 -->
<div id="versionDialog" class="dialog">
<div class="dialog-content">
<span class="close" onclick="document.getElementById('versionDialog').style.display='none'">&times;</span>
<h2 id="versionDialogTitle">系统版本检测</h2>
<div class="version-info">
<p>当前版本: <span id="currentVersion">-</span></p>
<p>最新版本: <span id="onlineVersion">-</span></p>
<p id="versionStatus"></p>
<p class="check-time">上次检查: <span id="lastCheckTime">-</span></p>
</div>
<div style="display: flex; justify-content: flex-end;">
<button id="updateButton" class="dialog-button update" style="display: none;">立即更新</button>
<button id="close-version-dialog" class="dialog-button">关闭</button>
</div>
</div>
</div>
<!-- 无法识别工单弹窗 -->
<div id="unrecognizedIssuesDialog" class="dialog">
<div class="dialog-content">
<span class="close" onclick="document.getElementById('unrecognizedIssuesDialog').style.display='none'">&times;</span>
<h2>无法识别的工单</h2>
@@ -1140,28 +1084,51 @@
// 更新仪表盘
function updateDashboard(data) {
try {
// 更新统计栏数据
if (data.breeze && data.breeze.hourly) {
// 获取平台可用性信息
const breezeAvailable = data.breeze_available !== undefined ? data.breeze_available : true;
const cmsAvailable = data.cms_available !== undefined ? data.cms_available : true;
const inspectAvailable = data.inspect_available !== undefined ? data.inspect_available : true;
// 控制面板显示
document.getElementById('breeze-panel').style.display = breezeAvailable ? 'block' : 'none';
document.getElementById('cms-panel').style.display = cmsAvailable ? 'block' : 'none';
document.getElementById('inspect-panel').style.display = inspectAvailable ? 'block' : 'none';
// 根据可用平台调整总量级显示标题
let totalPlatforms = [];
if (breezeAvailable) totalPlatforms.push("清风审核");
if (cmsAvailable) totalPlatforms.push("大神CMS");
if (inspectAvailable) totalPlatforms.push("CC审核平台");
const platformsText = totalPlatforms.join(" + ");
const totalCard = document.querySelector('.stats-card.total h3');
totalCard.textContent = `总计(折算量)- ${platformsText || "无可用平台"}`;
// 更新Breeze工单系统面板数据
// 即使breeze数据不存在也使用默认值而不是直接返回
const breezeHourly = data.breeze && data.breeze.hourly ? data.breeze.hourly : { total: 0, weighted_total: 0, categories: {} };
const breezeDaily = data.breeze && data.breeze.daily ? data.breeze.daily : { total: 0, weighted_total: 0, categories: {} };
// 更新顶部统计数据
document.getElementById('breeze-total').textContent = data.breeze.hourly.total || '0';
document.getElementById('breeze-daily-total').textContent = data.breeze.daily ? (data.breeze.daily.total || '0') : '0';
document.getElementById('breeze-total').textContent = breezeHourly.total || '0';
document.getElementById('breeze-daily-total').textContent = breezeDaily.total || '0';
// 更新Breeze工单系统面板
document.getElementById('breeze-hourly-count').textContent = data.breeze.hourly.total || '-';
document.getElementById('breeze-hourly-weighted').textContent = data.breeze.hourly.weighted_total ? data.breeze.hourly.weighted_total.toFixed(2) : '-';
document.getElementById('breeze-daily-count').textContent = data.breeze.daily ? (data.breeze.daily.total || '-') : '-';
document.getElementById('breeze-daily-weighted').textContent = data.breeze.daily ? (data.breeze.daily.weighted_total || '-').toFixed(2) : '-';
document.getElementById('breeze-hourly-count').textContent = breezeHourly.total || '0';
document.getElementById('breeze-hourly-weighted').textContent = breezeHourly.weighted_total ? breezeHourly.weighted_total.toFixed(2) : '0.00';
document.getElementById('breeze-daily-count').textContent = breezeDaily.total || '0';
document.getElementById('breeze-daily-weighted').textContent = breezeDaily.weighted_total ? breezeDaily.weighted_total.toFixed(2) : '0.00';
// 更新小时类别数据
const breezeHourlyCategories = document.getElementById('breeze-hourly-categories');
if (data.breeze.hourly.categories) {
if (breezeHourly.categories && Object.keys(breezeHourly.categories).length > 0) {
let categoriesHTML = `
<div class="category-header">
<div class="name">类别</div>
<div class="count">数量</div>
<div class="weighted">折算值</div>
</div>`;
for (const [name, info] of Object.entries(data.breeze.hourly.categories)) {
for (const [name, info] of Object.entries(breezeHourly.categories)) {
if (info.count > 0) {
categoriesHTML += `
<div class="category-item">
@@ -1181,14 +1148,14 @@
// 更新日类别数据
const breezeDailyCategories = document.getElementById('breeze-daily-categories');
if (data.breeze.daily.categories) {
if (breezeDaily.categories && Object.keys(breezeDaily.categories).length > 0) {
let categoriesHTML = `
<div class="category-header">
<div class="name">类别</div>
<div class="count">数量</div>
<div class="weighted">折算值</div>
</div>`;
for (const [name, info] of Object.entries(data.breeze.daily.categories)) {
for (const [name, info] of Object.entries(breezeDaily.categories)) {
if (info.count > 0) {
categoriesHTML += `
<div class="category-item">
@@ -1207,7 +1174,8 @@
}
// 更新最后更新时间
document.getElementById('breeze-last-update').textContent = '最后更新: ' + data.breeze.hourly_update;
if (data.breeze) {
document.getElementById('breeze-last-update').textContent = '最后更新: ' + (data.breeze.hourly_update || '未知');
// 更新时间戳
if (data.breeze.hourly_update) {
@@ -1219,21 +1187,33 @@
}
// 更新CMS数据
if (data.cms && data.cms.hourly) {
// 即使cms数据不存在也使用默认值而不是直接返回
const cmsHourly = data.cms && data.cms.hourly ? data.cms.hourly : {
stats: { comment: 0, feed: 0, complaint: 0 },
weighted_total: 0,
total_count: 0
};
const cmsDaily = data.cms && data.cms.daily ? data.cms.daily : {
stats: { comment: 0, feed: 0, complaint: 0 },
weighted_total: 0,
total_count: 0
};
// 更新顶部统计栏
const cmsTotal = data.cms.hourly.total_count || 0;
document.getElementById('cms-total').textContent = cmsTotal;
document.getElementById('cms-daily-total').textContent = data.cms.daily ? (data.cms.daily.total_count || '0') : '0';
document.getElementById('cms-total').textContent = cmsHourly.total_count || '0';
document.getElementById('cms-daily-total').textContent = cmsDaily.total_count || '0';
// 更新CMS审核系统面板
document.getElementById('cms-hourly-comment').textContent = data.cms.hourly.stats ? data.cms.hourly.stats.comment : '-';
document.getElementById('cms-hourly-feed').textContent = data.cms.hourly.stats ? data.cms.hourly.stats.feed : '-';
document.getElementById('cms-hourly-complaint').textContent = data.cms.hourly.stats ? data.cms.hourly.stats.complaint : '-';
document.getElementById('cms-hourly-count').textContent = data.cms.hourly.total_count || '-';
document.getElementById('cms-hourly-weighted').textContent = data.cms.hourly.weighted_total ? data.cms.hourly.weighted_total.toFixed(2) : '-';
document.getElementById('cms-last-update').textContent = '最后更新: ' + data.cms.hourly_update;
document.getElementById('cms-hourly-comment').textContent = cmsHourly.stats ? cmsHourly.stats.comment : '0';
document.getElementById('cms-hourly-feed').textContent = cmsHourly.stats ? cmsHourly.stats.feed : '0';
document.getElementById('cms-hourly-complaint').textContent = cmsHourly.stats ? cmsHourly.stats.complaint : '0';
document.getElementById('cms-hourly-count').textContent = cmsHourly.total_count || '0';
document.getElementById('cms-hourly-weighted').textContent = cmsHourly.weighted_total ? cmsHourly.weighted_total.toFixed(2) : '0.00';
// 更新时间戳
if (data.cms) {
document.getElementById('cms-last-update').textContent = '最后更新: ' + (data.cms.hourly_update || '未知');
if (data.cms.hourly_update) {
document.getElementById('cms-hourly-time').textContent = data.cms.hourly_update;
}
@@ -1243,26 +1223,23 @@
}
// 更新CMS每日数据
if (data.cms && data.cms.daily && data.cms.daily.stats) {
document.getElementById('cms-daily-comment').textContent = data.cms.daily.stats.comment || '-';
document.getElementById('cms-daily-feed').textContent = data.cms.daily.stats.feed || '-';
document.getElementById('cms-daily-complaint').textContent = data.cms.daily.stats.complaint || '-';
document.getElementById('cms-daily-count').textContent = data.cms.daily.total_count || '-';
document.getElementById('cms-daily-weighted').textContent = data.cms.daily.weighted_total ? data.cms.daily.weighted_total.toFixed(2) : '-';
}
document.getElementById('cms-daily-comment').textContent = cmsDaily.stats ? cmsDaily.stats.comment : '0';
document.getElementById('cms-daily-feed').textContent = cmsDaily.stats ? cmsDaily.stats.feed : '0';
document.getElementById('cms-daily-complaint').textContent = cmsDaily.stats ? cmsDaily.stats.complaint : '0';
document.getElementById('cms-daily-count').textContent = cmsDaily.total_count || '0';
document.getElementById('cms-daily-weighted').textContent = cmsDaily.weighted_total ? cmsDaily.weighted_total.toFixed(2) : '0.00';
// 更新CC审核平台数据
if (data.inspect && data.inspect.hourly) {
const hourlyTotal = data.inspect.hourly.total || 0;
const hourlyWeighted = data.inspect.hourly.weighted_total || 0;
document.getElementById('inspect-hourly-total').textContent = hourlyTotal;
document.getElementById('inspect-hourly-weighted').textContent = `(${Math.round(hourlyWeighted)})`;
document.getElementById('inspect-daily-total').textContent = data.inspect.daily ? (data.inspect.daily.total || '0') : '0';
if (data.inspect.daily) {
document.getElementById('inspect-daily-weighted').textContent = `(${Math.round(data.inspect.daily.weighted_total)})`;
}
const inspectHourly = data.inspect && data.inspect.hourly ? data.inspect.hourly : { total: 0, weighted_total: 0 };
const inspectDaily = data.inspect && data.inspect.daily ? data.inspect.daily : { total: 0, weighted_total: 0 };
document.getElementById('inspect-hourly-total').textContent = inspectHourly.total || '0';
document.getElementById('inspect-hourly-weighted').textContent = `(${Math.round(inspectHourly.weighted_total || 0)})`;
document.getElementById('inspect-daily-total').textContent = inspectDaily.total || '0';
document.getElementById('inspect-daily-weighted').textContent = `(${Math.round(inspectDaily.weighted_total || 0)})`;
// 更新时间戳
if (data.inspect) {
if (data.inspect.hourly_update) {
document.getElementById('inspect-hourly-time').textContent = data.inspect.hourly_update;
}
@@ -1271,10 +1248,10 @@
}
}
// 更新总计数据
// 更新总计数据 - 即使某个业务无数据也能正确显示总量级
if (data.total) {
document.getElementById('total-weighted-hourly').textContent = Math.round(data.total.hourly);
document.getElementById('total-weighted-daily').textContent = Math.round(data.total.daily);
document.getElementById('total-weighted-hourly').textContent = Math.round(data.total.hourly || 0);
document.getElementById('total-weighted-daily').textContent = Math.round(data.total.daily || 0);
// 获取最新的时间戳
const hourlyUpdateTime = getLatestTimestamp([
@@ -1960,12 +1937,15 @@
function updateStats(data) {
try {
// 更新统计栏数据
if (data.breeze && data.breeze.hourly) {
document.getElementById('breeze-total').textContent = data.breeze.hourly.total || '0';
document.getElementById('breeze-daily-total').textContent = data.breeze.daily ? (data.breeze.daily.total || '0') : '0';
// 更新统计栏数据 - 使用默认值处理缺失数据
const breezeHourly = data.breeze && data.breeze.hourly ? data.breeze.hourly : { total: 0, weighted_total: 0 };
const breezeDaily = data.breeze && data.breeze.daily ? data.breeze.daily : { total: 0, weighted_total: 0 };
document.getElementById('breeze-total').textContent = breezeHourly.total || '0';
document.getElementById('breeze-daily-total').textContent = breezeDaily.total || '0';
// 更新时间戳
if (data.breeze) {
if (data.breeze.hourly_update) {
document.getElementById('breeze-hourly-time').textContent = data.breeze.hourly_update;
}
@@ -1974,14 +1954,16 @@
}
}
// 更新CMS数据
if (data.cms && data.cms.hourly) {
// 更新CMS数据 - 使用默认值处理缺失数据
const cmsHourly = data.cms && data.cms.hourly ? data.cms.hourly : { total_count: 0, weighted_total: 0 };
const cmsDaily = data.cms && data.cms.daily ? data.cms.daily : { total_count: 0, weighted_total: 0 };
// 更新顶部统计栏
const cmsTotal = data.cms.hourly.total_count || 0;
document.getElementById('cms-total').textContent = cmsTotal;
document.getElementById('cms-daily-total').textContent = data.cms.daily ? (data.cms.daily.total_count || '0') : '0';
document.getElementById('cms-total').textContent = cmsHourly.total_count || '0';
document.getElementById('cms-daily-total').textContent = cmsDaily.total_count || '0';
// 更新时间戳
if (data.cms) {
if (data.cms.hourly_update) {
document.getElementById('cms-hourly-time').textContent = data.cms.hourly_update;
}
@@ -1990,18 +1972,17 @@
}
}
// 更新CC审核平台数据
if (data.inspect && data.inspect.hourly) {
const hourlyTotal = data.inspect.hourly.total || 0;
const hourlyWeighted = data.inspect.hourly.weighted_total || 0;
document.getElementById('inspect-hourly-total').textContent = hourlyTotal;
document.getElementById('inspect-hourly-weighted').textContent = `(${Math.round(hourlyWeighted)})`;
document.getElementById('inspect-daily-total').textContent = data.inspect.daily ? (data.inspect.daily.total || '0') : '0';
if (data.inspect.daily) {
document.getElementById('inspect-daily-weighted').textContent = `(${Math.round(data.inspect.daily.weighted_total)})`;
}
// 更新CC审核平台数据 - 使用默认值处理缺失数据
const inspectHourly = data.inspect && data.inspect.hourly ? data.inspect.hourly : { total: 0, weighted_total: 0 };
const inspectDaily = data.inspect && data.inspect.daily ? data.inspect.daily : { total: 0, weighted_total: 0 };
document.getElementById('inspect-hourly-total').textContent = inspectHourly.total || '0';
document.getElementById('inspect-hourly-weighted').textContent = `(${Math.round(inspectHourly.weighted_total || 0)})`;
document.getElementById('inspect-daily-total').textContent = inspectDaily.total || '0';
document.getElementById('inspect-daily-weighted').textContent = `(${Math.round(inspectDaily.weighted_total || 0)})`;
// 更新时间戳
if (data.inspect) {
if (data.inspect.hourly_update) {
document.getElementById('inspect-hourly-time').textContent = data.inspect.hourly_update;
}
@@ -2010,10 +1991,10 @@
}
}
// 更新总计数据
// 更新总计数据 - 确保即使某个业务无数据也能正确显示总量级
if (data.total) {
document.getElementById('total-weighted-hourly').textContent = Math.round(data.total.hourly);
document.getElementById('total-weighted-daily').textContent = Math.round(data.total.daily);
document.getElementById('total-weighted-hourly').textContent = Math.round(data.total.hourly || 0);
document.getElementById('total-weighted-daily').textContent = Math.round(data.total.daily || 0);
// 获取最新的时间戳
const hourlyUpdateTime = getLatestTimestamp([