init
This commit is contained in:
170
static/css/daily_report.css
Normal file
170
static/css/daily_report.css
Normal file
@@ -0,0 +1,170 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 30px;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2.5em;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.header p {
|
||||
font-size: 1.2em;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.controls {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.control-group {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.control-group label {
|
||||
font-weight: bold;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.control-group input {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: #5a6fd8;
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
background: #ccc;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.report-container {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
padding: 30px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.report-content {
|
||||
white-space: pre-wrap;
|
||||
font-family: 'Courier New', monospace;
|
||||
line-height: 1.8;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.error {
|
||||
background: #ffe6e6;
|
||||
color: #d63031;
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
margin: 10px 0;
|
||||
border-left: 4px solid #d63031;
|
||||
}
|
||||
|
||||
.statistics {
|
||||
background: #f8f9fa;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.stat-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 15px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
background: white;
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 1.8em;
|
||||
font-weight: bold;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 0.9em;
|
||||
color: #666;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.nav-btn {
|
||||
padding: 8px 16px;
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.nav-btn:hover {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-color: #667eea;
|
||||
}
|
||||
492
static/css/index.css
Normal file
492
static/css/index.css
Normal file
@@ -0,0 +1,492 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||||
background-color: #f5f5f5;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 30px;
|
||||
border-radius: 15px;
|
||||
margin-bottom: 30px;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2.5em;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.header p {
|
||||
font-size: 1.1em;
|
||||
opacity: 0.9;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.nav-btn {
|
||||
padding: 8px 16px;
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.nav-btn:hover {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.nav-btn.active {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.nav-link {
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
color: white;
|
||||
padding: 8px 16px;
|
||||
border-radius: 20px;
|
||||
text-decoration: none;
|
||||
font-size: 0.9em;
|
||||
transition: all 0.3s ease;
|
||||
border: 1px solid rgba(255, 255, 255, 0.3);
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
background: rgba(255, 255, 255, 0.3);
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 20px;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.stat-card {
|
||||
background: white;
|
||||
padding: 25px;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
|
||||
text-align: center;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.stat-card:hover {
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.stat-number {
|
||||
font-size: 2.5em;
|
||||
font-weight: bold;
|
||||
color: #667eea;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
color: #666;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.view-switcher {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.view-btn {
|
||||
padding: 10px 20px;
|
||||
border: 2px solid #667eea;
|
||||
background: white;
|
||||
color: #667eea;
|
||||
border-radius: 25px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.view-btn.active {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.view-btn:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
display: grid;
|
||||
grid-template-columns: 300px 1fr;
|
||||
gap: 20px;
|
||||
height: 70vh;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.sidebar h3 {
|
||||
margin-bottom: 15px;
|
||||
color: #333;
|
||||
border-bottom: 2px solid #667eea;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.group-list {
|
||||
list-style: none;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.group-item {
|
||||
padding: 15px;
|
||||
margin-bottom: 10px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
border-left: 4px solid transparent;
|
||||
}
|
||||
|
||||
.group-item:hover {
|
||||
background: #e9ecef;
|
||||
transform: translateX(5px);
|
||||
}
|
||||
|
||||
.group-item.active {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-left-color: #764ba2;
|
||||
}
|
||||
|
||||
.group-name {
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.group-info {
|
||||
font-size: 0.8em;
|
||||
color: #666;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.group-item.active .group-info {
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.chat-area {
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.chat-header {
|
||||
padding: 20px;
|
||||
border-bottom: 1px solid #eee;
|
||||
background: #f8f9fa;
|
||||
border-radius: 12px 12px 0 0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.current-group {
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.group-stats {
|
||||
font-size: 0.9em;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.chat-messages {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.message {
|
||||
margin-bottom: 20px;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.message.own {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
max-width: 70%;
|
||||
padding: 12px 16px;
|
||||
border-radius: 18px;
|
||||
background: #f1f3f5;
|
||||
position: relative;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap: break-word;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.message.own .message-content {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.message-sender {
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.message-time {
|
||||
font-size: 0.8em;
|
||||
color: #999;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.message.own .message-time {
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
.controls {
|
||||
padding: 20px;
|
||||
border-top: 1px solid #eee;
|
||||
background: #f8f9fa;
|
||||
border-radius: 0 0 12px 12px;
|
||||
}
|
||||
|
||||
.load-more {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 12px 24px;
|
||||
border-radius: 25px;
|
||||
cursor: pointer;
|
||||
font-size: 1em;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.load-more:hover {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.error {
|
||||
background: #ffe6e6;
|
||||
color: #d63031;
|
||||
padding: 10px;
|
||||
border-radius: 8px;
|
||||
margin: 10px 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.chat-container {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
max-width: 85%;
|
||||
}
|
||||
}
|
||||
|
||||
body, .container {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* 聊天记录按钮样式 */
|
||||
.chatrecord-btn {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 15px;
|
||||
cursor: pointer;
|
||||
font-size: 0.9em;
|
||||
transition: all 0.3s ease;
|
||||
text-align: left;
|
||||
max-width: 100%;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap: break-word;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.chatrecord-btn:hover {
|
||||
transform: scale(1.05);
|
||||
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
|
||||
}
|
||||
|
||||
/* 模态框样式 */
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 1000;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
animation: fadeIn 0.3s;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: white;
|
||||
margin: 5% auto;
|
||||
padding: 0;
|
||||
border-radius: 15px;
|
||||
width: 80%;
|
||||
max-width: 800px;
|
||||
max-height: 80vh;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
|
||||
animation: slideIn 0.3s;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 20px;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.modal-header h3 {
|
||||
margin: 0;
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.close {
|
||||
color: white;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.3s;
|
||||
}
|
||||
|
||||
.close:hover {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 0;
|
||||
max-height: calc(80vh - 80px);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.chat-record-content {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.chat-record-item {
|
||||
margin-bottom: 15px;
|
||||
padding: 15px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 10px;
|
||||
border-left: 4px solid #667eea;
|
||||
}
|
||||
|
||||
.chat-record-sender {
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.chat-record-text {
|
||||
margin-bottom: 5px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.chat-record-time {
|
||||
font-size: 0.8em;
|
||||
color: #666;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.chat-record-image {
|
||||
max-width: 200px;
|
||||
max-height: 200px;
|
||||
border-radius: 8px;
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideIn {
|
||||
from {
|
||||
transform: translateY(-50px);
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 100%;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
506
static/css/qa.css
Normal file
506
static/css/qa.css
Normal file
@@ -0,0 +1,506 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background-color: #f5f5f5;
|
||||
color: #333;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 30px 0;
|
||||
text-align: center;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 30px;
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2.5em;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.header p {
|
||||
font-size: 1.1em;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.controls {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.search-box {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.search-box input {
|
||||
flex: 1;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: #5a6fd8;
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
background: #28a745;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-success:hover {
|
||||
background: #218838;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: #dc3545;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: #c82333;
|
||||
}
|
||||
|
||||
.qa-list {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.qa-item {
|
||||
padding: 20px;
|
||||
border-bottom: 1px solid #eee;
|
||||
transition: background-color 0.3s ease;
|
||||
}
|
||||
|
||||
.qa-item:hover {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.qa-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.qa-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.qa-id {
|
||||
font-weight: bold;
|
||||
color: #667eea;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.qa-group {
|
||||
background: #e9ecef;
|
||||
padding: 5px 10px;
|
||||
border-radius: 15px;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.qa-content {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.nav-btn {
|
||||
padding: 8px 16px;
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.nav-btn:hover {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.nav-btn.active {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.qa-section {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.qa-section h4 {
|
||||
color: #495057;
|
||||
margin-bottom: 5px;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.message-list {
|
||||
background: #f8f9fa;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.message-item {
|
||||
padding: 5px;
|
||||
margin-bottom: 5px;
|
||||
background: white;
|
||||
border-radius: 3px;
|
||||
font-size: 0.9em;
|
||||
border-left: 3px solid #667eea;
|
||||
}
|
||||
|
||||
.qa-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.modal {
|
||||
display: none;
|
||||
position: fixed;
|
||||
z-index: 1000;
|
||||
left: 0;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background-color: white;
|
||||
margin: 5% auto;
|
||||
padding: 30px;
|
||||
border-radius: 10px;
|
||||
width: 80%;
|
||||
max-width: 800px;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.close {
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.close:hover {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 5px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.form-group input,
|
||||
.form-group textarea {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.message-selector {
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
padding: 15px;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.search-results {
|
||||
max-height: 200px;
|
||||
overflow-y: auto;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.search-result-item {
|
||||
padding: 10px;
|
||||
border-bottom: 1px solid #eee;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.search-result-item:hover {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
|
||||
.selected-messages {
|
||||
background: #f8f9fa;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.selected-message {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 5px;
|
||||
margin-bottom: 5px;
|
||||
background: white;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.empty-state i {
|
||||
font-size: 48px;
|
||||
margin-bottom: 10px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
/* 聊天记录预览样式 */
|
||||
.chat-preview {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.chat-header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.chat-header h3 {
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.chat-info {
|
||||
opacity: 0.9;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.chat-container {
|
||||
padding: 20px;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.chat-message {
|
||||
display: flex;
|
||||
margin-bottom: 15px;
|
||||
animation: fadeIn 0.3s ease;
|
||||
}
|
||||
|
||||
.chat-message.question {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
.chat-message.answer {
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
.chat-message.other {
|
||||
flex-direction: row;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.message-avatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 18px;
|
||||
margin: 0 10px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.chat-message.question .message-avatar {
|
||||
background: #e3f2fd;
|
||||
color: #1976d2;
|
||||
}
|
||||
|
||||
.chat-message.answer .message-avatar {
|
||||
background: #f3e5f5;
|
||||
color: #7b1fa2;
|
||||
}
|
||||
|
||||
.chat-message.other .message-avatar {
|
||||
background: #f5f5f5;
|
||||
color: #757575;
|
||||
}
|
||||
|
||||
.message-content {
|
||||
flex: 1;
|
||||
max-width: 70%;
|
||||
}
|
||||
|
||||
.message-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-bottom: 5px;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.sender {
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.time {
|
||||
font-size: 0.8em;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.message-type-badge {
|
||||
padding: 2px 8px;
|
||||
border-radius: 12px;
|
||||
font-size: 0.7em;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.message-type-badge.question {
|
||||
background: #e3f2fd;
|
||||
color: #1976d2;
|
||||
}
|
||||
|
||||
.message-type-badge.answer {
|
||||
background: #f3e5f5;
|
||||
color: #7b1fa2;
|
||||
}
|
||||
|
||||
.message-type-badge.other {
|
||||
background: #f5f5f5;
|
||||
color: #757575;
|
||||
}
|
||||
|
||||
.message-text {
|
||||
background: white;
|
||||
padding: 12px 15px;
|
||||
border-radius: 18px;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||
line-height: 1.4;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.chat-message.question .message-text {
|
||||
background: #e3f2fd;
|
||||
border-bottom-left-radius: 5px;
|
||||
}
|
||||
|
||||
.chat-message.answer .message-text {
|
||||
background: #f3e5f5;
|
||||
border-bottom-right-radius: 5px;
|
||||
}
|
||||
|
||||
.chat-message.other .message-text {
|
||||
background: #f5f5f5;
|
||||
border-radius: 18px;
|
||||
}
|
||||
|
||||
.message-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
margin-top: 5px;
|
||||
font-size: 0.7em;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.chat-summary {
|
||||
background: white;
|
||||
padding: 15px 20px;
|
||||
border-top: 1px solid #eee;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.summary-item {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.summary-label {
|
||||
display: block;
|
||||
font-size: 0.8em;
|
||||
color: #666;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.summary-value {
|
||||
display: block;
|
||||
font-size: 1.2em;
|
||||
font-weight: bold;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
@keyframes fadeIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(10px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
212
static/css/weekly_report.css
Normal file
212
static/css/weekly_report.css
Normal file
@@ -0,0 +1,212 @@
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.header {
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: white;
|
||||
padding: 30px;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.header h1 {
|
||||
font-size: 2.5em;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.header p {
|
||||
font-size: 1.2em;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.controls {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
margin-bottom: 20px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.control-group {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.control-group label {
|
||||
font-weight: bold;
|
||||
color: #555;
|
||||
}
|
||||
|
||||
.control-group input {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.btn:hover {
|
||||
background: #5a6fd8;
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
background: #ccc;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.report-container {
|
||||
background: white;
|
||||
border-radius: 10px;
|
||||
padding: 30px;
|
||||
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.report-content {
|
||||
white-space: pre-wrap;
|
||||
font-family: 'Courier New', monospace;
|
||||
line-height: 1.8;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.error {
|
||||
background: #ffe6e6;
|
||||
color: #d63031;
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
margin: 10px 0;
|
||||
border-left: 4px solid #d63031;
|
||||
}
|
||||
|
||||
.statistics {
|
||||
background: #f8f9fa;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.stat-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
gap: 15px;
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
background: white;
|
||||
padding: 15px;
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 1.8em;
|
||||
font-weight: bold;
|
||||
color: #667eea;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 0.9em;
|
||||
color: #666;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.category-chart {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 10px 0;
|
||||
padding: 10px;
|
||||
background: #f8f9fa;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.category-bar {
|
||||
height: 20px;
|
||||
background: linear-gradient(90deg, #667eea, #764ba2);
|
||||
border-radius: 10px;
|
||||
margin: 0 10px;
|
||||
min-width: 50px;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.nav-btn {
|
||||
padding: 8px 16px;
|
||||
background: #f8f9fa;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 5px;
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.nav-btn:hover {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.nav-btn.active {
|
||||
background: #667eea;
|
||||
color: white;
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.export-btn {
|
||||
background: #28a745;
|
||||
color: white;
|
||||
border: none;
|
||||
padding: 8px 16px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
font-size: 14px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.export-btn:hover {
|
||||
background: #218838;
|
||||
}
|
||||
86
static/js/daily_report.js
Normal file
86
static/js/daily_report.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// 设置默认日期为今天
|
||||
document.getElementById('date').value = new Date().toISOString().split('T')[0];
|
||||
|
||||
function showLoading() {
|
||||
document.getElementById('loading').style.display = 'block';
|
||||
document.getElementById('report-container').style.display = 'none';
|
||||
document.getElementById('error').style.display = 'none';
|
||||
}
|
||||
|
||||
function hideLoading() {
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
}
|
||||
|
||||
function showError(message) {
|
||||
document.getElementById('error').style.display = 'block';
|
||||
document.getElementById('error').textContent = message;
|
||||
}
|
||||
|
||||
function generateTodayReport() {
|
||||
document.getElementById('date').value = new Date().toISOString().split('T')[0];
|
||||
generateReport();
|
||||
}
|
||||
|
||||
function generateReport() {
|
||||
const date = document.getElementById('date').value;
|
||||
if (!date) {
|
||||
showError('请选择日期');
|
||||
return;
|
||||
}
|
||||
|
||||
showLoading();
|
||||
|
||||
fetch(`/api/reports/daily?date=${date}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
hideLoading();
|
||||
|
||||
if (data.success) {
|
||||
document.getElementById('report-content').textContent = data.report;
|
||||
document.getElementById('report-container').style.display = 'block';
|
||||
|
||||
// 显示统计数据
|
||||
if (data.statistics) {
|
||||
displayStatistics(data.statistics);
|
||||
document.getElementById('statistics').style.display = 'block';
|
||||
}
|
||||
} else {
|
||||
showError('生成日报失败:' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
hideLoading();
|
||||
showError('网络错误:' + error.message);
|
||||
});
|
||||
}
|
||||
|
||||
function displayStatistics(stats) {
|
||||
const statGrid = document.getElementById('stat-grid');
|
||||
statGrid.innerHTML = '';
|
||||
|
||||
const statistics = [
|
||||
{label: '今日消息量', value: stats.today_message_count, unit: '条'},
|
||||
{label: '昨日消息量', value: stats.yesterday_message_count, unit: '条'},
|
||||
{label: '消息变化率', value: stats.message_change_rate.toFixed(1), unit: '%'},
|
||||
{label: '今日活跃用户', value: stats.today_active_users, unit: '人'},
|
||||
{label: '昨日活跃用户', value: stats.yesterday_active_users, unit: '人'},
|
||||
{label: '用户变化率', value: stats.user_change_rate.toFixed(1), unit: '%'},
|
||||
{label: '群组数量', value: stats.group_count, unit: '个'},
|
||||
{label: '成员总数', value: stats.member_count, unit: '人'}
|
||||
];
|
||||
|
||||
statistics.forEach(stat => {
|
||||
const statItem = document.createElement('div');
|
||||
statItem.className = 'stat-item';
|
||||
statItem.innerHTML = `
|
||||
<div class="stat-value">${stat.value}${stat.unit}</div>
|
||||
<div class="stat-label">${stat.label}</div>
|
||||
`;
|
||||
statGrid.appendChild(statItem);
|
||||
});
|
||||
}
|
||||
|
||||
// 页面加载时自动生成今日日报
|
||||
window.addEventListener('load', function () {
|
||||
generateTodayReport();
|
||||
});
|
||||
309
static/js/index.js
Normal file
309
static/js/index.js
Normal file
@@ -0,0 +1,309 @@
|
||||
let currentOffset = 0;
|
||||
const limit = 50;
|
||||
let currentView = 'groups';
|
||||
let currentGroupId = null;
|
||||
// 页面加载时初始化
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
loadStatistics();
|
||||
loadGroupMessages();
|
||||
loadMessages();
|
||||
});
|
||||
|
||||
// 加载统计信息
|
||||
async function loadStatistics() {
|
||||
try {
|
||||
const response = await fetch('/api/statistics');
|
||||
const data = await response.json();
|
||||
if (data) {
|
||||
const stats = data;
|
||||
document.getElementById('userCount').textContent = stats.user_count;
|
||||
document.getElementById('groupCount').textContent = stats.group_count;
|
||||
document.getElementById('messageCount').textContent = stats.message_count;
|
||||
document.getElementById('fileCount').textContent = stats.file_count;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载统计信息失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 加载按群组分组的消息统计
|
||||
async function loadGroupMessages() {
|
||||
try {
|
||||
const response = await fetch('/api/groups');
|
||||
const data = await response.json();
|
||||
const groupList = document.getElementById('groupList');
|
||||
|
||||
if (data.success) {
|
||||
const groups = data.groups || [];
|
||||
groupList.innerHTML = '';
|
||||
|
||||
if (groups.length === 0) {
|
||||
groupList.innerHTML = '<li>暂无群组</li>';
|
||||
return;
|
||||
} else {
|
||||
currentGroupId = groups[0].id;
|
||||
}
|
||||
|
||||
groups.forEach(group => {
|
||||
const li = document.createElement('li');
|
||||
li.className = 'group-item';
|
||||
li.setAttribute('data-group-id', group.id);
|
||||
li.onclick = () => selectGroup(group.id);
|
||||
|
||||
const groupName = document.createElement('div');
|
||||
groupName.className = 'group-name';
|
||||
groupName.textContent = group.name || group.id;
|
||||
|
||||
const groupInfo = document.createElement('div');
|
||||
groupInfo.className = 'group-info';
|
||||
groupInfo.innerHTML = `
|
||||
<span>创建者: ${group.owner || '未知'}</span>
|
||||
`;
|
||||
|
||||
li.appendChild(groupName);
|
||||
li.appendChild(groupInfo);
|
||||
groupList.appendChild(li);
|
||||
});
|
||||
|
||||
// 默认选择第一个群组
|
||||
if (currentView === 'groups' && groups.length > 0) {
|
||||
selectGroup(groups[0].id);
|
||||
}
|
||||
} else {
|
||||
groupList.innerHTML = '<li>加载失败</li>';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载群组消息失败:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 选择群组
|
||||
function selectGroup(groupId) {
|
||||
currentGroupId = groupId;
|
||||
currentOffset = 0;
|
||||
|
||||
// 更新选中状态
|
||||
document.querySelectorAll('.group-item').forEach(item => {
|
||||
item.classList.remove('active');
|
||||
});
|
||||
|
||||
// 找到对应的群组项并添加选中状态
|
||||
document.querySelectorAll('.group-item').forEach(item => {
|
||||
// 使用data-group-id属性来准确匹配群组
|
||||
if (item.getAttribute('data-group-id') === groupId) {
|
||||
item.classList.add('active');
|
||||
|
||||
// 更新群组信息
|
||||
document.getElementById('currentGroup').textContent = item.querySelector('.group-name').textContent;
|
||||
document.getElementById('messageCountDisplay').textContent = '消息数量: 加载中...';
|
||||
document.getElementById('latestTime').textContent = '最新消息: 加载中...';
|
||||
}
|
||||
});
|
||||
|
||||
// 加载该群组的消息
|
||||
loadMessages();
|
||||
|
||||
// 加载统计信息
|
||||
loadStatistics();
|
||||
}
|
||||
|
||||
|
||||
// 加载更多消息
|
||||
async function loadMoreMessages() {
|
||||
await loadMessages();
|
||||
currentOffset += limit;
|
||||
}
|
||||
|
||||
// 关闭聊天记录模态框
|
||||
function closeChatRecordModal() {
|
||||
document.getElementById('chatRecordModal').style.display = 'none';
|
||||
}
|
||||
|
||||
// 显示聊天记录模态框
|
||||
function showChatRecordModal(chatrecordData) {
|
||||
const modal = document.getElementById('chatRecordModal');
|
||||
const title = document.getElementById('modalTitle');
|
||||
const content = document.getElementById('chatRecordContent');
|
||||
|
||||
// 设置模态框标题
|
||||
if (chatrecordData.chatrecord && chatrecordData.chatrecord.title) {
|
||||
title.textContent = chatrecordData.chatrecord.title;
|
||||
} else {
|
||||
title.textContent = '聊天记录';
|
||||
}
|
||||
|
||||
// 渲染聊天记录内容
|
||||
renderChatRecordContent(chatrecordData, content);
|
||||
|
||||
modal.style.display = 'block';
|
||||
}
|
||||
|
||||
// 渲染聊天记录内容
|
||||
function renderChatRecordContent(chatrecordData, contentElement) {
|
||||
try {
|
||||
if (!chatrecordData.chatrecord || !chatrecordData.chatrecord.item) {
|
||||
contentElement.innerHTML = '<div class="error">聊天记录数据格式错误</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
const chatItems = chatrecordData.chatrecord.item;
|
||||
|
||||
if (!Array.isArray(chatItems) || chatItems.length === 0) {
|
||||
contentElement.innerHTML = '<div class="error">暂无聊天记录内容</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
let html = '';
|
||||
chatItems.forEach(item => {
|
||||
// 处理不同类型的聊天记录项
|
||||
let contentHtml = '';
|
||||
|
||||
if (item.type === 'ChatRecordText') {
|
||||
// 文本消息
|
||||
try {
|
||||
const contentData = JSON.parse(item.content);
|
||||
contentHtml = contentData.content || item.content || '';
|
||||
} catch (e) {
|
||||
contentHtml = item.content || '';
|
||||
}
|
||||
} else if (item.type === 'ChatRecordImage') {
|
||||
// 图片消息
|
||||
contentHtml = '<div class="chat-record-image">[图片消息]</div>';
|
||||
} else {
|
||||
// 其他类型消息
|
||||
contentHtml = `[${item.type}] ${item.content || ''}`;
|
||||
}
|
||||
|
||||
html += `
|
||||
<div class="chat-record-item">
|
||||
<div class="chat-record-sender">${item.from_chatroom ? '群聊' : '私聊'}</div>
|
||||
<div class="chat-record-text">${contentHtml}</div>
|
||||
<div class="chat-record-time">${new Date(item.msgtime * 1000).toLocaleString()}</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
contentElement.innerHTML = html;
|
||||
} catch (error) {
|
||||
console.error('渲染聊天记录失败:', error);
|
||||
contentElement.innerHTML = '<div class="error">渲染聊天记录失败: ' + error.message + '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// 加载消息
|
||||
async function loadMessages() {
|
||||
try {
|
||||
const chatMessages = document.getElementById('chatMessages');
|
||||
if (!currentGroupId) {
|
||||
chatMessages.innerHTML = '<div class="loading">暂无消息</div>';
|
||||
return;
|
||||
}
|
||||
let url = `/api/group_messages?limit=${limit}&offset=${currentOffset}&group_id=${currentGroupId}`;
|
||||
|
||||
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
const messages = data.messages || [];
|
||||
|
||||
if (currentOffset === 0) {
|
||||
chatMessages.innerHTML = '';
|
||||
}
|
||||
|
||||
if (messages.length === 0) {
|
||||
if (currentOffset === 0) {
|
||||
chatMessages.innerHTML = '<div class="loading">暂无消息</div>';
|
||||
document.getElementById('messageCountDisplay').textContent = `消息数量: 0`;
|
||||
document.getElementById('latestTime').textContent = `最新消息: 暂无`;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
messages.forEach(message => {
|
||||
const messageDiv = createMessageElement(message);
|
||||
if (currentOffset === 0) {
|
||||
chatMessages.appendChild(messageDiv);
|
||||
} else {
|
||||
// 加载更多消息时,插入到现有消息的前面
|
||||
chatMessages.insertBefore(messageDiv, chatMessages.firstChild);
|
||||
}
|
||||
});
|
||||
currentOffset += limit;
|
||||
|
||||
|
||||
document.getElementById('messageCountDisplay').textContent = `消息数量: ${data.total || 0}`;
|
||||
document.getElementById('latestTime').textContent = `最新消息: ${data.lastest_time || '暂无'}`;
|
||||
|
||||
|
||||
} else {
|
||||
chatMessages.innerHTML = '<div class="error">加载消息失败</div>';
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('加载消息失败:', error);
|
||||
document.getElementById('chatMessages').innerHTML = '<div class="error">加载消息失败: ' + error.message + '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// 创建消息元素
|
||||
function createMessageElement(message) {
|
||||
const messageDiv = document.createElement('div');
|
||||
messageDiv.className = 'message';
|
||||
|
||||
// 判断是否为自己的消息
|
||||
if (message.is_own) {
|
||||
messageDiv.classList.add('own');
|
||||
}
|
||||
|
||||
const avatar = document.createElement('div');
|
||||
avatar.className = 'avatar';
|
||||
avatar.textContent = message.sender_name ? message.sender_name.charAt(0).toUpperCase() : 'U';
|
||||
|
||||
const contentDiv = document.createElement('div');
|
||||
contentDiv.className = 'message-content';
|
||||
|
||||
const senderDiv = document.createElement('div');
|
||||
senderDiv.className = 'message-sender';
|
||||
senderDiv.textContent = message.sender_name || '未知用户';
|
||||
|
||||
const textDiv = document.createElement('div');
|
||||
textDiv.className = 'message-text';
|
||||
|
||||
// 处理消息内容
|
||||
if (message.content) {
|
||||
if (message.type === 'chatrecord' && message.chatrecord_data) {
|
||||
const chatrecordBtn = document.createElement('button');
|
||||
chatrecordBtn.className = 'chatrecord-btn';
|
||||
chatrecordBtn.textContent = message.display_content || '[聊天记录]';
|
||||
chatrecordBtn.onclick = () => showChatRecordModal(message.chatrecord_data);
|
||||
textDiv.appendChild(chatrecordBtn);
|
||||
} else {
|
||||
textDiv.textContent = message.display_content;
|
||||
}
|
||||
} else {
|
||||
textDiv.textContent = '[空消息]';
|
||||
}
|
||||
|
||||
const timeDiv = document.createElement('div');
|
||||
timeDiv.className = 'message-time';
|
||||
timeDiv.textContent = message.formatted_time;
|
||||
|
||||
contentDiv.appendChild(senderDiv);
|
||||
contentDiv.appendChild(textDiv);
|
||||
contentDiv.appendChild(timeDiv);
|
||||
|
||||
messageDiv.appendChild(avatar);
|
||||
messageDiv.appendChild(contentDiv);
|
||||
|
||||
return messageDiv;
|
||||
}
|
||||
|
||||
|
||||
// 点击模态框外部关闭
|
||||
window.onclick = function (event) {
|
||||
const modal = document.getElementById('chatRecordModal');
|
||||
if (event.target === modal) {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
}
|
||||
567
static/js/qa.js
Normal file
567
static/js/qa.js
Normal file
@@ -0,0 +1,567 @@
|
||||
let currentQA = null;
|
||||
let selectedQuestions = [];
|
||||
let selectedAnswers = [];
|
||||
|
||||
// 页面加载时获取QA列表
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
loadQAList();
|
||||
});
|
||||
|
||||
// 加载QA列表
|
||||
async function loadQAList() {
|
||||
try {
|
||||
const response = await fetch('/api/qa');
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
// 根据后端API返回的数据结构,data字段包含qa_list
|
||||
const qaList = result.qa_list || [];
|
||||
displayQAList(qaList);
|
||||
} else {
|
||||
alert('加载QA列表失败: ' + result.error);
|
||||
}
|
||||
} catch (error) {
|
||||
alert('加载QA列表时出错: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 显示QA列表
|
||||
async function displayQAList(qaList) {
|
||||
const qaListContainer = document.getElementById('qaList');
|
||||
|
||||
if (qaList.length === 0) {
|
||||
qaListContainer.innerHTML = `
|
||||
<div class="empty-state">
|
||||
<div>📝</div>
|
||||
<h3>暂无QA记录</h3>
|
||||
<p>点击"创建新QA"按钮开始创建第一个问答记录</p>
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取所有消息的详细内容
|
||||
let allMessageIds = [];
|
||||
qaList.forEach(qa => {
|
||||
// 解析JSON格式的question和answer字段
|
||||
let questionIds = [];
|
||||
let answerIds = [];
|
||||
|
||||
try {
|
||||
questionIds = typeof qa.question === 'string' ? JSON.parse(qa.question) : qa.question || [];
|
||||
answerIds = typeof qa.answer === 'string' ? JSON.parse(qa.answer) : qa.answer || [];
|
||||
} catch (e) {
|
||||
console.error('解析QA数据时出错:', e);
|
||||
questionIds = [];
|
||||
answerIds = [];
|
||||
}
|
||||
|
||||
allMessageIds = [...allMessageIds, ...questionIds, ...answerIds];
|
||||
});
|
||||
|
||||
let messageMap = {};
|
||||
if (allMessageIds.length > 0) {
|
||||
try {
|
||||
const response = await fetch('/api/messages_by_ids', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({message_ids: allMessageIds})
|
||||
});
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
result.messages.forEach(msg => {
|
||||
messageMap[msg.id] = msg;
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取消息详情时出错:', error);
|
||||
}
|
||||
}
|
||||
|
||||
qaListContainer.innerHTML = qaList.map(qa => {
|
||||
// 解析JSON格式的question和answer字段
|
||||
let questionIds = [];
|
||||
let answerIds = [];
|
||||
|
||||
try {
|
||||
questionIds = typeof qa.question === 'string' ? JSON.parse(qa.question) : qa.question || [];
|
||||
answerIds = typeof qa.answer === 'string' ? JSON.parse(qa.answer) : qa.answer || [];
|
||||
} catch (e) {
|
||||
console.error('解析QA数据时出错:', e);
|
||||
questionIds = [];
|
||||
answerIds = [];
|
||||
}
|
||||
|
||||
// 获取第一个问题的内容作为显示
|
||||
let questionContent = '暂无问题内容';
|
||||
if (questionIds.length > 0) {
|
||||
const firstQuestionId = questionIds[0];
|
||||
const message = messageMap[firstQuestionId];
|
||||
if (message && message.content) {
|
||||
questionContent = message.content;
|
||||
} else {
|
||||
questionContent = `问题消息ID: ${firstQuestionId}`;
|
||||
}
|
||||
}
|
||||
|
||||
// 截取问题内容,超过30个字用省略号
|
||||
if (questionContent.length > 30) {
|
||||
questionContent = questionContent.substring(0, 30) + '...';
|
||||
}
|
||||
|
||||
return `
|
||||
<div class="qa-item">
|
||||
<div class="qa-header">
|
||||
<div class="qa-id">QA #${qa.id}</div>
|
||||
<div class="qa-group">${qa.groupId || '无群组'}</div>
|
||||
</div>
|
||||
|
||||
<div class="qa-content">
|
||||
<div class="qa-question">
|
||||
<strong>问题:</strong> ${questionContent}
|
||||
</div>
|
||||
<div class="qa-stats">
|
||||
<span class="stat">问题: ${questionIds.length}条</span>
|
||||
<span class="stat">答案: ${answerIds.length}条</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="qa-actions">
|
||||
<button class="btn btn-primary" onclick="previewQA(${qa.id})">预览</button>
|
||||
<button class="btn" onclick="editQA(${qa.id})">编辑</button>
|
||||
<button class="btn btn-danger" onclick="deleteQA(${qa.id})">删除</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('');
|
||||
}
|
||||
|
||||
// 搜索消息
|
||||
async function searchMessages() {
|
||||
const keyword = document.getElementById('searchInput').value.trim();
|
||||
if (!keyword) {
|
||||
alert('请输入搜索关键词');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/search_messages?keyword=${encodeURIComponent(keyword)}`);
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
displaySearchResults(result.messages);
|
||||
} else {
|
||||
alert('搜索失败: ' + result.error);
|
||||
}
|
||||
} catch (error) {
|
||||
alert('搜索时出错: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 显示搜索结果
|
||||
function displaySearchResults(messages) {
|
||||
const qaListContainer = document.getElementById('qaList');
|
||||
|
||||
if (messages.length === 0) {
|
||||
qaListContainer.innerHTML = `
|
||||
<div class="empty-state">
|
||||
<div>🔍</div>
|
||||
<h3>未找到相关消息</h3>
|
||||
<p>请尝试其他搜索关键词</p>
|
||||
</div>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
qaListContainer.innerHTML = messages.map(msg => `
|
||||
<div class="qa-item">
|
||||
<div class="qa-header">
|
||||
<div class="qa-id">消息ID: ${msg.id}</div>
|
||||
<div class="qa-group">${msg.formatted_time || '未知时间'}</div>
|
||||
</div>
|
||||
|
||||
<div class="qa-content">
|
||||
<div class="message-item">
|
||||
<strong>类型:</strong> ${msg.type} |
|
||||
<strong>发送者:</strong> ${msg.sender || '未知'} |
|
||||
<strong>接收者:</strong> ${msg.receiver || '未知'}
|
||||
</div>
|
||||
<div class="message-item" style="margin-top: 10px;">
|
||||
<strong>内容:</strong> ${msg.content || '无内容'}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="qa-actions">
|
||||
<button class="btn btn-primary" onclick="addToQuestion('${msg.id}')">设为问题</button>
|
||||
<button class="btn btn-success" onclick="addToAnswer('${msg.id}')">设为答案</button>
|
||||
</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
// 打开创建模态框
|
||||
function openCreateModal() {
|
||||
currentQA = null;
|
||||
selectedQuestions = [];
|
||||
selectedAnswers = [];
|
||||
|
||||
document.getElementById('modalTitle').textContent = '创建QA记录';
|
||||
document.getElementById('groupId').value = '';
|
||||
updateSelectedMessages();
|
||||
|
||||
document.getElementById('qaModal').style.display = 'block';
|
||||
}
|
||||
|
||||
// 编辑QA
|
||||
async function editQA(qaId) {
|
||||
try {
|
||||
const response = await fetch(`/api/qa/${qaId}`);
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
currentQA = result.qa;
|
||||
selectedQuestions = [...currentQA.question_list];
|
||||
selectedAnswers = [...currentQA.answer_list];
|
||||
|
||||
document.getElementById('modalTitle').textContent = '编辑QA记录';
|
||||
document.getElementById('groupId').value = currentQA.groupId || '';
|
||||
updateSelectedMessages();
|
||||
|
||||
document.getElementById('qaModal').style.display = 'block';
|
||||
} else {
|
||||
alert('加载QA详情失败: ' + result.error);
|
||||
}
|
||||
} catch (error) {
|
||||
alert('加载QA详情时出错: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索问题消息
|
||||
async function searchQuestionMessages() {
|
||||
const keyword = document.getElementById('questionSearch').value.trim();
|
||||
if (!keyword) {
|
||||
document.getElementById('questionResults').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
const groupId = document.getElementById('groupId').value.trim();
|
||||
try {
|
||||
const url = `/api/search_messages?keyword=${encodeURIComponent(keyword)}&limit=20${groupId ? `&group_id=${groupId}` : ''}`;
|
||||
const response = await fetch(url);
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
displayQuestionResults(result.messages);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('搜索问题消息时出错:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 显示问题搜索结果
|
||||
function displayQuestionResults(messages) {
|
||||
const resultsContainer = document.getElementById('questionResults');
|
||||
console.log(messages);
|
||||
resultsContainer.innerHTML = messages.map(msg => `
|
||||
<div class="search-result-item" onclick="selectQuestion('${msg.id}', '${msg.content.replace(/'/g, "\\'").substring(0, 100)}')">
|
||||
<div><strong>ID:</strong> ${msg.id}</div>
|
||||
<div><strong>内容:</strong> ${msg.content ? msg.content.substring(0, 100) + (msg.content.length > 100 ? '...' : '') : '无内容'}</div>
|
||||
<div><strong>时间:</strong> ${msg.formatted_time || '未知'}</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
// 搜索答案消息
|
||||
async function searchAnswerMessages() {
|
||||
const keyword = document.getElementById('answerSearch').value.trim();
|
||||
if (!keyword) {
|
||||
document.getElementById('answerResults').innerHTML = '';
|
||||
return;
|
||||
}
|
||||
const groupId = document.getElementById('groupId').value.trim();
|
||||
|
||||
try {
|
||||
const url = `/api/search_messages?keyword=${encodeURIComponent(keyword)}&limit=20${groupId ? `&group_id=${groupId}` : ''}`;
|
||||
const response = await fetch(url);
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
displayAnswerResults(result.messages);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('搜索答案消息时出错:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 显示答案搜索结果
|
||||
function displayAnswerResults(messages) {
|
||||
const resultsContainer = document.getElementById('answerResults');
|
||||
|
||||
resultsContainer.innerHTML = messages.map(msg => `
|
||||
<div class="search-result-item" onclick="selectAnswer('${msg.id}', '${msg.content.replace(/'/g, "\\'").substring(0, 100)}')">
|
||||
<div><strong>ID:</strong> ${msg.id}</div>
|
||||
<div><strong>内容:</strong> ${msg.content ? msg.content.substring(0, 100) + (msg.content.length > 100 ? '...' : '') : '无内容'}</div>
|
||||
<div><strong>时间:</strong> ${msg.formatted_time || '未知'}</div>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
// 选择问题消息
|
||||
function selectQuestion(messageId, content) {
|
||||
if (!selectedQuestions.includes(messageId)) {
|
||||
selectedQuestions.push(messageId);
|
||||
updateSelectedMessages();
|
||||
}
|
||||
}
|
||||
|
||||
// 选择答案消息
|
||||
function selectAnswer(messageId, content) {
|
||||
if (!selectedAnswers.includes(messageId)) {
|
||||
selectedAnswers.push(messageId);
|
||||
updateSelectedMessages();
|
||||
}
|
||||
}
|
||||
|
||||
// 从搜索结果添加为问题
|
||||
function addToQuestion(messageId) {
|
||||
if (!selectedQuestions.includes(messageId)) {
|
||||
selectedQuestions.push(messageId);
|
||||
alert('已添加到问题列表');
|
||||
}
|
||||
}
|
||||
|
||||
// 从搜索结果添加为答案
|
||||
function addToAnswer(messageId) {
|
||||
if (!selectedAnswers.includes(messageId)) {
|
||||
selectedAnswers.push(messageId);
|
||||
alert('已添加到答案列表');
|
||||
}
|
||||
}
|
||||
|
||||
// 更新已选择的消息显示
|
||||
function updateSelectedMessages() {
|
||||
document.getElementById('selectedQuestions').innerHTML = selectedQuestions.map(id => `
|
||||
<div class="selected-message">
|
||||
<span>消息ID: ${id}</span>
|
||||
<button class="btn btn-danger" onclick="removeQuestion('${id}')" style="padding: 2px 8px; font-size: 12px;">移除</button>
|
||||
</div>
|
||||
`).join('');
|
||||
|
||||
document.getElementById('selectedAnswers').innerHTML = selectedAnswers.map(id => `
|
||||
<div class="selected-message">
|
||||
<span>消息ID: ${id}</span>
|
||||
<button class="btn btn-danger" onclick="removeAnswer('${id}')" style="padding: 2px 8px; font-size: 12px;">移除</button>
|
||||
</div>
|
||||
`).join('');
|
||||
}
|
||||
|
||||
// 移除问题消息
|
||||
function removeQuestion(messageId) {
|
||||
selectedQuestions = selectedQuestions.filter(id => id !== messageId);
|
||||
updateSelectedMessages();
|
||||
}
|
||||
|
||||
// 移除答案消息
|
||||
function removeAnswer(messageId) {
|
||||
selectedAnswers = selectedAnswers.filter(id => id !== messageId);
|
||||
updateSelectedMessages();
|
||||
}
|
||||
|
||||
// 保存QA记录
|
||||
async function saveQA() {
|
||||
const groupId = document.getElementById('groupId').value.trim();
|
||||
|
||||
if (selectedQuestions.length === 0) {
|
||||
alert('请至少选择一个问题消息');
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedAnswers.length === 0) {
|
||||
alert('请至少选择一个答案消息');
|
||||
return;
|
||||
}
|
||||
|
||||
const qaData = {
|
||||
groupId: groupId,
|
||||
question: selectedQuestions,
|
||||
answer: selectedAnswers
|
||||
};
|
||||
|
||||
try {
|
||||
const url = currentQA ? `/api/qa/${currentQA.id}` : '/api/qa';
|
||||
const method = currentQA ? 'PUT' : 'POST';
|
||||
|
||||
const response = await fetch(url, {
|
||||
method: method,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(qaData)
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
alert(currentQA ? 'QA记录更新成功' : 'QA记录创建成功');
|
||||
closeModal();
|
||||
loadQAList();
|
||||
} else {
|
||||
alert('保存失败: ' + result.error);
|
||||
}
|
||||
} catch (error) {
|
||||
alert('保存时出错: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 预览QA
|
||||
async function previewQA(qaId) {
|
||||
try {
|
||||
const response = await fetch(`/api/qa/${qaId}`);
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
displayPreview(result.qa);
|
||||
} else {
|
||||
alert('加载QA详情失败: ' + result.error);
|
||||
}
|
||||
} catch (error) {
|
||||
alert('加载QA详情时出错: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 显示预览
|
||||
async function displayPreview(qa) {
|
||||
const previewContent = document.getElementById('previewContent');
|
||||
// 获取所有消息的详细内容
|
||||
let allMessages = [];
|
||||
const allMessageIds = [...qa.question_list, ...qa.answer_list];
|
||||
|
||||
if (allMessageIds.length > 0) {
|
||||
try {
|
||||
const response = await fetch('/api/messages_by_ids', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({message_ids: allMessageIds})
|
||||
});
|
||||
const result = await response.json();
|
||||
if (result.success) {
|
||||
allMessages = result.messages;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取消息详情时出错:', error);
|
||||
}
|
||||
}
|
||||
|
||||
// 创建消息映射
|
||||
const messageMap = {};
|
||||
allMessages.forEach(msg => {
|
||||
messageMap[msg.id] = msg;
|
||||
});
|
||||
|
||||
// 按时间排序所有消息
|
||||
const sortedMessages = allMessages.sort((a, b) => {
|
||||
return new Date(a.time) - new Date(b.time);
|
||||
});
|
||||
|
||||
previewContent.innerHTML = `
|
||||
<div class="chat-preview">
|
||||
<div class="chat-header">
|
||||
<h3>QA #${qa.id} - 聊天记录预览</h3>
|
||||
<div class="chat-info">群组: ${qa.groupId || '无群组'} | 消息数量: ${sortedMessages.length}</div>
|
||||
</div>
|
||||
|
||||
<div class="chat-container">
|
||||
${sortedMessages.map(msg => {
|
||||
|
||||
const isQuestion = qa.question_list.includes(msg.id);
|
||||
const isAnswer = qa.answer_list.includes(msg.id);
|
||||
const messageType = isQuestion ? 'question' : (isAnswer ? 'answer' : 'other');
|
||||
|
||||
return `
|
||||
<div class="chat-message ${messageType}">
|
||||
<div class="message-avatar">
|
||||
${messageType === 'question' ? '❓' : (messageType === 'answer' ? '💬' : '📝')}
|
||||
</div>
|
||||
<div class="message-content">
|
||||
<div class="message-header">
|
||||
<span class="sender">${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-meta">
|
||||
<span class="message-id">消息ID: ${msg.id}</span>
|
||||
<span class="message-type">类型: ${msg.type || '未知'}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}).join('')}
|
||||
</div>
|
||||
|
||||
<div class="chat-summary">
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">问题数量:</span>
|
||||
<span class="summary-value">${qa.question_list.length}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">答案数量:</span>
|
||||
<span class="summary-value">${qa.answer_list.length}</span>
|
||||
</div>
|
||||
<div class="summary-item">
|
||||
<span class="summary-label">总消息数:</span>
|
||||
<span class="summary-value">${sortedMessages.length}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.getElementById('previewModal').style.display = 'block';
|
||||
}
|
||||
|
||||
// 删除QA
|
||||
async function deleteQA(qaId) {
|
||||
if (!confirm('确定要删除这个QA记录吗?此操作不可恢复。')) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`/api/qa/${qaId}`, {
|
||||
method: 'DELETE'
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
alert('QA记录删除成功');
|
||||
loadQAList();
|
||||
} else {
|
||||
alert('删除失败: ' + result.error);
|
||||
}
|
||||
} catch (error) {
|
||||
alert('删除时出错: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭模态框
|
||||
function closeModal() {
|
||||
document.getElementById('qaModal').style.display = 'none';
|
||||
}
|
||||
|
||||
// 关闭预览模态框
|
||||
function closePreviewModal() {
|
||||
document.getElementById('previewModal').style.display = 'none';
|
||||
}
|
||||
|
||||
// 点击模态框外部关闭
|
||||
window.onclick = function (event) {
|
||||
const modal = document.getElementById('qaModal');
|
||||
const previewModal = document.getElementById('previewModal');
|
||||
|
||||
if (event.target === modal) {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
if (event.target === previewModal) {
|
||||
previewModal.style.display = 'none';
|
||||
}
|
||||
}
|
||||
146
static/js/weekly_report.js
Normal file
146
static/js/weekly_report.js
Normal file
@@ -0,0 +1,146 @@
|
||||
// 设置默认周次为当前周
|
||||
function getCurrentWeek() {
|
||||
const now = new Date();
|
||||
const startOfYear = new Date(now.getFullYear(), 0, 1);
|
||||
const days = Math.floor((now - startOfYear) / (24 * 60 * 60 * 1000));
|
||||
const weekNumber = Math.ceil((days + 1) / 7);
|
||||
return `${now.getFullYear()}-W${weekNumber.toString().padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
// 页面加载时设置默认周次
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.getElementById('week').value = getCurrentWeek();
|
||||
});
|
||||
|
||||
function showLoading() {
|
||||
document.getElementById('loading').style.display = 'block';
|
||||
document.getElementById('report-container').style.display = 'none';
|
||||
document.getElementById('error').style.display = 'none';
|
||||
}
|
||||
|
||||
function hideLoading() {
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
}
|
||||
|
||||
function showError(message) {
|
||||
document.getElementById('error').style.display = 'block';
|
||||
document.getElementById('error').textContent = message;
|
||||
}
|
||||
|
||||
function generateCurrentWeekReport() {
|
||||
document.getElementById('week').value = getCurrentWeek();
|
||||
generateReport();
|
||||
}
|
||||
|
||||
function generateReport() {
|
||||
const week = document.getElementById('week').value;
|
||||
if (!week) {
|
||||
showError('请选择周次');
|
||||
return;
|
||||
}
|
||||
|
||||
// 转换格式:YYYY-WWW 到 YYYY-WW
|
||||
const weekFormatted = week.replace('W', '-W');
|
||||
|
||||
showLoading();
|
||||
|
||||
fetch(`/api/reports/weekly?week=${weekFormatted}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
hideLoading();
|
||||
|
||||
if (data.success) {
|
||||
document.getElementById('report-content').textContent = data.report;
|
||||
document.getElementById('report-container').style.display = 'block';
|
||||
|
||||
// 显示统计数据
|
||||
if (data.statistics) {
|
||||
displayStatistics(data.statistics);
|
||||
document.getElementById('statistics').style.display = 'block';
|
||||
|
||||
// 显示分类图表
|
||||
if (data.statistics.category_breakdown) {
|
||||
displayCategoryChart(data.statistics.category_breakdown);
|
||||
document.getElementById('category-chart').style.display = 'block';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
showError('生成周报失败:' + data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
hideLoading();
|
||||
showError('网络错误:' + error.message);
|
||||
});
|
||||
}
|
||||
|
||||
function displayStatistics(stats) {
|
||||
const statGrid = document.getElementById('stat-grid');
|
||||
statGrid.innerHTML = '';
|
||||
|
||||
const statistics = [
|
||||
{ label: '本周消息量', value: stats.week_message_count, unit: '条' },
|
||||
{ label: '上周消息量', value: stats.last_week_message_count, unit: '条' },
|
||||
{ label: '消息变化率', value: stats.message_change_rate.toFixed(1), unit: '%' },
|
||||
{ label: '本周活跃用户', value: stats.week_active_users, unit: '人' },
|
||||
{ label: '群组数量', value: stats.group_count, unit: '个' },
|
||||
{ label: '成员总数', value: stats.member_count, unit: '人' },
|
||||
{ label: '问答记录数', value: stats.qa_count, unit: '条' }
|
||||
];
|
||||
|
||||
statistics.forEach(stat => {
|
||||
const statItem = document.createElement('div');
|
||||
statItem.className = 'stat-item';
|
||||
statItem.innerHTML = `
|
||||
<div class="stat-value">${stat.value}${stat.unit}</div>
|
||||
<div class="stat-label">${stat.label}</div>
|
||||
`;
|
||||
statGrid.appendChild(statItem);
|
||||
});
|
||||
}
|
||||
|
||||
function displayCategoryChart(categories) {
|
||||
const categoryItems = document.getElementById('category-items');
|
||||
categoryItems.innerHTML = '';
|
||||
|
||||
Object.entries(categories).forEach(([category, percentage]) => {
|
||||
const categoryItem = document.createElement('div');
|
||||
categoryItem.className = 'category-item';
|
||||
categoryItem.innerHTML = `
|
||||
<span style="min-width: 120px;">${category}</span>
|
||||
<div class="category-bar" style="width: ${percentage * 2}px;"></div>
|
||||
<span style="min-width: 40px; text-align: right;">${percentage}%</span>
|
||||
`;
|
||||
categoryItems.appendChild(categoryItem);
|
||||
});
|
||||
}
|
||||
|
||||
function exportReport() {
|
||||
const reportContent = document.getElementById('report-content').textContent;
|
||||
if (!reportContent) {
|
||||
showError('请先生成周报');
|
||||
return;
|
||||
}
|
||||
|
||||
const blob = new Blob([reportContent], { type: 'text/markdown' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `运营周报_${document.getElementById('week').value}.md`;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
// 页面加载时自动生成本周周报
|
||||
window.addEventListener('load', function() {
|
||||
generateCurrentWeekReport();
|
||||
});
|
||||
|
||||
// 支持回车键生成报告
|
||||
document.getElementById('week').addEventListener('keypress', function(e) {
|
||||
if (e.key === 'Enter') {
|
||||
generateReport();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user