首页AI脚本卡片右下角显示脚本评分:listRecentScripts 关联最新 AI 复盘总分,无评分不显示徽章
This commit is contained in:
1 parent
0f315de830
commit
4f4e126e61
4 files changed
+23
-7
No files matched your search
@@ -311,13 +311,18 @@ function getStats() {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// 最近 AI 写剧本(首页快捷卡片):status=done 且有内容,按 id 倒序取前 N 条
|
// 最近 AI 写剧本(首页快捷卡片):status=done 且有内容,按 id 倒序取前 N 条;
|
||||||
|
// score = 该脚本最新一条已完成 AI 复盘(script_review type='ai')的总分,无复盘则为 null
|
||||||
function listRecentScripts(limit = 4) {
|
function listRecentScripts(limit = 4) {
|
||||||
const d = getDb(); if (!d) return [];
|
const d = getDb(); if (!d) return [];
|
||||||
const n = Math.max(1, Math.min(Number(limit) || 4, 20));
|
const n = Math.max(1, Math.min(Number(limit) || 4, 20));
|
||||||
return d.prepare(`
|
return d.prepare(`
|
||||||
SELECT r.id, r.title, r.script_text, r.created_time, r.video_id, r.account_id,
|
SELECT r.id, r.title, r.script_text, r.created_time, r.video_id, r.account_id,
|
||||||
h.account_name, v.video_title
|
h.account_name, v.video_title,
|
||||||
|
(SELECT sr.total FROM script_review sr
|
||||||
|
WHERE sr.type='ai' AND sr.rewrite_id = r.id AND sr.status='done'
|
||||||
|
AND sr.total IS NOT NULL AND sr.total <> ''
|
||||||
|
ORDER BY sr.id DESC LIMIT 1) AS score
|
||||||
FROM rewrite_log r
|
FROM rewrite_log r
|
||||||
LEFT JOIN hot_accounts h ON h.id = r.account_id
|
LEFT JOIN hot_accounts h ON h.id = r.account_id
|
||||||
LEFT JOIN account_videos v ON v.id = r.video_id
|
LEFT JOIN account_videos v ON v.id = r.video_id
|
||||||
|
|||||||
@@ -424,15 +424,24 @@ async function loadRecentScripts() {
|
|||||||
const items = (d.items || []);
|
const items = (d.items || []);
|
||||||
if (!items.length) { el.innerHTML = '<span class="dim">暂无 AI 写剧本</span>'; return; }
|
if (!items.length) { el.innerHTML = '<span class="dim">暂无 AI 写剧本</span>'; return; }
|
||||||
_recentScriptsCache = {};
|
_recentScriptsCache = {};
|
||||||
|
// 评分徽章配色与诊断页一致:≥75 绿 / ≥60 橙 / <60 红
|
||||||
|
const scoreColor = (v) => (v >= 75 ? '#3a9e6d' : v >= 60 ? '#d99a2b' : '#d9534f');
|
||||||
el.innerHTML = items.map((s) => {
|
el.innerHTML = items.map((s) => {
|
||||||
_recentScriptsCache[s.id] = s;
|
_recentScriptsCache[s.id] = s;
|
||||||
const title = cleanTitle(s.title || s.video_title) || '未命名剧本';
|
const title = cleanTitle(s.title || s.video_title) || '未命名剧本';
|
||||||
const meta = [s.account_name, s.created_time ? fmtDate(s.created_time) : ''].filter(Boolean).join(' | ');
|
const meta = [s.account_name, s.created_time ? fmtDate(s.created_time) : ''].filter(Boolean).join(' | ');
|
||||||
const preview = previewLines(s.script_text, 5);
|
const preview = previewLines(s.script_text, 5);
|
||||||
|
// 有 AI 复盘评分 → 卡片右下角徽章;无评分不显示
|
||||||
|
const sc = Number(s.score);
|
||||||
|
const scoreBadge = (s.score !== null && s.score !== undefined && s.score !== '' && Number.isFinite(sc))
|
||||||
|
? `<span class="recent-card-score" style="background:${scoreColor(sc)}1a;color:${scoreColor(sc)}">评分 ${sc % 1 === 0 ? sc : sc.toFixed(1)}</span>` : '';
|
||||||
return `<button class="recent-card" data-script="${s.id}" title="点击查看完整剧本">
|
return `<button class="recent-card" data-script="${s.id}" title="点击查看完整剧本">
|
||||||
<span class="recent-card-title">${esc(title)}</span>
|
<span class="recent-card-title">${esc(title)}</span>
|
||||||
<span class="recent-card-preview">${preview.map((l) => `<span class="recent-preview-line">${esc(l)}</span>`).join('')}</span>
|
<span class="recent-card-preview">${preview.map((l) => `<span class="recent-preview-line">${esc(l)}</span>`).join('')}</span>
|
||||||
<span class="recent-card-meta">${esc(meta)}</span>
|
<span class="recent-card-foot">
|
||||||
|
<span class="recent-card-meta">${esc(meta)}</span>
|
||||||
|
${scoreBadge}
|
||||||
|
</span>
|
||||||
</button>`;
|
</button>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
el.querySelectorAll('.recent-card').forEach((b) => b.addEventListener('click', () => {
|
el.querySelectorAll('.recent-card').forEach((b) => b.addEventListener('click', () => {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>MCN工作台</title>
|
<title>MCN工作台</title>
|
||||||
<link rel="stylesheet" href="style.css?v=20260903f">
|
<link rel="stylesheet" href="style.css?v=20260903g">
|
||||||
<script src="vendor/echarts.min.js"></script>
|
<script src="vendor/echarts.min.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="app.js?v=20260903f"></script>
|
<script src="app.js?v=20260903g"></script>
|
||||||
<script src="data-pages.js?v=20260903f"></script>
|
<script src="data-pages.js?v=20260903g"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -626,7 +626,9 @@ td.td-title { max-width: 240px; }
|
|||||||
.recent-card-title { font-size: 15px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; display: flex; align-items: center; gap: 6px; }
|
.recent-card-title { font-size: 15px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; display: flex; align-items: center; gap: 6px; }
|
||||||
.recent-card-preview { width: 100%; display: flex; flex-direction: column; gap: 2px; }
|
.recent-card-preview { width: 100%; display: flex; flex-direction: column; gap: 2px; }
|
||||||
.recent-preview-line { display: block; font-size: 14px; color: #57606a; line-height: 1.55; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
|
.recent-preview-line { display: block; font-size: 14px; color: #57606a; line-height: 1.55; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
|
||||||
.recent-card-meta { font-size: 14px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; margin-top: auto; }
|
.recent-card-foot { width: 100%; margin-top: auto; display: flex; align-items: center; gap: 8px; }
|
||||||
|
.recent-card-meta { font-size: 14px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
|
||||||
|
.recent-card-score { flex: none; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; line-height: 1.5; }
|
||||||
.recent-meta { font-size: 14px; color: var(--dim); margin-bottom: 12px; }
|
.recent-meta { font-size: 14px; color: var(--dim); margin-bottom: 12px; }
|
||||||
|
|
||||||
/* ================= 扁平化向量图标 ================= */
|
/* ================= 扁平化向量图标 ================= */
|
||||||
|
|||||||
Reference in new issue
Block a user