fix: AI诊断摘要正则提取 + 仪表盘排序/宽度修复
- DiagnosisSummary extractSection 改为正则模糊匹配,兼容 DeepSeek 不同标题格式 - 仪表盘近12期柱状图改为从左到右按播出时间升序 - 全局内容区宽度参数定位:.app-content max-width 1190px + width 100%(修复 Ant Design flex 下 margin auto shrink-to-fit) - Dashboard.css 去除多余 max-width 限制 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,18 +10,29 @@ import { generateDiagnosisReport } from '../../services/analyticsService'
|
||||
* - 从 markdown 提取核心发现和行动建议
|
||||
*/
|
||||
|
||||
/** 从 markdown 中提取指定章节内容 */
|
||||
function extractSection(markdown, startMarker, endMarkers) {
|
||||
/** 从 markdown 中提取指定章节内容(正则模糊匹配) */
|
||||
function extractSection(markdown, keyword, endKeywords) {
|
||||
if (!markdown) return ''
|
||||
const startIdx = markdown.indexOf(startMarker)
|
||||
if (startIdx === -1) return ''
|
||||
const afterStart = startIdx + startMarker.length
|
||||
// 找最近的结束标记
|
||||
// 用正则匹配:任意数量的 # 开头,后面包含关键词的行
|
||||
const startRegex = new RegExp(`^#{1,6}\\s*.*${keyword}.*$`, 'm')
|
||||
const match = markdown.match(startRegex)
|
||||
if (!match) return ''
|
||||
const afterStart = match.index + match[0].length
|
||||
// 找最近的结束标记(下一个同级或更高级标题)
|
||||
let endIdx = markdown.length
|
||||
for (const marker of endMarkers) {
|
||||
const idx = markdown.indexOf(marker, afterStart)
|
||||
if (idx !== -1 && idx < endIdx) {
|
||||
endIdx = idx
|
||||
if (endKeywords && endKeywords.length > 0) {
|
||||
for (const kw of endKeywords) {
|
||||
const endRegex = new RegExp(`^#{1,6}\\s*.*${kw}.*$`, 'm')
|
||||
const endMatch = markdown.substring(afterStart).match(endRegex)
|
||||
if (endMatch && (afterStart + endMatch.index) < endIdx) {
|
||||
endIdx = afterStart + endMatch.index
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 没有 endKeywords 时,找下一个同级标题作为结束
|
||||
const nextHeading = markdown.substring(afterStart).match(/^#{1,6}\s+/m)
|
||||
if (nextHeading) {
|
||||
endIdx = afterStart + nextHeading.index
|
||||
}
|
||||
}
|
||||
return markdown.substring(afterStart, endIdx).trim()
|
||||
@@ -156,10 +167,10 @@ function DiagnosisSummary({ episodes, yearlyTarget, selectedYear }) {
|
||||
|
||||
// 提取核心发现和行动建议
|
||||
const markdown = report?.report_markdown || ''
|
||||
// 核心发现:从 "#### 二、核心发现" 到 "#### 三、"
|
||||
let coreFindings = extractSection(markdown, '#### 二、核心发现', ['#### 三、'])
|
||||
// 行动建议:从 "#### 四、行动建议" 到末尾
|
||||
let actions = extractSection(markdown, '#### 四、行动建议', [])
|
||||
// 核心发现:关键词匹配"核心发现",到"深度分析"或"三、"
|
||||
let coreFindings = extractSection(markdown, '核心发现', ['深度分析', '三、'])
|
||||
// 行动建议:关键词匹配"行动建议",到末尾
|
||||
let actions = extractSection(markdown, '行动建议', [])
|
||||
|
||||
const coreLines = parseMarkdownLines(coreFindings)
|
||||
const actionLines = parseMarkdownLines(actions)
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
.app-main {
|
||||
min-height: 100vh;
|
||||
margin-left: 220px;
|
||||
width: calc(100vw - 220px);
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.app-header {
|
||||
@@ -35,6 +37,8 @@
|
||||
padding: 24px;
|
||||
background: var(--color-bg-cream);
|
||||
min-height: calc(100vh - 64px);
|
||||
max-width: 1400px;
|
||||
width: 100%;
|
||||
max-width: 1190px;
|
||||
margin: 0 auto;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
.dashboard {
|
||||
max-width: 1200px;
|
||||
padding: 12px;
|
||||
padding: 12px 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* ===== Banner ===== */
|
||||
|
||||
@@ -86,6 +86,7 @@ function Dashboard() {
|
||||
const displayEpisodes = episodes
|
||||
.filter(e => e.audience_share != null)
|
||||
.slice(0, 12)
|
||||
.reverse()
|
||||
|
||||
const bestEpisode = [...displayEpisodes].sort((a, b) => Number(b.audience_share) - Number(a.audience_share))[0]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user