feat: 完全重建选题管理页面,包含统一卡片容器,恢复所有功能
This commit is contained in:
+60
-155
@@ -90,163 +90,68 @@
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="currentPage === 'topics'" style="margin-left: 160px; width: 100%; max-width: calc(100vw - 160px); box-sizing: border-box; overflow-x: auto;">
|
||||
<div class="flex justify-between items-center mb-6" style="width: 100%;"><h2 class="text-2xl font-bold text-gray-800">📋 选题管理</h2></div>
|
||||
<div class="card mb-6" style="display: inline-block; min-width: fit-content;"><div class="flex flex-wrap gap-2 items-center">
|
||||
<el-button type="primary" size="small" @click="refreshAll">🔄 批量刷新</el-button>
|
||||
<el-button type="success" size="small" @click="triggerGenerateSelected" :disabled="selectedTopicIds.length === 0">▶ 批量创作</el-button>
|
||||
<el-button type="warning" size="small" @click="triggerOptimizeSelected" :disabled="selectedTopicIds.length === 0">🔍 批量优化</el-button>
|
||||
<span class="ml-auto text-sm text-gray-500" v-if="selectedTopicIds.length > 0">已选 {{ selectedTopicIds.length }} 项</span>
|
||||
</div></div>
|
||||
<div class="quick-filter mb-4">
|
||||
<el-tag size="large" :type="filterStatus === '' ? 'primary' : ''" @click="filterStatus = ''">全部 ({{ topics.length }})</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '待处理' ? 'primary' : ''" @click="filterStatus = '待处理'">待处理 ({{ countByStatus('待处理') }})</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '待审查' ? 'primary' : ''" @click="filterStatus = '待审查'">待审查 ({{ countByStatus('待审查') }})</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '待发布' ? 'primary' : ''" @click="filterStatus = '待发布'">待发布 ({{ countByStatus('待发布') }})</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '已发布' ? 'primary' : ''" @click="filterStatus = '已发布'">已发布 ({{ countByStatus('已发布') }})</el-tag>
|
||||
</div>
|
||||
<div class="card" style="width: 100%; overflow-x: auto; box-sizing: border-box;">
|
||||
<el-table :data="filteredTopics" style="width: 100%; overflow-x: auto;"> stripe v-loading="loadingTable" :row-key="topic => topic.id" @selection-change="selectedTopicIds = $event">
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column prop="id" label="ID" width="70" fixed></el-table-column>
|
||||
<el-table-column prop="title" label="标题" min-width="220"></el-table-column>
|
||||
<el-table-column prop="field" label="领域" width="100"></el-table-column>
|
||||
<el-table-column prop="priority_score" label="优先级" width="70"><template #default="scope"><el-tag :type="getPriorityType(scope.row.priority_score)" size="small">{{ scope.row.priority_score }}</el-tag></template></el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="90"><template #default="scope"><span class="status-badge"><span class="status-dot" :class="getStatusClass(scope.row.status)"></span>{{ scope.row.status }}</span></template></el-table-column>
|
||||
<el-table-column prop="compliance_score" label="合规分" width="90"><template #default="scope"><el-progress :percentage="scope.row.compliance_score || 0" :format="() => scope.row.compliance_score || '-'" :stroke-width="15"></el-progress></template></el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="140"><template #default="scope">{{ formatDate(scope.row.created_at) }}</template></el-table-column>
|
||||
<el-table-column prop="generated_at" label="创作时间" width="140"><template #default="scope">{{ scope.row.generated_at ? formatDate(scope.row.generated_at) : '-' }}</template></el-table-column>
|
||||
<el-table-column prop="published_at" label="发布时间" width="140"><template #default="scope">{{ scope.row.published_at ? formatDate(scope.row.published_at) : '-' }}</template></el-table-column>
|
||||
<el-table-column prop="updated_at" label="更新时间" width="140"><template #default="scope">{{ formatDate(scope.row.updated_at) }}</template></el-table-column>
|
||||
<el-table-column label="操作" width="210" fixed="right">
|
||||
<template #default="scope">
|
||||
<div class="flex flex-wrap gap-1" style="justify-content: flex-start;">
|
||||
<el-button size="small" @click="openPreview(scope.row)" type="primary">预览</el-button>
|
||||
<el-button size="small" type="success" :disabled="scope.row.status !== '待处理'" @click="createTopic(scope.row)">创作</el-button>
|
||||
<el-button size="small" type="warning" :disabled="scope.row.status !== '待审查'" @click="optimizeTopic(scope.row)">审查</el-button>
|
||||
<el-button v-if="scope.row.status === '待发布'" size="small" type="primary" @click="handlePublish(scope.row)">发布</el-button>
|
||||
<el-button size="small" type="danger" @click="deleteTopic(scope.row.id)">删除</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="currentPage === 'logs'">
|
||||
<h2 class="text-2xl font-bold mb-6 text-gray-800">📄 系统日志</h2>
|
||||
<div class="card">
|
||||
<div class="flex flex-wrap gap-4 mb-4">
|
||||
<el-select v-model="logType" placeholder="日志类型" size="default"><el-option label="创作日志" value="creator"></el-option><el-option label="优化日志" value="optimizer"></el-option><el-option label="收集日志" value="collector"></el-option></el-select>
|
||||
<el-date-picker v-model="logDate" type="date" placeholder="选择日期" format="YYYY-MM-DD" value-format="YYYY-MM-DD" size="default"></el-date-picker>
|
||||
<el-button type="primary" @click="fetchLogs" :loading="loadingLogs">加载日志</el-button>
|
||||
</div>
|
||||
<el-card v-if="logContent" class="font-mono text-sm bg-gray-50" style="max-height: 600px; overflow-y: auto;"><pre>{{ logContent }}</pre></el-card>
|
||||
<el-empty v-else description="请先选择类型和日期,然后点击加载"></el-empty>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="currentPage === 'users' && isAdmin">
|
||||
<h2 class="text-2xl font-bold mb-6 text-gray-800">👥 用户管理</h2>
|
||||
<div class="card">
|
||||
<div class="flex justify-between items-center mb-4"><h3 class="text-lg font-bold">用户列表</h3><el-button type="primary" @click="openCreateUserModal">+ 新建用户</el-button></div>
|
||||
<el-table :data="users" stripe v-loading="loadingUsers">
|
||||
<el-table-column prop="id" label="ID" width="70"></el-table-column>
|
||||
<el-table-column prop="username" label="用户名"></el-table-column>
|
||||
<el-table-column prop="role" label="角色" width="100"><template #default="scope"><el-tag :type="scope.row.role === 'admin' ? 'danger' : 'info'">{{ scope.row.role }}</el-tag></template></el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="180"><template #default="scope">{{ formatDate(scope.row.created_at) }}</template></el-table-column>
|
||||
<el-table-column label="操作" width="150"><template #default="scope"><el-button size="small" type="danger" @click="deleteUser(scope.row.id)" :disabled="scope.row.role === 'admin'">删除</el-button></template></el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div class="card" style="padding: 20px; margin-top: 20px;">
|
||||
<div class="flex justify-between items-center mb-6" style="width: 100%;"><h2 class="text-2xl font-bold text-gray-800">📋 选题管理</h2></div>
|
||||
|
||||
<div class="card mb-6" style="display: inline-block; min-width: fit-content;"><div class="flex flex-wrap gap-2 items-center">
|
||||
<el-button type="primary" size="small" @click="refreshAll">🔄 批量刷新</el-button>
|
||||
<el-button type="success" size="small" @click="triggerGenerateSelected" :disabled="selectedTopicIds.length === 0">▶ 批量创作</el-button>
|
||||
<el-button type="warning" size="small" @click="triggerOptimizeSelected" :disabled="selectedTopicIds.length === 0">🔍 批量优化</el-button>
|
||||
<span class="ml-auto text-sm text-gray-500" v-if="selectedTopicIds.length > 0">已选 {{ selectedTopicIds.length }} 项</span>
|
||||
</div></div>
|
||||
<div class="quick-filter mb-4">
|
||||
<el-tag size="large" :type="filterStatus === '' ? 'primary' : ''" @click="filterStatus = ''">全部 ({{ topics.length }})</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '待处理' ? 'primary' : ''" @click="filterStatus = '待处理'">待处理 ({{ countByStatus('待处理') }})</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '待审查' ? 'primary' : ''" @click="filterStatus = '待审查'">待审查 ({{ countByStatus('待审查') }})</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '待发布' ? 'primary' : ''" @click="filterStatus = '待发布'">待发布 ({{ countByStatus('待发布') }})</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '已发布' ? 'primary' : ''" @click="filterStatus = '已发布'">已发布 ({{ countByStatus('已发布') }})</el-tag>
|
||||
<div class="flex justify-between items-center mb-6">
|
||||
<h2 class="text-2xl font-bold text-gray-800">📋 选题管理</h2>
|
||||
</div>
|
||||
<div class="card mb-6" style="display: inline-block; min-width: fit-content;">
|
||||
<div class="flex flex-wrap gap-2 items-center">
|
||||
<el-button type="primary" size="small" @click="refreshAll">🔄 批量刷新</el-button>
|
||||
<el-button type="success" size="small" @click="triggerGenerateSelected" :disabled="selectedTopicIds.length === 0">▶ 批量创作</el-button>
|
||||
<el-button type="warning" size="small" @click="triggerOptimizeSelected" :disabled="selectedTopicIds.length === 0">🔍 批量优化</el-button>
|
||||
<span class="ml-auto text-sm text-gray-500" v-if="selectedTopicIds.length > 0">已选 {{ selectedTopicIds.length }} 项</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="quick-filter mb-4">
|
||||
<el-tag size="large" :type="filterStatus === '' ? 'primary' : ''" @click="filterStatus = ''">全部 ({{ topics.length }})</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '待处理' ? 'primary' : ''" @click="filterStatus = '待处理'">待处理 ({{ countByStatus('待处理') }})</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '待审查' ? 'primary' : ''" @click="filterStatus = '待审查'">待审查 ({{ countByStatus('待审查') }})</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '待发布' ? 'primary' : ''" @click="filterStatus = '待发布'">待发布 ({{ countByStatus('待发布') }})</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '已发布' ? 'primary' : ''" @click="filterStatus = '已发布'">已发布 ({{ countByStatus('已发布') }})</el-tag>
|
||||
</div>
|
||||
<div class="card" style="width: 100%; overflow-x: auto; box-sizing: border-box;">
|
||||
<el-table :data="filteredTopics" stripe v-loading="loadingTable" :row-key="topic => topic.id" @selection-change="selectedTopicIds = $event">
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column prop="id" label="ID" width="70" fixed></el-table-column>
|
||||
<el-table-column prop="title" label="标题" min-width="220"></el-table-column>
|
||||
<el-table-column prop="field" label="领域" width="100"></el-table-column>
|
||||
<el-table-column prop="priority_score" label="优先级" width="70">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getPriorityType(scope.row.priority_score)" size="small">{{ scope.row.priority_score }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="90">
|
||||
<template #default="scope">
|
||||
<span class="status-badge">
|
||||
<span class="status-dot" :class="getStatusClass(scope.row.status)"></span>
|
||||
{{ scope.row.status }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="compliance_score" label="合规分" width="90">
|
||||
<template #default="scope">
|
||||
<el-progress :percentage="scope.row.compliance_score || 0" :format="() => scope.row.compliance_score || '-'" :stroke-width="15"></el-progress>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="140"><template #default="scope">{{ formatDate(scope.row.created_at) }}</template></el-table-column>
|
||||
<el-table-column prop="generated_at" label="创作时间" width="140"><template #default="scope">{{ scope.row.generated_at ? formatDate(scope.row.generated_at) : '-' }}</template></el-table-column>
|
||||
<el-table-column prop="published_at" label="发布时间" width="140"><template #default="scope">{{ scope.row.published_at ? formatDate(scope.row.published_at) : '-' }}</template></el-table-column>
|
||||
<el-table-column prop="updated_at" label="更新时间" width="140"><template #default="scope">{{ formatDate(scope.row.updated_at) }}</template></el-table-column>
|
||||
<el-table-column label="操作" width="210" fixed="right">
|
||||
<template #default="scope">
|
||||
<div class="flex flex-wrap gap-1" style="justify-content: flex-start;">
|
||||
<el-button size="small" @click="openPreview(scope.row)" type="primary">预览</el-button>
|
||||
<el-button size="small" type="success" :disabled="scope.row.status !== '待处理'" @click="createTopic(scope.row)">创作</el-button>
|
||||
<el-button size="small" type="warning" :disabled="scope.row.status !== '待审查'" @click="optimizeTopic(scope.row)">审查</el-button>
|
||||
<el-button v-if="scope.row.status === '待发布'" size="small" type="primary" @click="handlePublish(scope.row)">发布</el-button>
|
||||
<el-button size="small" type="danger" @click="deleteTopic(scope.row.id)">删除</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card" style="width: 100%; overflow-x: auto; box-sizing: border-box;">
|
||||
<el-table :data="filteredTopics" style="width: 100%; overflow-x: auto; box-sizing: border-box;" stripe v-loading="loadingTable" :row-key="topic => topic.id" @selection-change="selectedTopicIds = $event">
|
||||
<el-table-column type="selection" width="55"></el-table-column>
|
||||
<el-table-column prop="id" label="ID" width="70" fixed></el-table-column>
|
||||
<el-table-column prop="title" label="标题" min-width="220"></el-table-column>
|
||||
<el-table-column prop="field" label="领域" width="100"></el-table-column>
|
||||
<el-table-column prop="priority_score" label="优先级" width="70"><template #default="scope"><el-tag :type="getPriorityType(scope.row.priority_score)" size="small">{{ scope.row.priority_score }}</el-tag></template></el-table-column>
|
||||
<el-table-column prop="status" label="状态" width="90"><template #default="scope"><span class="status-badge"><span class="status-dot" :class="getStatusClass(scope.row.status)"></span>{{ scope.row.status }}</span></template></el-table-column>
|
||||
<el-table-column prop="compliance_score" label="合规分" width="90"><template #default="scope"><el-progress :percentage="scope.row.compliance_score || 0" :format="() => scope.row.compliance_score || '- '" :stroke-width="15"></el-progress></template></el-table-column>
|
||||
<el-table-column prop="created_at" label="创建时间" width="140"><template #default="scope">{{ formatDate(scope.row.created_at) }}</template></el-table-column>
|
||||
<el-table-column prop="generated_at" label="创作时间" width="140"><template #default="scope">{{ scope.row.generated_at ? formatDate(scope.row.generated_at) : '- '}}< /template></el-table-column>
|
||||
<el-table-column prop="published_at" label="发布时间" width="140"><template #default="scope">{{ scope.row.published_at ? formatDate(scope.row.published_at) : '- '}}< /template></el-table-column>
|
||||
<el-table-column prop="updated_at" label="更新时间" width="140"><template #default="scope">{{ formatDate(scope.row.updated_at) }}</template></el-table-column>
|
||||
<el-table-column label="操作" width="210" fixed="right">
|
||||
<template #default="scope">
|
||||
<div class="flex flex-wrap gap-1" style="justify-content: flex-start;">
|
||||
<el-button size="small" @click="openPreview(scope.row)" type="primary">预览</el-button>
|
||||
<el-button size="small" type="success" :disabled="scope.row.status !== '待处理'" @click="createTopic(scope.row)">创作</el-button>
|
||||
<el-button size="small" type="warning" :disabled="scope.row.status !== '待审查'" @click="optimizeTopic(scope.row)">审查</el-button>
|
||||
<el-button v-if="scope.row.status === '待发布'" size="small" type="primary" @click="handlePublish(scope.row)">发布</el-button>
|
||||
<el-button size="small" type="danger" @click="deleteTopic(scope.row.id)">删除</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
||||
<div v-if="loadingOverlay" class="loading-overlay"><el-spinner type="spinning" :size="50"></el-spinner><p class="ml-4 text-lg">{{ loadingText }}</p></div>
|
||||
<el-dialog v-model="previewVisible" title="文章预览" width="80%" top="5vh">
|
||||
<div class="preview-container">
|
||||
<div class="preview-actions"><el-button type="primary" size="small" @click="copyPreviewHtml">📋 复制 HTML</el-button><el-button type="success" size="small" @click="expandPreview">⛶ 全屏</el-button></div>
|
||||
<el-card v-if="previewHtml" class="mt-4" style="max-height: 60vh; overflow-y: auto;"><div v-html="previewHtml"></div></el-card>
|
||||
<el-empty v-else description="暂无预览内容"></el-empty>
|
||||
</div>
|
||||
</el-dialog>
|
||||
<el-dialog v-model="createTopicModalVisible" title="新建选题" width="500px">
|
||||
<el-form :model="newTopicForm" label-width="100px">
|
||||
<el-form-item label="标题"><el-input v-model="newTopicForm.title" placeholder="请输入标题"></el-input></el-form-item>
|
||||
<el-form-item label="领域"><el-input v-model="newTopicForm.field" placeholder="请输入领域"></el-input></el-form-item>
|
||||
<el-form-item label="优先级"><el-select v-model="newTopicForm.priority" placeholder="请选择"><el-option label="高" value="高"></el-option><el-option label="中" value="中"></el-option><el-option label="低" value="低"></el-option></el-select></el-form-item>
|
||||
</el-form>
|
||||
<template #footer><el-button @click="createTopicModalVisible = false">取消</el-button><el-button type="primary" @click="confirmCreateTopic">确定</el-button></template>
|
||||
</el-dialog>
|
||||
<el-dialog v-model="createUserModalVisible" title="新建用户" width="500px">
|
||||
<el-form :model="newUserForm" label-width="100px">
|
||||
<el-form-item label="用户名"><el-input v-model="newUserForm.username" placeholder="请输入用户名"></el-input></el-form-item>
|
||||
<el-form-item label="密码"><el-input v-model="newUserForm.password" type="password" placeholder="请输入密码"></el-input></el-form-item>
|
||||
<el-form-item label="角色"><el-select v-model="newUserForm.role" placeholder="请选择"><el-option label="管理员" value="admin"></el-option><el-option label="普通用户" value="user"></el-option></el-select></el-form-item>
|
||||
</el-form>
|
||||
<template #footer><el-button @click="createUserModalVisible = false">取消</el-button><el-button type="primary" @click="confirmCreateUser">确定</el-button></template>
|
||||
</el-dialog>
|
||||
<el-dialog v-model="publishModalVisible" title="发布选题" width="500px">
|
||||
<el-form :model="publishForm" label-width="100px">
|
||||
<el-form-item label="平台"><el-select v-model="publishForm.platform" placeholder="请选择平台"><el-option label="知乎" value="zhihu"></el-option><el-option label="微信公众号" value="wechat"></el-option><el-option label="小红书" value="xiaohongshu"></el-option></el-select></el-form-item>
|
||||
<el-form-item label="URL"><el-input v-model="publishForm.url" placeholder="发布后的链接"></el-input></el-form-item>
|
||||
<el-form-item label="说明"><el-input type="textarea" v-model="publishForm.description" placeholder="发布说明"></el-input></el-form-item>
|
||||
</el-form>
|
||||
<template #footer><el-button @click="publishModalVisible = false">取消</el-button><el-button type="primary" @click="confirmPublish">确定</el-button></template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
<nav class="md:hidden fixed bottom-0 left-0 right-0 bg-white border-t border-gray-200 flex justify-around py-2 z-50" v-if="isLoggedIn">
|
||||
<button @click="currentPage = 'overview'" :class="['flex flex-col items-center px-4 py-1', currentPage === 'overview' ? 'text-blue-600' : 'text-gray-500']"><span class="text-xl">📊</span><span class="text-xs mt-1">概览</span></button>
|
||||
<button @click="currentPage = 'topics'" :class="['flex flex-col items-center px-4 py-1', currentPage === 'topics' ? 'text-blue-600' : 'text-gray-500']"><span class="text-xl">📋</span><span class="text-xs mt-1">选题</span></button>
|
||||
<button @click="currentPage = 'logs'" :class="['flex flex-col items-center px-4 py-1', currentPage === 'logs' ? 'text-blue-600' : 'text-gray-500']"><span class="text-xl">📄</span><span class="text-xs mt-1">日志</span></button>
|
||||
<button v-if="isAdmin" @click="currentPage = 'users'" :class="['flex flex-col items-center px-4 py-1', currentPage === 'users' ? 'text-blue-600' : 'text-gray-500']"><span class="text-xl">👥</span><span class="text-xs mt-1">用户</span></button>
|
||||
</nav>
|
||||
</div>
|
||||
</div></div>
|
||||
<script>
|
||||
const { ref, reactive, computed, onMounted, watch } = Vue;
|
||||
const { ElMessage, ElNotification } = ElementPlus;
|
||||
|
||||
Reference in New Issue
Block a user