diff --git a/platform/backend/app/api/system.py b/platform/backend/app/api/system.py
index 269f143..d521390 100644
--- a/platform/backend/app/api/system.py
+++ b/platform/backend/app/api/system.py
@@ -14,7 +14,7 @@ from ..core.generator import run_creator
from ..core.optimizer import run_optimizer
from ..core.sync import sync_topic_to_db, sync_all_topics
-PROJECT_ROOT = Path(__file__).resolve().parents[1]
+PROJECT_ROOT = Path(__file__).resolve().parents[4]
if os.getenv('PROJECT_ROOT'):
PROJECT_ROOT = Path(os.getenv('PROJECT_ROOT'))
LOGS_DIR = PROJECT_ROOT / "automation" / "logs"
diff --git a/platform/frontend/index.html b/platform/frontend/index.html
index d44705a..c316b02 100644
--- a/platform/frontend/index.html
+++ b/platform/frontend/index.html
@@ -98,16 +98,16 @@
已选 {{ selectedTopicIds.length }} 项
- 全部
- 待处理
- 待审查
- 待发布
- 已发布
+ 全部 ({{ topics.length }})
+ 待处理 ({{ countByStatus('待处理') }})
+ 待审查 ({{ countByStatus('待审查') }})
+ 待发布 ({{ countByStatus('待发布') }})
+ 已发布 ({{ countByStatus('已发布') }})
-
+
{{ scope.row.priority_score }}
@@ -117,14 +117,17 @@
{{ scope.row.generated_at ? formatDate(scope.row.generated_at) : '-' }}
{{ scope.row.published_at ? formatDate(scope.row.published_at) : '-' }}
{{ formatDate(scope.row.updated_at) }}
-
-
- 预览
- 创作
- 审查
- 发布
-
-
+
+
+
+ 预览
+ 创作
+ 审查
+ 发布
+ 删除
+
+
+
@@ -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; };