fix: 修复分类标签、删除按钮、日志 API 路径 - 保留操作列固定右侧设计
This commit is contained in:
@@ -98,16 +98,16 @@
|
||||
<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' : ''" closable @close="filterStatus = ''">全部</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '待处理' ? 'primary' : ''" closable @close="filterStatus = '待处理'">待处理</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '待审查' ? 'primary' : ''" closable @close="filterStatus = '待审查'">待审查</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '待发布' ? 'primary' : ''" closable @close="filterStatus = '待发布'">待发布</el-tag>
|
||||
<el-tag size="large" :type="filterStatus === '已发布' ? 'primary' : ''" closable @close="filterStatus = '已发布'">已发布</el-tag>
|
||||
<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">
|
||||
<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="100"></el-table-column>
|
||||
<el-table-column prop="id" label="ID" width="80" fixed></el-table-column>
|
||||
<el-table-column prop="title" label="标题" min-width="300"></el-table-column>
|
||||
<el-table-column prop="field" label="领域" width="120"></el-table-column>
|
||||
<el-table-column prop="priority_score" label="优先级" width="80"><template #default="scope"><el-tag :type="getPriorityType(scope.row.priority_score)" size="small">{{ scope.row.priority_score }}</el-tag></template></el-table-column>
|
||||
@@ -117,14 +117,17 @@
|
||||
<el-table-column prop="generated_at" label="创作时间" width="160"><template #default="scope">{{ scope.row.generated_at ? formatDate(scope.row.generated_at) : '-' }}</template></el-table-column>
|
||||
<el-table-column prop="published_at" label="发布时间" width="160"><template #default="scope">{{ scope.row.published_at ? formatDate(scope.row.published_at) : '-' }}</template></el-table-column>
|
||||
<el-table-column prop="updated_at" label="更新时间" width="160"><template #default="scope">{{ formatDate(scope.row.updated_at) }}</template></el-table-column>
|
||||
<el-table-column label="操作" width="280" fixed="right"><template #default="scope">
|
||||
<div class="flex gap-1 flex-wrap">
|
||||
<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>
|
||||
</div>
|
||||
</template></el-table-column>
|
||||
<el-table-column label="操作" width="220" fixed="right">
|
||||
<template #default="scope">
|
||||
<div class="flex gap-1 flex-wrap">
|
||||
<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>
|
||||
@@ -263,10 +266,19 @@
|
||||
const loadPreview = async () => { try { const res = await authFetch(API_BASE + '/api/topics/' + previewTopic.value.id + '/preview?platform=' + previewPlatform.value); const data = await res.json(); previewHtml.value = data.html; } catch (e) { ElMessage.error('预览加载失败'); previewHtml.value = ''; } };
|
||||
const copyPreviewHtml = () => { navigator.clipboard.writeText(previewHtml.value).then(() => ElMessage.success('HTML 已复制到剪贴板')).catch(() => ElMessage.error('复制失败')); };
|
||||
const expandPreview = () => { fullScreenPreview.value = !fullScreenPreview.value; };
|
||||
const fetchLogs = async () => { loadingLogs.value = true; logContent.value = ''; try { const res = await authFetch(API_BASE + '/api/system/logs/' + logDate.value + '?log_type=' + logType.value); const data = await res.json(); logContent.value = data.content.join('\n'); } catch (e) { ElMessage.error('加载日志失败:' + e.message); } finally { loadingLogs.value = false; } };
|
||||
const fetchLogs = async () => { loadingLogs.value = true; logContent.value = ''; try { const res = await authFetch(API_BASE + '/api/system/logs/' + logDate.value + '?log_type=' + logType.value); if (res.status === 404) { logContent.value = '日志文件不存在或为空。'; ElMessage.info('该日期无日志记录'); } else { const data = await res.json(); logContent.value = data.content.join('\n'); } } catch (e) { if (e.message.includes('未授权')) return; ElMessage.error('加载日志失败:' + e.message); } finally { loadingLogs.value = false; } };
|
||||
const createTopic = (topic) => { if (topic && topic.status === '待处理') triggerGenerate(topic.id); else ElMessage.info('仅待处理选题可创作'); };
|
||||
const optimizeTopic = (topic) => { if (topic && topic.status === '待审查') triggerOptimize([topic.id]); else ElMessage.info('仅待审查选题可优化'); };
|
||||
const handlePublish = (topic) => { publishModalVisible.value = true; publishForm.platform = 'zhihu'; publishForm.url = ''; publishForm.description = ''; publishTopicId = topic.id; };
|
||||
|
||||
const deleteTopic = async (id) => {
|
||||
if (!confirm('确定删除该选题?删除后无法恢复。')) return;
|
||||
try {
|
||||
await authFetch(API_BASE + '/api/topics/' + id, { method: 'DELETE' });
|
||||
ElMessage.success('删除成功');
|
||||
refresh();
|
||||
} catch (e) { if (e.message.includes('未授权')) return; ElMessage.error('删除失败:' + e.message); }
|
||||
};
|
||||
const confirmPublish = async () => { try { await authFetch(API_BASE + '/api/topics/' + publishTopicId + '/publish', { method: 'POST', body: JSON.stringify({ platform: publishForm.platform, platform_urls: { [publishForm.platform]: publishForm.url }, description: publishForm.description }) }); ElMessage.success('发布成功'); publishModalVisible.value = false; refresh(); } catch (e) { ElMessage.error('发布失败:' + e.message); } };
|
||||
const openCreateTopic = () => { createTopicModalVisible.value = true; newTopicForm.title = ''; newTopicForm.field = ''; newTopicForm.priority = '中'; };
|
||||
const confirmCreateTopic = () => { ElMessage.info('新建选题功能待实现'); createTopicModalVisible.value = false; };
|
||||
|
||||
Reference in New Issue
Block a user