update code
This commit is contained in:
@@ -182,4 +182,177 @@ body {
|
||||
|
||||
.export-btn:hover {
|
||||
background: #218838;
|
||||
}
|
||||
|
||||
/* 预览控制样式 */
|
||||
.preview-controls {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
border-bottom: 1px solid #eee;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
.preview-btn {
|
||||
background: #f8f9fa;
|
||||
color: #666;
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px 16px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.preview-btn:hover {
|
||||
background: #e9ecef;
|
||||
border-color: #adb5bd;
|
||||
}
|
||||
|
||||
.preview-btn.active {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
/* Markdown源代码显示样式 */
|
||||
.markdown-source {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
max-height: 600px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.markdown-source pre {
|
||||
margin: 0;
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.markdown-source code {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 增强的报告内容样式 */
|
||||
.report-content {
|
||||
white-space: pre-wrap;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
line-height: 1.8;
|
||||
font-size: 14px;
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
/* Markdown渲染样式 */
|
||||
.report-content h1,
|
||||
.report-content h2,
|
||||
.report-content h3,
|
||||
.report-content h4,
|
||||
.report-content h5,
|
||||
.report-content h6 {
|
||||
margin: 20px 0 10px 0;
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.report-content h1 {
|
||||
font-size: 1.8em;
|
||||
border-bottom: 2px solid #667eea;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.report-content h2 {
|
||||
font-size: 1.5em;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.report-content h3 {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.report-content p {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.report-content ul,
|
||||
.report-content ol {
|
||||
margin: 10px 0 10px 20px;
|
||||
}
|
||||
|
||||
.report-content li {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.report-content blockquote {
|
||||
border-left: 4px solid #667eea;
|
||||
background: #f8f9fa;
|
||||
padding: 10px 15px;
|
||||
margin: 15px 0;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.report-content code {
|
||||
background: #f1f3f4;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.report-content pre {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: 5px;
|
||||
padding: 15px;
|
||||
overflow-x: auto;
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.report-content pre code {
|
||||
background: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.report-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.report-content th,
|
||||
.report-content td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px 12px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.report-content th {
|
||||
background: #f8f9fa;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.report-content tr:nth-child(even) {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
/* 水平分隔线样式 */
|
||||
.report-content hr {
|
||||
border: none;
|
||||
border-top: 2px solid #667eea;
|
||||
margin: 30px 0;
|
||||
height: 0;
|
||||
}
|
||||
@@ -209,4 +209,177 @@ body {
|
||||
|
||||
.export-btn:hover {
|
||||
background: #218838;
|
||||
}
|
||||
|
||||
/* 预览控制样式 */
|
||||
.preview-controls {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
border-bottom: 1px solid #eee;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
.preview-btn {
|
||||
background: #f8f9fa;
|
||||
color: #666;
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px 16px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.preview-btn:hover {
|
||||
background: #e9ecef;
|
||||
border-color: #adb5bd;
|
||||
}
|
||||
|
||||
.preview-btn.active {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
/* Markdown源代码显示样式 */
|
||||
.markdown-source {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: 5px;
|
||||
padding: 20px;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
max-height: 600px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.markdown-source pre {
|
||||
margin: 0;
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.markdown-source code {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 增强的报告内容样式 */
|
||||
.report-content {
|
||||
white-space: pre-wrap;
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
line-height: 1.8;
|
||||
font-size: 14px;
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
/* Markdown渲染样式 */
|
||||
.report-content h1,
|
||||
.report-content h2,
|
||||
.report-content h3,
|
||||
.report-content h4,
|
||||
.report-content h5,
|
||||
.report-content h6 {
|
||||
margin: 20px 0 10px 0;
|
||||
color: #333;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.report-content h1 {
|
||||
font-size: 1.8em;
|
||||
border-bottom: 2px solid #667eea;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.report-content h2 {
|
||||
font-size: 1.5em;
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.report-content h3 {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.report-content p {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
.report-content ul,
|
||||
.report-content ol {
|
||||
margin: 10px 0 10px 20px;
|
||||
}
|
||||
|
||||
.report-content li {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.report-content blockquote {
|
||||
border-left: 4px solid #667eea;
|
||||
background: #f8f9fa;
|
||||
padding: 10px 15px;
|
||||
margin: 15px 0;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.report-content code {
|
||||
background: #f1f3f4;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
font-family: 'Courier New', monospace;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.report-content pre {
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: 5px;
|
||||
padding: 15px;
|
||||
overflow-x: auto;
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.report-content pre code {
|
||||
background: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.report-content table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
margin: 15px 0;
|
||||
}
|
||||
|
||||
.report-content th,
|
||||
.report-content td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 8px 12px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.report-content th {
|
||||
background: #f8f9fa;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.report-content tr:nth-child(even) {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
/* 水平分隔线样式 */
|
||||
.report-content hr {
|
||||
border: none;
|
||||
border-top: 2px solid #667eea;
|
||||
margin: 30px 0;
|
||||
height: 0;
|
||||
}
|
||||
@@ -36,7 +36,16 @@ function generateReport() {
|
||||
hideLoading();
|
||||
|
||||
if (data.success) {
|
||||
document.getElementById('report-content').textContent = data.report;
|
||||
// 保存原始Markdown内容到data属性
|
||||
document.getElementById('report-content').setAttribute('data-markdown', data.report);
|
||||
|
||||
// 将Markdown转换为HTML并显示
|
||||
const htmlContent = markdownToHtml(data.report);
|
||||
document.getElementById('report-content').innerHTML = htmlContent;
|
||||
|
||||
// 重置为预览模式
|
||||
togglePreview('preview');
|
||||
|
||||
document.getElementById('report-container').style.display = 'block';
|
||||
|
||||
// 显示统计数据
|
||||
@@ -81,7 +90,7 @@ function displayStatistics(stats) {
|
||||
}
|
||||
|
||||
function exportReport() {
|
||||
const reportContent = document.getElementById('report-content').textContent;
|
||||
const reportContent = document.getElementById('report-content').getAttribute('data-markdown');
|
||||
if (!reportContent) {
|
||||
showError('请先生成日报');
|
||||
return;
|
||||
|
||||
86
static/js/markdown-render.js
Normal file
86
static/js/markdown-render.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// Markdown转HTML的简单实现
|
||||
function markdownToHtml(markdown) {
|
||||
// 替换标题
|
||||
let html = markdown
|
||||
.replace(/^# (.*$)/gm, '<h1>$1</h1>')
|
||||
.replace(/^## (.*$)/gm, '<h2>$1</h2>')
|
||||
.replace(/^### (.*$)/gm, '<h3>$1</h3>')
|
||||
.replace(/^#### (.*$)/gm, '<h4>$1</h4>')
|
||||
.replace(/^##### (.*$)/gm, '<h5>$1</h5>')
|
||||
.replace(/^###### (.*$)/gm, '<h6>$1</h6>');
|
||||
|
||||
// 替换粗体
|
||||
html = html.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>');
|
||||
|
||||
// 替换斜体
|
||||
html = html.replace(/\*(.*?)\*/g, '<em>$1</em>');
|
||||
|
||||
// 替换代码块
|
||||
html = html.replace(/```([\s\S]*?)```/g, '<pre><code>$1</code></pre>');
|
||||
|
||||
// 替换行内代码
|
||||
html = html.replace(/`(.*?)`/g, '<code>$1</code>');
|
||||
|
||||
// 替换无序列表
|
||||
html = html.replace(/^\s*[-*] (.*$)/gm, '<li>$1</li>');
|
||||
html = html.replace(/(<li>.*<\/li>)/s, '<ul>$1</ul>');
|
||||
|
||||
// 替换有序列表
|
||||
html = html.replace(/^\s*\d+\. (.*$)/gm, '<li>$1</li>');
|
||||
html = html.replace(/(<li>.*<\/li>)/s, '<ol>$1</ol>');
|
||||
|
||||
// 替换引用块
|
||||
html = html.replace(/^> (.*$)/gm, '<blockquote>$1</blockquote>');
|
||||
|
||||
// 替换链接
|
||||
html = html.replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2" target="_blank">$1</a>');
|
||||
|
||||
// 替换图片
|
||||
html = html.replace(/!\[(.*?)\]\((.*?)\)/g, '<img src="$2" alt="$1" style="max-width: 100%;">');
|
||||
|
||||
// 替换表格(简单实现)
|
||||
html = html.replace(/\|(.+)\|/g, function(match) {
|
||||
const cells = match.split('|').filter(cell => cell.trim());
|
||||
if (cells.length > 0) {
|
||||
return '<tr><td>' + cells.join('</td><td>') + '</td></tr>';
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
// 替换水平分隔线(---、***、___)
|
||||
html = html.replace(/^\s*[-*_]{3,}\s*$/gm, '<hr>');
|
||||
|
||||
// 将连续的空行转换为段落
|
||||
html = html.replace(/\n\n+/g, '</p><p>');
|
||||
html = '<p>' + html.replace(/\n/g, '<br>') + '</p>';
|
||||
|
||||
// 清理多余的段落标签
|
||||
html = html.replace(/<p><\/p>/g, '');
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
// 切换预览模式函数
|
||||
togglePreview = function(mode) {
|
||||
const previewBtn = document.getElementById('preview-toggle');
|
||||
const sourceBtn = document.getElementById('source-toggle');
|
||||
const reportContent = document.getElementById('report-content');
|
||||
const markdownSource = document.getElementById('markdown-source');
|
||||
const sourceContent = document.getElementById('source-content');
|
||||
|
||||
if (mode === 'preview') {
|
||||
previewBtn.classList.add('active');
|
||||
sourceBtn.classList.remove('active');
|
||||
reportContent.style.display = 'block';
|
||||
markdownSource.style.display = 'none';
|
||||
} else {
|
||||
previewBtn.classList.remove('active');
|
||||
sourceBtn.classList.add('active');
|
||||
reportContent.style.display = 'none';
|
||||
markdownSource.style.display = 'block';
|
||||
|
||||
// 显示原始Markdown源代码
|
||||
const markdown = reportContent.getAttribute('data-markdown');
|
||||
sourceContent.textContent = markdown;
|
||||
}
|
||||
};
|
||||
@@ -184,11 +184,11 @@ function displaySearchResults(messages) {
|
||||
<div class="qa-content">
|
||||
<div class="message-item">
|
||||
<strong>类型:</strong> ${msg.type} |
|
||||
<strong>发送者:</strong> ${msg.sender || '未知'} |
|
||||
<strong>发送者:</strong> ${msg.sender_name || '未知'} |
|
||||
<strong>接收者:</strong> ${msg.receiver || '未知'}
|
||||
</div>
|
||||
<div class="message-item" style="margin-top: 10px;">
|
||||
<strong>内容:</strong> ${msg.content || '无内容'}
|
||||
<strong>内容:</strong> ${msg.display_content || '无内容'}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -484,11 +484,11 @@ async function displayPreview(qa) {
|
||||
</div>
|
||||
<div class="message-content">
|
||||
<div class="message-header">
|
||||
<span class="sender">${msg.sender || '未知用户'}</span>
|
||||
<span class="sender">${msg.sender_name || msg.sender}</span>
|
||||
<span class="time">${msg.formatted_time || '未知时间'}</span>
|
||||
<span class="message-type-badge ${messageType}">${messageType === 'question' ? '问题' : (messageType === 'answer' ? '答案' : '其他')}</span>
|
||||
</div>
|
||||
<div class="message-text">${msg.content || '无内容'}</div>
|
||||
<div class="message-text">${msg.display_content || '无内容'}</div>
|
||||
<div class="message-meta">
|
||||
<span class="message-id">消息ID: ${msg.id}</span>
|
||||
<span class="message-type">类型: ${msg.type || '未知'}</span>
|
||||
|
||||
@@ -32,6 +32,8 @@ function generateCurrentWeekReport() {
|
||||
generateReport();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function generateReport() {
|
||||
const week = document.getElementById('week').value;
|
||||
if (!week) {
|
||||
@@ -52,8 +54,14 @@ function generateReport() {
|
||||
if (data.success) {
|
||||
// 保存原始Markdown内容到data属性
|
||||
document.getElementById('report-content').setAttribute('data-markdown', data.report);
|
||||
// 使用innerHTML显示格式化内容
|
||||
document.getElementById('report-content').innerHTML = data.report.replace(/\n/g, '<br>');
|
||||
|
||||
// 将Markdown转换为HTML并显示
|
||||
const htmlContent = markdownToHtml(data.report);
|
||||
document.getElementById('report-content').innerHTML = htmlContent;
|
||||
|
||||
// 重置为预览模式
|
||||
togglePreview('preview');
|
||||
|
||||
document.getElementById('report-container').style.display = 'block';
|
||||
|
||||
// 显示统计数据
|
||||
|
||||
Reference in New Issue
Block a user