You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1617 lines
54 KiB
1617 lines
54 KiB
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, maximum-scale=1.0, minimum-scale=1.0">
|
|
<title>论坛动态审核</title>
|
|
<style>
|
|
/* 全局样式 */
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
background-color: #f0f2f5;
|
|
color: #333;
|
|
line-height: 1.6;
|
|
}
|
|
|
|
/* 容器样式 */
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
}
|
|
|
|
/* 顶部导航栏 */
|
|
.header {
|
|
background: linear-gradient(135deg, #1890ff, #36cfc9);
|
|
color: white;
|
|
padding: 16px 0;
|
|
margin-bottom: 24px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
.header-content {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
padding: 0 20px;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 24px;
|
|
font-weight: 600;
|
|
margin: 0;
|
|
}
|
|
|
|
.header-actions {
|
|
display: flex;
|
|
gap: 12px;
|
|
}
|
|
|
|
.btn {
|
|
padding: 10px 20px;
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
border-radius: 12px;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
backdrop-filter: blur(10px);
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.btn:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
.btn-primary {
|
|
background-color: rgba(255, 255, 255, 0.2);
|
|
color: white;
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background-color: rgba(255, 255, 255, 0.3);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
/* 搜索和过滤区域 */
|
|
.search-filter-section {
|
|
background: white;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.search-filter-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 16px;
|
|
flex-wrap: wrap;
|
|
gap: 12px;
|
|
}
|
|
|
|
.status-filter {
|
|
display: flex;
|
|
gap: 8px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.date-filter {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.date-input {
|
|
padding: 6px 12px;
|
|
border: 1px solid #d9d9d9;
|
|
border-radius: 4px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.btn-filter {
|
|
background-color: rgba(24, 144, 255, 0.9);
|
|
color: white;
|
|
padding: 8px 20px;
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
.btn-filter:hover {
|
|
background-color: rgba(64, 169, 255, 0.9);
|
|
}
|
|
|
|
.btn-reset {
|
|
background-color: rgba(153, 153, 153, 0.9);
|
|
color: white;
|
|
padding: 8px 20px;
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
.btn-reset:hover {
|
|
background-color: rgba(102, 102, 102, 0.9);
|
|
}
|
|
|
|
.filter-btn {
|
|
padding: 6px 16px;
|
|
border: 1px solid #d9d9d9;
|
|
background-color: white;
|
|
color: #666;
|
|
border-radius: 16px;
|
|
font-size: 14px;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.filter-btn.active {
|
|
background-color: #1890ff;
|
|
color: white;
|
|
border-color: #1890ff;
|
|
}
|
|
|
|
.filter-btn:hover:not(.active) {
|
|
border-color: #1890ff;
|
|
color: #1890ff;
|
|
}
|
|
|
|
.search-box {
|
|
display: flex;
|
|
gap: 12px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.search-input {
|
|
flex: 1;
|
|
min-width: 200px;
|
|
padding: 10px 16px;
|
|
border: 1px solid #d9d9d9;
|
|
border-radius: 4px;
|
|
font-size: 14px;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.search-input:focus {
|
|
outline: none;
|
|
border-color: #1890ff;
|
|
box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
|
|
}
|
|
|
|
.btn-search {
|
|
background-color: rgba(24, 144, 255, 0.9);
|
|
color: white;
|
|
padding: 12px 24px;
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
.btn-search:hover {
|
|
background-color: rgba(64, 169, 255, 0.9);
|
|
}
|
|
|
|
.btn-refresh {
|
|
background-color: rgba(82, 196, 26, 0.9);
|
|
color: white;
|
|
padding: 12px 24px;
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
.btn-refresh:hover {
|
|
background-color: rgba(115, 209, 61, 0.9);
|
|
}
|
|
|
|
/* 帖子列表区域 */
|
|
.post-list-section {
|
|
background: white;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
overflow: hidden;
|
|
margin-bottom: 24px;
|
|
width: 100%;
|
|
}
|
|
|
|
.post-header {
|
|
padding: 16px 20px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
background-color: #fafafa;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
|
|
.post-header h2 {
|
|
font-size: 16px;
|
|
font-weight: 600;
|
|
margin: 0;
|
|
color: #333;
|
|
}
|
|
|
|
.post-stats {
|
|
font-size: 14px;
|
|
color: #666;
|
|
}
|
|
|
|
.post-list {
|
|
/* 取消内部滚轮,使用外部滚轮 */
|
|
}
|
|
|
|
/* 序号样式 */
|
|
.post-index {
|
|
font-size: 14px;
|
|
color: #666;
|
|
font-weight: 500;
|
|
min-width: 60px;
|
|
text-align: left;
|
|
margin-right: 16px;
|
|
padding-top: 2px;
|
|
border-right: 1px solid #e8e8e8;
|
|
padding-right: 16px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
/* 勾选框样式 */
|
|
.post-checkbox {
|
|
margin: 0;
|
|
width: 16px;
|
|
height: 16px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.post-checkbox:disabled {
|
|
cursor: not-allowed;
|
|
opacity: 0.5;
|
|
}
|
|
|
|
.post-item {
|
|
padding: 20px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
transition: all 0.3s ease;
|
|
border-radius: 8px;
|
|
margin-bottom: 12px;
|
|
background-color: white;
|
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
.post-item:hover {
|
|
background-color: #fafafa;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.post-item:last-child {
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.post-meta {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.post-info {
|
|
flex: 1;
|
|
}
|
|
|
|
.post-author {
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
color: #333;
|
|
margin-bottom: 8px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
}
|
|
|
|
.post-details {
|
|
font-size: 12px;
|
|
color: #999;
|
|
display: flex;
|
|
gap: 16px;
|
|
flex-wrap: wrap;
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.post-content {
|
|
font-size: 14px;
|
|
line-height: 1.5;
|
|
color: #333;
|
|
margin-bottom: 16px;
|
|
white-space: pre-wrap;
|
|
word-break: break-word;
|
|
padding-left: 52px;
|
|
}
|
|
|
|
.post-images {
|
|
display: flex;
|
|
gap: 8px;
|
|
flex-wrap: wrap;
|
|
margin-bottom: 16px;
|
|
padding-left: 52px;
|
|
}
|
|
|
|
.post-image {
|
|
width: 80px;
|
|
height: 80px;
|
|
object-fit: cover;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
transition: transform 0.3s ease;
|
|
}
|
|
|
|
.post-image:hover {
|
|
transform: scale(1.05);
|
|
}
|
|
|
|
.post-topic {
|
|
display: inline-block;
|
|
padding: 4px 12px;
|
|
background-color: #f0f9ff;
|
|
color: #1890ff;
|
|
border-radius: 12px;
|
|
font-size: 12px;
|
|
margin-left: 52px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.post-actions {
|
|
display: flex;
|
|
gap: 12px;
|
|
align-items: center;
|
|
padding-left: 52px;
|
|
}
|
|
|
|
.btn-approve {
|
|
background-color: rgba(82, 196, 26, 0.9);
|
|
color: white;
|
|
padding: 8px 20px;
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
.btn-approve:hover {
|
|
background-color: rgba(115, 209, 61, 0.9);
|
|
}
|
|
|
|
.btn-reject {
|
|
background-color: rgba(255, 77, 79, 0.9);
|
|
color: white;
|
|
padding: 8px 20px;
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
.btn-reject:hover {
|
|
background-color: rgba(255, 120, 117, 0.9);
|
|
}
|
|
|
|
.btn-details {
|
|
background-color: rgba(24, 144, 255, 0.9);
|
|
color: white;
|
|
padding: 8px 20px;
|
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
}
|
|
|
|
.btn-details:hover {
|
|
background-color: rgba(64, 169, 255, 0.9);
|
|
}
|
|
|
|
/* 状态标签 */
|
|
.status-tag {
|
|
padding: 2px 8px;
|
|
border-radius: 10px;
|
|
font-size: 12px;
|
|
font-weight: 500;
|
|
color: white;
|
|
display: inline-block;
|
|
}
|
|
|
|
.status-pending {
|
|
background-color: #faad14;
|
|
}
|
|
|
|
.status-approved {
|
|
background-color: #52c41a;
|
|
}
|
|
|
|
.status-rejected {
|
|
background-color: #ff4d4f;
|
|
}
|
|
|
|
/* 空状态 */
|
|
.empty-state {
|
|
padding: 60px 20px;
|
|
text-align: center;
|
|
color: #999;
|
|
}
|
|
|
|
.empty-icon {
|
|
font-size: 48px;
|
|
margin-bottom: 16px;
|
|
color: #d9d9d9;
|
|
}
|
|
|
|
.empty-state h3 {
|
|
margin: 0 0 8px 0;
|
|
color: #333;
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
/* 加载状态 */
|
|
.loading-state {
|
|
padding: 40px 20px;
|
|
text-align: center;
|
|
color: #1890ff;
|
|
}
|
|
|
|
/* 分页区域 */
|
|
.pagination-section {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
gap: 8px;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
/* 页面大小选择器 */
|
|
.page-size-selector {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
margin-right: 20px;
|
|
}
|
|
|
|
.page-size-selector label {
|
|
font-size: 14px;
|
|
color: #666;
|
|
}
|
|
|
|
.page-size-selector select {
|
|
padding: 4px 8px;
|
|
border: 1px solid #d9d9d9;
|
|
border-radius: 4px;
|
|
font-size: 14px;
|
|
color: #666;
|
|
}
|
|
|
|
.page-btn {
|
|
padding: 6px 12px;
|
|
border: 1px solid #d9d9d9;
|
|
background-color: white;
|
|
color: #666;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.page-btn:hover:not(:disabled) {
|
|
border-color: #1890ff;
|
|
color: #1890ff;
|
|
}
|
|
|
|
.page-btn.active {
|
|
background-color: #1890ff;
|
|
color: white;
|
|
border-color: #1890ff;
|
|
}
|
|
|
|
.page-btn:disabled {
|
|
opacity: 0.5;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
/* 详情弹窗 */
|
|
.modal {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background-color: rgba(0, 0, 0, 0.6);
|
|
backdrop-filter: blur(4px);
|
|
display: none;
|
|
justify-content: center;
|
|
align-items: center;
|
|
z-index: 1000;
|
|
}
|
|
|
|
.modal-content {
|
|
background-color: white;
|
|
border-radius: 16px;
|
|
width: 92%;
|
|
max-width: 720px;
|
|
max-height: 90vh;
|
|
overflow: hidden;
|
|
box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
|
|
animation: modalFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
@keyframes modalFadeIn {
|
|
from {
|
|
opacity: 0;
|
|
transform: translateY(-30px) scale(0.92);
|
|
}
|
|
to {
|
|
opacity: 1;
|
|
transform: translateY(0) scale(1);
|
|
}
|
|
}
|
|
|
|
.modal-header {
|
|
padding: 24px 32px;
|
|
border-bottom: 1px solid #f0f0f0;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
background: linear-gradient(135deg, #f8f9fa, #ffffff);
|
|
border-radius: 16px 16px 0 0;
|
|
}
|
|
|
|
.modal-title {
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
margin: 0;
|
|
color: #333;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
}
|
|
|
|
.modal-title::before {
|
|
content: "📝";
|
|
font-size: 22px;
|
|
}
|
|
|
|
.modal-close {
|
|
background: none;
|
|
border: none;
|
|
font-size: 28px;
|
|
cursor: pointer;
|
|
color: #999;
|
|
padding: 0;
|
|
width: 36px;
|
|
height: 36px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: 50%;
|
|
transition: all 0.3s ease;
|
|
line-height: 1;
|
|
}
|
|
|
|
.modal-close:hover {
|
|
background-color: #f0f0f0;
|
|
color: #333;
|
|
transform: rotate(90deg);
|
|
}
|
|
|
|
.modal-body {
|
|
padding: 32px;
|
|
overflow-y: auto;
|
|
flex: 1;
|
|
}
|
|
|
|
.detail-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
|
gap: 24px;
|
|
margin-bottom: 32px;
|
|
}
|
|
|
|
.detail-card {
|
|
background: linear-gradient(135deg, #f8f9fa, #ffffff);
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
transition: all 0.3s ease;
|
|
border: 1px solid #e8e8e8;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
.detail-card:hover {
|
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.detail-label {
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: #666;
|
|
margin-bottom: 10px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.detail-label::before {
|
|
content: "•";
|
|
color: #1890ff;
|
|
font-size: 16px;
|
|
}
|
|
|
|
.detail-value {
|
|
font-size: 15px;
|
|
color: #333;
|
|
line-height: 1.5;
|
|
font-weight: 400;
|
|
}
|
|
|
|
.detail-content-section {
|
|
margin-top: 32px;
|
|
}
|
|
|
|
.content-card {
|
|
background: linear-gradient(135deg, #f8f9fa, #ffffff);
|
|
border-radius: 12px;
|
|
padding: 24px;
|
|
border: 1px solid #e8e8e8;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
.content-label {
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
color: #333;
|
|
margin-bottom: 16px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.content-label::before {
|
|
content: "💬";
|
|
font-size: 18px;
|
|
}
|
|
|
|
.content-value {
|
|
font-size: 15px;
|
|
color: #333;
|
|
line-height: 1.7;
|
|
white-space: pre-wrap;
|
|
word-break: break-word;
|
|
padding: 16px;
|
|
background-color: #ffffff;
|
|
border-radius: 8px;
|
|
border: 1px solid #f0f0f0;
|
|
}
|
|
|
|
.detail-images {
|
|
display: flex;
|
|
gap: 12px;
|
|
flex-wrap: wrap;
|
|
margin-top: 16px;
|
|
}
|
|
|
|
.detail-image {
|
|
width: 120px;
|
|
height: 120px;
|
|
object-fit: cover;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
transition: transform 0.3s ease;
|
|
}
|
|
|
|
.detail-image:hover {
|
|
transform: scale(1.05);
|
|
}
|
|
|
|
.status-tag-large {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 8px 20px;
|
|
border-radius: 20px;
|
|
font-size: 14px;
|
|
font-weight: 600;
|
|
color: white;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.status-pending-large {
|
|
background-color: #faad14;
|
|
}
|
|
|
|
.status-pending-large::before {
|
|
content: "⏳";
|
|
}
|
|
|
|
.status-approved-large {
|
|
background-color: #52c41a;
|
|
}
|
|
|
|
.status-approved-large::before {
|
|
content: "✅";
|
|
}
|
|
|
|
.status-rejected-large {
|
|
background-color: #ff4d4f;
|
|
}
|
|
|
|
.status-rejected-large::before {
|
|
content: "❌";
|
|
}
|
|
|
|
/* 图片预览弹窗 */
|
|
.image-modal {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background-color: rgba(0, 0, 0, 0.9);
|
|
display: none;
|
|
justify-content: center;
|
|
align-items: center;
|
|
z-index: 2000;
|
|
}
|
|
|
|
.image-modal-content {
|
|
position: relative;
|
|
max-width: 90%;
|
|
max-height: 90vh;
|
|
}
|
|
|
|
.image-modal img {
|
|
max-width: 100%;
|
|
max-height: 90vh;
|
|
object-fit: contain;
|
|
}
|
|
|
|
.image-modal-close {
|
|
position: absolute;
|
|
top: -40px;
|
|
right: 0;
|
|
background: none;
|
|
border: none;
|
|
font-size: 32px;
|
|
color: white;
|
|
cursor: pointer;
|
|
}
|
|
|
|
/* 滚动条样式 */
|
|
.modal-body::-webkit-scrollbar {
|
|
width: 8px;
|
|
}
|
|
|
|
.modal-body::-webkit-scrollbar-track {
|
|
background: #f1f1f1;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.modal-body::-webkit-scrollbar-thumb {
|
|
background: #c1c1c1;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.modal-body::-webkit-scrollbar-thumb:hover {
|
|
background: #a8a8a8;
|
|
}
|
|
|
|
/* 响应式设计 */
|
|
@media (max-width: 768px) {
|
|
.container {
|
|
padding: 12px;
|
|
}
|
|
|
|
.header h1 {
|
|
font-size: 20px;
|
|
}
|
|
|
|
.search-box {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.search-input {
|
|
min-width: auto;
|
|
}
|
|
|
|
.post-meta {
|
|
flex-direction: column;
|
|
align-items: flex-start;
|
|
gap: 8px;
|
|
}
|
|
|
|
.post-actions {
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.status-filter {
|
|
overflow-x: auto;
|
|
padding-bottom: 8px;
|
|
}
|
|
|
|
.filter-btn {
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.pagination-section {
|
|
justify-content: center;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<!-- 顶部导航栏 -->
|
|
<div class="header">
|
|
<div class="header-content">
|
|
<h1>论坛动态审核</h1>
|
|
<div class="header-actions">
|
|
<button class="btn btn-primary" onclick="window.location.href='admin.html'">返回管理后台</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<!-- 搜索和过滤区域 -->
|
|
<div class="search-filter-section">
|
|
<div class="search-filter-header">
|
|
<div class="status-filter">
|
|
<button class="filter-btn" data-status="all">全部</button>
|
|
<button class="filter-btn active" data-status="pending">待审核</button>
|
|
<button class="filter-btn" data-status="approved">已通过</button>
|
|
<button class="filter-btn" data-status="rejected">已拒绝</button>
|
|
</div>
|
|
<div class="date-filter">
|
|
<span>创建时间:</span>
|
|
<input type="date" class="date-input" id="startDateInput" placeholder="开始日期">
|
|
<span>至</span>
|
|
<input type="date" class="date-input" id="endDateInput" placeholder="结束日期">
|
|
<button class="btn btn-filter" onclick="handleDateFilter()">筛选</button>
|
|
<button class="btn btn-reset" onclick="resetDateFilter()">重置</button>
|
|
</div>
|
|
</div>
|
|
<div class="search-box">
|
|
<input type="text" class="search-input" id="searchInput" placeholder="搜索动态内容...">
|
|
<input type="text" class="search-input" id="phoneInput" placeholder="按手机号搜索...">
|
|
<button class="btn btn-search" onclick="handleSearch()">搜索</button>
|
|
<button class="btn btn-refresh" onclick="refreshPosts()">刷新</button>
|
|
<button class="btn btn-approve" onclick="batchApprovePosts()">批量通过</button>
|
|
<button class="btn btn-reject" onclick="batchRejectPosts()">批量拒绝</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 帖子列表区域 -->
|
|
<div class="post-list-section">
|
|
<div class="post-header">
|
|
<div style="display: flex; align-items: center; gap: 16px;">
|
|
<h2>论坛动态列表</h2>
|
|
<div style="display: flex; align-items: center; gap: 8px;">
|
|
<input type="checkbox" id="selectAllCheckbox" style="width: 16px; height: 16px; cursor: pointer;">
|
|
<label for="selectAllCheckbox" style="cursor: pointer; font-size: 14px;">全选</label>
|
|
<span id="selectedCount" style="font-size: 14px; color: #666;">已选中 0 条</span>
|
|
</div>
|
|
</div>
|
|
<div class="post-stats">
|
|
<span id="totalPosts">共 0 条</span>
|
|
<span id="pendingPosts" style="margin-left: 16px;">待审核: 0</span>
|
|
</div>
|
|
</div>
|
|
<div class="post-list" id="postList">
|
|
<div class="loading-state">
|
|
<div>加载中...</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 分页区域 -->
|
|
<div class="pagination-section" id="pagination">
|
|
<div class="page-size-selector">
|
|
<label for="pageSizeSelect">每页显示:</label>
|
|
<select id="pageSizeSelect" onchange="changePageSize(this.value)">
|
|
<option value="10" selected>10条</option>
|
|
<option value="30">30条</option>
|
|
<option value="50">50条</option>
|
|
<option value="100">100条</option>
|
|
</select>
|
|
</div>
|
|
<!-- 分页按钮将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 详情弹窗 -->
|
|
<div class="modal" id="detailModal">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h3 class="modal-title">动态详情</h3>
|
|
<button class="modal-close" onclick="closeDetailModal()">×</button>
|
|
</div>
|
|
<div class="modal-body" id="detailContent">
|
|
<!-- 详情内容将通过JavaScript动态生成 -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 图片预览弹窗 -->
|
|
<div class="image-modal" id="imageModal">
|
|
<div class="image-modal-content">
|
|
<button class="image-modal-close" onclick="closeImageModal()">×</button>
|
|
<img id="previewImage" src="" alt="预览图片">
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// 全局变量
|
|
let posts = [];
|
|
let filteredPosts = [];
|
|
let currentPage = 1;
|
|
let pageSize = 10;
|
|
let currentStatus = 'pending';
|
|
let totalPosts = 0;
|
|
let startDate = '';
|
|
let endDate = '';
|
|
|
|
// 缓存对象
|
|
const postCache = {
|
|
// 缓存结构: { status: { startDate: { endDate: { pageSize: { page: data } } } } }
|
|
};
|
|
|
|
// 缓存有效期 (毫秒)
|
|
const CACHE_EXPIRY = 5 * 60 * 1000; // 5分钟
|
|
|
|
// 登录检查
|
|
function checkLogin() {
|
|
const loginInfo = localStorage.getItem('loginInfo');
|
|
|
|
if (!loginInfo) {
|
|
window.location.href = 'login.html';
|
|
return false;
|
|
}
|
|
|
|
const parsedLoginInfo = JSON.parse(loginInfo);
|
|
|
|
// 检查是否为管理员
|
|
if (parsedLoginInfo.projectName !== '管理员') {
|
|
alert('权限不足,只有管理员可以访问此页面');
|
|
window.location.href = 'login.html';
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
// 检查缓存是否有效
|
|
function isCacheValid(cacheEntry) {
|
|
return cacheEntry && cacheEntry.timestamp && (Date.now() - cacheEntry.timestamp) < CACHE_EXPIRY;
|
|
}
|
|
|
|
// 加载帖子数据
|
|
async function loadPosts() {
|
|
const postListEl = document.getElementById('postList');
|
|
postListEl.innerHTML = '<div class="loading-state"><div>加载中...</div></div>';
|
|
|
|
try {
|
|
const searchKeyword = document.getElementById('searchInput').value.trim();
|
|
const phoneKeyword = document.getElementById('phoneInput').value.trim();
|
|
|
|
// 构建缓存键
|
|
const cacheKey = `${currentStatus}_${startDate || 'none'}_${endDate || 'none'}_${searchKeyword || 'none'}_${phoneKeyword || 'none'}`;
|
|
|
|
// 检查缓存
|
|
if (postCache[cacheKey] && postCache[cacheKey][pageSize] && postCache[cacheKey][pageSize][currentPage] && isCacheValid(postCache[cacheKey][pageSize][currentPage])) {
|
|
const cachedData = postCache[cacheKey][pageSize][currentPage];
|
|
posts = cachedData.posts;
|
|
totalPosts = cachedData.total;
|
|
const pendingTotal = cachedData.pendingTotal || 0;
|
|
|
|
// 更新统计信息
|
|
updatePostStats(pendingTotal);
|
|
|
|
// 显示帖子
|
|
displayPosts();
|
|
return;
|
|
}
|
|
|
|
// 构建查询参数
|
|
let queryParams = new URLSearchParams();
|
|
|
|
if (currentStatus !== 'all') {
|
|
let statusMap = {
|
|
'pending': 0,
|
|
'approved': 1,
|
|
'rejected': 2
|
|
};
|
|
queryParams.append('status', statusMap[currentStatus]);
|
|
}
|
|
|
|
if (startDate) {
|
|
queryParams.append('startDate', startDate);
|
|
}
|
|
|
|
if (endDate) {
|
|
queryParams.append('endDate', endDate);
|
|
}
|
|
|
|
if (searchKeyword || phoneKeyword) {
|
|
queryParams.append('search', searchKeyword || phoneKeyword);
|
|
}
|
|
|
|
queryParams.append('page', currentPage);
|
|
queryParams.append('pageSize', pageSize);
|
|
|
|
// 调用后端API获取帖子数据
|
|
const response = await fetch(`/api/forum-posts?${queryParams.toString()}`);
|
|
const data = await response.json();
|
|
|
|
if (data.success) {
|
|
posts = data.posts.map(post => ({
|
|
id: post.id,
|
|
user_id: post.user_id,
|
|
content: post.content,
|
|
images: post.images,
|
|
topic: post.topic,
|
|
likes: post.likes || 0,
|
|
comments: post.comments || 0,
|
|
shares: post.shares || 0,
|
|
created_at: post.created_at,
|
|
phone: post.phone,
|
|
status: post.status
|
|
}));
|
|
|
|
totalPosts = data.total;
|
|
const pendingTotal = data.pendingTotal || 0;
|
|
|
|
// 更新缓存
|
|
if (!postCache[cacheKey]) {
|
|
postCache[cacheKey] = {};
|
|
}
|
|
if (!postCache[cacheKey][pageSize]) {
|
|
postCache[cacheKey][pageSize] = {};
|
|
}
|
|
postCache[cacheKey][pageSize][currentPage] = {
|
|
posts: [...posts],
|
|
total: totalPosts,
|
|
pendingTotal: pendingTotal,
|
|
timestamp: Date.now()
|
|
};
|
|
|
|
// 更新统计信息
|
|
updatePostStats(pendingTotal);
|
|
|
|
// 显示帖子
|
|
displayPosts();
|
|
} else {
|
|
console.error('加载帖子失败:', data.message);
|
|
postListEl.innerHTML = '<div class="empty-state"><div class="empty-icon">⚠️</div><h3>加载失败</h3><p>无法加载帖子数据,请稍后重试</p></div>';
|
|
}
|
|
} catch (error) {
|
|
console.error('加载帖子失败:', error);
|
|
postListEl.innerHTML = '<div class="empty-state"><div class="empty-icon">⚠️</div><h3>加载失败</h3><p>无法加载帖子数据,请稍后重试</p></div>';
|
|
}
|
|
}
|
|
|
|
// 更新帖子统计信息
|
|
function updatePostStats(pendingTotal) {
|
|
document.getElementById('totalPosts').textContent = `共 ${totalPosts} 条`;
|
|
|
|
// 只有在全部和待审核标签页中显示待审核数量
|
|
if (currentStatus === 'all' || currentStatus === 'pending') {
|
|
document.getElementById('pendingPosts').textContent = `待审核: ${pendingTotal}`;
|
|
document.getElementById('pendingPosts').style.display = 'inline';
|
|
} else {
|
|
document.getElementById('pendingPosts').style.display = 'none';
|
|
}
|
|
}
|
|
|
|
// 过滤帖子(现在主要通过API参数过滤,前端过滤作为补充)
|
|
function filterPosts() {
|
|
// 由于我们现在通过API参数进行过滤,这里只需要调用loadPosts
|
|
loadPosts();
|
|
}
|
|
|
|
// 显示帖子
|
|
function displayPosts() {
|
|
const postListEl = document.getElementById('postList');
|
|
|
|
if (posts.length === 0) {
|
|
postListEl.innerHTML = '<div class="empty-state"><div class="empty-icon">📝</div><h3>暂无动态</h3><p>没有找到符合条件的论坛动态</p></div>';
|
|
} else {
|
|
postListEl.innerHTML = posts.map((post, index) => {
|
|
let statusClass = 'status-pending';
|
|
let statusText = '待审核';
|
|
|
|
if (post.status === 1) {
|
|
statusClass = 'status-approved';
|
|
statusText = '已通过';
|
|
} else if (post.status === 2) {
|
|
statusClass = 'status-rejected';
|
|
statusText = '已拒绝';
|
|
}
|
|
|
|
// 计算序号,考虑分页
|
|
const serialNumber = (currentPage - 1) * pageSize + (index + 1);
|
|
|
|
// 处理图片
|
|
let imagesHtml = '';
|
|
if (post.images) {
|
|
try {
|
|
const images = typeof post.images === 'string' ? JSON.parse(post.images) : post.images;
|
|
if (Array.isArray(images) && images.length > 0) {
|
|
imagesHtml = images.map((image, imgIndex) => `
|
|
<img src="${image}" alt="图片 ${imgIndex + 1}" class="post-image" onclick="showImagePreview('${image}')">
|
|
`).join('');
|
|
}
|
|
} catch (e) {
|
|
console.error('解析图片数据失败:', e);
|
|
}
|
|
}
|
|
|
|
return `
|
|
<div class="post-item">
|
|
<div class="post-meta">
|
|
<div class="post-index">
|
|
<input type="checkbox" class="post-checkbox" data-id="${post.id}" ${(post.status === 0 || post.status === null) ? '' : 'disabled'}>
|
|
${serialNumber}
|
|
</div>
|
|
<div class="post-info">
|
|
<div class="post-author">
|
|
${post.phone || '未知用户'}
|
|
<span class="status-tag ${statusClass}">${statusText}</span>
|
|
</div>
|
|
<div class="post-details">
|
|
<span>用户ID: ${post.user_id}</span>
|
|
<span>创建时间: ${formatDateTime(post.created_at)}</span>
|
|
<span>点赞: ${post.likes}</span>
|
|
<span>评论: ${post.comments}</span>
|
|
<span>分享: ${post.shares}</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="post-content">${post.content}</div>
|
|
${imagesHtml ? `<div class="post-images">${imagesHtml}</div>` : ''}
|
|
${post.topic ? `<div class="post-topic">#${post.topic}</div>` : ''}
|
|
<div class="post-actions">
|
|
${post.status === 0 || post.status === null ? `
|
|
<button class="btn btn-approve" onclick="approvePost(${post.id})">审核通过</button>
|
|
<button class="btn btn-reject" onclick="rejectPost(${post.id})">审核拒绝</button>
|
|
` : ''}
|
|
<button class="btn btn-details" onclick="showPostDetail(${post.id})">查看详情</button>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}).join('');
|
|
}
|
|
|
|
// 更新分页
|
|
updatePagination();
|
|
|
|
// 更新全选按钮状态
|
|
updateSelectAllStatus();
|
|
}
|
|
|
|
// 更新分页
|
|
function updatePagination() {
|
|
const paginationEl = document.getElementById('pagination');
|
|
const totalPages = Math.ceil(totalPosts / pageSize);
|
|
|
|
if (totalPages <= 1) {
|
|
paginationEl.innerHTML = '<div class="page-size-selector"><label for="pageSizeSelect">每页显示:</label><select id="pageSizeSelect" onchange="changePageSize(this.value)"><option value="10" ' + (pageSize === 10 ? 'selected' : '') + '>10条</option><option value="30" ' + (pageSize === 30 ? 'selected' : '') + '>30条</option><option value="50" ' + (pageSize === 50 ? 'selected' : '') + '>50条</option><option value="100" ' + (pageSize === 100 ? 'selected' : '') + '>100条</option></select></div>';
|
|
return;
|
|
}
|
|
|
|
// 构建页面大小选择器
|
|
const pageSizeSelector = '<div class="page-size-selector"><label for="pageSizeSelect">每页显示:</label><select id="pageSizeSelect" onchange="changePageSize(this.value)"><option value="10" ' + (pageSize === 10 ? 'selected' : '') + '>10条</option><option value="30" ' + (pageSize === 30 ? 'selected' : '') + '>30条</option><option value="50" ' + (pageSize === 50 ? 'selected' : '') + '>50条</option><option value="100" ' + (pageSize === 100 ? 'selected' : '') + '>100条</option></select></div>';
|
|
|
|
let paginationHTML = pageSizeSelector;
|
|
|
|
// 上一页
|
|
paginationHTML += `<button class="page-btn" onclick="changePage(${currentPage - 1})" ${currentPage === 1 ? 'disabled' : ''}>上一页</button>`;
|
|
|
|
// 页码
|
|
const startPage = Math.max(1, currentPage - 2);
|
|
const endPage = Math.min(totalPages, startPage + 4);
|
|
|
|
for (let i = startPage; i <= endPage; i++) {
|
|
paginationHTML += `<button class="page-btn ${currentPage === i ? 'active' : ''}" onclick="changePage(${i})">${i}</button>`;
|
|
}
|
|
|
|
// 下一页
|
|
paginationHTML += `<button class="page-btn" onclick="changePage(${currentPage + 1})" ${currentPage === totalPages ? 'disabled' : ''}>下一页</button>`;
|
|
|
|
paginationEl.innerHTML = paginationHTML;
|
|
}
|
|
|
|
// 更改页码
|
|
function changePage(page) {
|
|
const totalPages = Math.ceil(totalPosts / pageSize);
|
|
if (page < 1 || page > totalPages) {
|
|
return;
|
|
}
|
|
currentPage = page;
|
|
loadPosts();
|
|
}
|
|
|
|
// 处理搜索
|
|
function handleSearch() {
|
|
currentPage = 1;
|
|
filterPosts();
|
|
}
|
|
|
|
// 刷新帖子
|
|
function refreshPosts() {
|
|
currentPage = 1;
|
|
loadPosts();
|
|
}
|
|
|
|
// 审核通过
|
|
function approvePost(id) {
|
|
updatePostStatus(id, 1);
|
|
}
|
|
|
|
// 审核拒绝
|
|
function rejectPost(id) {
|
|
updatePostStatus(id, 2);
|
|
}
|
|
|
|
// 更新帖子状态
|
|
async function updatePostStatus(id, status) {
|
|
try {
|
|
// 调用后端API更新数据库
|
|
const response = await fetch('/api/forum-posts/update', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({ id, status })
|
|
});
|
|
|
|
const data = await response.json();
|
|
if (data.success) {
|
|
// 更新本地数据
|
|
const post = posts.find(p => p.id === id);
|
|
if (post) {
|
|
post.status = status;
|
|
}
|
|
|
|
// 清除缓存,确保下次加载时获取最新数据
|
|
Object.keys(postCache).forEach(key => {
|
|
delete postCache[key];
|
|
});
|
|
|
|
// 显示成功提示
|
|
alert(status === 1 ? '审核通过' : '审核拒绝');
|
|
|
|
// 重新过滤和显示
|
|
filterPosts();
|
|
} else {
|
|
alert('更新失败: ' + data.message);
|
|
}
|
|
} catch (error) {
|
|
console.error('更新帖子状态失败:', error);
|
|
alert('更新失败,请稍后重试');
|
|
}
|
|
}
|
|
|
|
// 显示帖子详情
|
|
function showPostDetail(id) {
|
|
const post = posts.find(p => p.id === id);
|
|
if (post) {
|
|
let statusText = '待审核';
|
|
let statusClass = 'status-pending-large';
|
|
|
|
if (post.status === 1) {
|
|
statusText = '已通过';
|
|
statusClass = 'status-approved-large';
|
|
} else if (post.status === 2) {
|
|
statusText = '已拒绝';
|
|
statusClass = 'status-rejected-large';
|
|
}
|
|
|
|
// 处理图片
|
|
let imagesHtml = '';
|
|
if (post.images) {
|
|
try {
|
|
const images = typeof post.images === 'string' ? JSON.parse(post.images) : post.images;
|
|
if (Array.isArray(images) && images.length > 0) {
|
|
imagesHtml = images.map((image, imgIndex) => `
|
|
<img src="${image}" alt="图片 ${imgIndex + 1}" class="detail-image" onclick="showImagePreview('${image}')">
|
|
`).join('');
|
|
}
|
|
} catch (e) {
|
|
console.error('解析图片数据失败:', e);
|
|
}
|
|
}
|
|
|
|
document.getElementById('detailContent').innerHTML = `
|
|
<div class="detail-grid">
|
|
<div class="detail-card">
|
|
<div class="detail-label">用户电话</div>
|
|
<div class="detail-value">${post.phone || '未知'}</div>
|
|
</div>
|
|
<div class="detail-card">
|
|
<div class="detail-label">用户ID</div>
|
|
<div class="detail-value">${post.user_id}</div>
|
|
</div>
|
|
<div class="detail-card">
|
|
<div class="detail-label">创建时间</div>
|
|
<div class="detail-value">${formatDateTime(post.created_at)}</div>
|
|
</div>
|
|
<div class="detail-card">
|
|
<div class="detail-label">审核状态</div>
|
|
<div class="detail-value">
|
|
<span class="status-tag-large ${statusClass}">${statusText}</span>
|
|
</div>
|
|
</div>
|
|
<div class="detail-card">
|
|
<div class="detail-label">点赞数</div>
|
|
<div class="detail-value">${post.likes}</div>
|
|
</div>
|
|
<div class="detail-card">
|
|
<div class="detail-label">评论数</div>
|
|
<div class="detail-value">${post.comments}</div>
|
|
</div>
|
|
<div class="detail-card">
|
|
<div class="detail-label">分享数</div>
|
|
<div class="detail-value">${post.shares}</div>
|
|
</div>
|
|
${post.topic ? `
|
|
<div class="detail-card">
|
|
<div class="detail-label">话题</div>
|
|
<div class="detail-value">#${post.topic}</div>
|
|
</div>
|
|
` : ''}
|
|
</div>
|
|
<div class="detail-content-section">
|
|
<div class="content-card">
|
|
<div class="content-label">动态内容</div>
|
|
<div class="content-value">${post.content}</div>
|
|
</div>
|
|
</div>
|
|
${imagesHtml ? `
|
|
<div class="detail-content-section">
|
|
<div class="content-card">
|
|
<div class="content-label">图片</div>
|
|
<div class="detail-images">${imagesHtml}</div>
|
|
</div>
|
|
</div>
|
|
` : ''}
|
|
`;
|
|
|
|
document.getElementById('detailModal').style.display = 'flex';
|
|
}
|
|
}
|
|
|
|
// 关闭详情弹窗
|
|
function closeDetailModal() {
|
|
document.getElementById('detailModal').style.display = 'none';
|
|
}
|
|
|
|
// 显示图片预览
|
|
function showImagePreview(imageUrl) {
|
|
document.getElementById('previewImage').src = imageUrl;
|
|
document.getElementById('imageModal').style.display = 'flex';
|
|
}
|
|
|
|
// 关闭图片预览弹窗
|
|
function closeImageModal() {
|
|
document.getElementById('imageModal').style.display = 'none';
|
|
}
|
|
|
|
// 更改页面大小
|
|
function changePageSize(size) {
|
|
pageSize = parseInt(size);
|
|
currentPage = 1;
|
|
loadPosts();
|
|
}
|
|
|
|
// 格式化日期时间
|
|
function formatDateTime(dateTimeStr) {
|
|
if (!dateTimeStr) return '';
|
|
const date = new Date(dateTimeStr);
|
|
return date.toLocaleString('zh-CN', {
|
|
year: 'numeric',
|
|
month: '2-digit',
|
|
day: '2-digit',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
second: '2-digit'
|
|
});
|
|
}
|
|
|
|
// 处理时间筛选
|
|
function handleDateFilter() {
|
|
startDate = document.getElementById('startDateInput').value;
|
|
endDate = document.getElementById('endDateInput').value;
|
|
currentPage = 1;
|
|
loadPosts();
|
|
}
|
|
|
|
// 重置时间筛选
|
|
function resetDateFilter() {
|
|
document.getElementById('startDateInput').value = '';
|
|
document.getElementById('endDateInput').value = '';
|
|
startDate = '';
|
|
endDate = '';
|
|
currentPage = 1;
|
|
loadPosts();
|
|
}
|
|
|
|
// 绑定事件
|
|
function bindEvents() {
|
|
// 状态过滤按钮
|
|
document.querySelectorAll('.filter-btn').forEach(btn => {
|
|
btn.addEventListener('click', () => {
|
|
document.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
|
|
btn.classList.add('active');
|
|
currentStatus = btn.dataset.status;
|
|
currentPage = 1;
|
|
filterPosts();
|
|
});
|
|
});
|
|
|
|
// 回车键搜索
|
|
document.getElementById('searchInput').addEventListener('keypress', (e) => {
|
|
if (e.key === 'Enter') handleSearch();
|
|
});
|
|
|
|
document.getElementById('phoneInput').addEventListener('keypress', (e) => {
|
|
if (e.key === 'Enter') handleSearch();
|
|
});
|
|
|
|
// 输入框内容变化时自动搜索
|
|
document.getElementById('searchInput').addEventListener('input', () => {
|
|
handleSearch();
|
|
});
|
|
|
|
document.getElementById('phoneInput').addEventListener('input', () => {
|
|
handleSearch();
|
|
});
|
|
|
|
// 点击弹窗外部关闭
|
|
document.getElementById('detailModal').addEventListener('click', (e) => {
|
|
if (e.target === document.getElementById('detailModal')) {
|
|
closeDetailModal();
|
|
}
|
|
});
|
|
|
|
document.getElementById('imageModal').addEventListener('click', (e) => {
|
|
if (e.target === document.getElementById('imageModal')) {
|
|
closeImageModal();
|
|
}
|
|
});
|
|
|
|
// 全选功能
|
|
if (document.getElementById('selectAllCheckbox')) {
|
|
document.getElementById('selectAllCheckbox').addEventListener('change', function() {
|
|
const checkboxes = document.querySelectorAll('.post-checkbox:not(:disabled)');
|
|
checkboxes.forEach(checkbox => {
|
|
checkbox.checked = this.checked;
|
|
});
|
|
// 更新已选中数量
|
|
updateSelectedCount();
|
|
});
|
|
}
|
|
|
|
// 单个勾选框变化时更新全选状态
|
|
document.addEventListener('change', function(e) {
|
|
if (e.target.classList.contains('post-checkbox') && !e.target.disabled) {
|
|
updateSelectAllStatus();
|
|
}
|
|
});
|
|
}
|
|
|
|
// 更新全选按钮状态
|
|
function updateSelectAllStatus() {
|
|
const checkboxes = document.querySelectorAll('.post-checkbox:not(:disabled)');
|
|
const checkedBoxes = document.querySelectorAll('.post-checkbox:not(:disabled):checked');
|
|
const selectAllCheckbox = document.getElementById('selectAllCheckbox');
|
|
|
|
if (selectAllCheckbox) {
|
|
if (checkboxes.length === 0) {
|
|
selectAllCheckbox.checked = false;
|
|
selectAllCheckbox.disabled = true;
|
|
} else {
|
|
selectAllCheckbox.disabled = false;
|
|
selectAllCheckbox.checked = checkboxes.length === checkedBoxes.length;
|
|
}
|
|
}
|
|
|
|
// 更新已选中数量
|
|
updateSelectedCount();
|
|
}
|
|
|
|
// 更新已选中数量显示
|
|
function updateSelectedCount() {
|
|
const checkedBoxes = document.querySelectorAll('.post-checkbox:not(:disabled):checked');
|
|
const selectedCountElement = document.getElementById('selectedCount');
|
|
|
|
if (selectedCountElement) {
|
|
selectedCountElement.textContent = `已选中 ${checkedBoxes.length} 条`;
|
|
}
|
|
}
|
|
|
|
// 获取选中的帖子ID列表
|
|
function getSelectedPostIds() {
|
|
const checkboxes = document.querySelectorAll('.post-checkbox:checked');
|
|
return Array.from(checkboxes).map(checkbox => parseInt(checkbox.dataset.id));
|
|
}
|
|
|
|
// 批量审核通过
|
|
function batchApprovePosts() {
|
|
batchUpdatePostStatus(1);
|
|
}
|
|
|
|
// 批量审核拒绝
|
|
function batchRejectPosts() {
|
|
batchUpdatePostStatus(2);
|
|
}
|
|
|
|
// 批量更新帖子状态
|
|
async function batchUpdatePostStatus(status) {
|
|
try {
|
|
const selectedIds = getSelectedPostIds();
|
|
|
|
if (selectedIds.length === 0) {
|
|
alert('请先选择要审核的动态');
|
|
return;
|
|
}
|
|
|
|
// 调用后端API更新数据库
|
|
const response = await fetch('/api/forum-posts/batch-update', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({ ids: selectedIds, status })
|
|
});
|
|
|
|
const data = await response.json();
|
|
if (data.success) {
|
|
// 更新本地数据
|
|
selectedIds.forEach(id => {
|
|
const post = posts.find(p => p.id === id);
|
|
if (post) {
|
|
post.status = status;
|
|
}
|
|
});
|
|
|
|
// 清除缓存,确保下次加载时获取最新数据
|
|
Object.keys(postCache).forEach(key => {
|
|
delete postCache[key];
|
|
});
|
|
|
|
// 显示成功提示
|
|
alert(`批量${status === 1 ? '通过' : '拒绝'}成功`);
|
|
|
|
// 重新过滤和显示
|
|
filterPosts();
|
|
} else {
|
|
alert('更新失败: ' + data.message);
|
|
}
|
|
} catch (error) {
|
|
console.error('批量更新帖子状态失败:', error);
|
|
alert('更新失败,请稍后重试');
|
|
}
|
|
}
|
|
|
|
// 初始化
|
|
window.onload = function() {
|
|
if (!checkLogin()) {
|
|
return;
|
|
}
|
|
|
|
loadPosts();
|
|
bindEvents();
|
|
};
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|