diff --git a/frontend/src/views/ArticleDetail.vue b/frontend/src/views/ArticleDetail.vue index aaea87e..7ac6235 100644 --- a/frontend/src/views/ArticleDetail.vue +++ b/frontend/src/views/ArticleDetail.vue @@ -64,6 +64,24 @@ const publishedAt = computed(() => article.value?.published_at || article.value? const isOwner = computed(() => auth.isOwner) const categories = computed(() => (article.value?.category || '').split(',').filter(Boolean)) +// === 评论三态 === +// 'ok' + 有内容 → 显示真实评论 +// 'ok' 但无内容 → 等待(防御性) +// 'pending' / 'n/a' / null → 等待 +// 'failed' → 失败 +type CommentaryState = 'ok' | 'waiting' | 'failed' +function commentaryState(status?: string | null, content?: string | null): CommentaryState { + if (status === 'failed') return 'failed' + if (status === 'ok' && content) return 'ok' + return 'waiting' +} +const angelState = computed(() => + commentaryState(article.value?.commentary_status, article.value?.commentary) +) +const meituanState = computed(() => + commentaryState(article.value?.commentary_meituan_status, article.value?.commentary_meituan) +) + /** 把"一坨"译文/原文按"中文句号"切成

段,改善"挤在一起"的观感。 * 优先按 \n 切(LLM 排版过的),没有换行再按句号/问号/感叹号切。 * 句中常见的"Mr./U.S."等缩写不会出现在中文译文里,按 6+ 字符才切,避免半句话被切。 @@ -258,44 +276,81 @@ onMounted(load) 本条翻译失败,可点 "重译" 重试,或查看后端日志。 - - + + -

{{ article.commentary }}

+

{{ article.commentary }}

+

+ ⚠️ 评论生成失败 + + enrichment_loop 会自动重试;如持续失败,检查后端 worker 日志 + +

+

+ 🕒 等待评论中 + + enrichment_loop 会在翻译完成后跑(每篇约 15-20 秒) + +

- + + -

{{ article.commentary_meituan }}

- +

{{ article.commentary_meituan }}

+

+ ⚠️ 评论生成失败 + + {{ article.commentary_meituan_error }} + +

+

+ 🕒 等待评论中 + + enrichment_loop 会在翻译完成后跑(每篇约 15-20 秒) + +

+ 模型: {{ article.commentary_meituan_model }}
- -
美团评论生成失败
-
{{ article.commentary_meituan_error }}
-
-
@@ -379,6 +434,16 @@ onMounted(load) font-size: 15px; } +.commentary-text-waiting-detail { + color: var(--color-text-faint); + font-style: italic; +} + +.commentary-text-failed-detail { + color: #d03050; + font-style: italic; +} + .article-body-fallback { white-space: pre-wrap; line-height: 1.95; diff --git a/frontend/src/views/Feed.vue b/frontend/src/views/Feed.vue index 9b407f7..327fd42 100644 --- a/frontend/src/views/Feed.vue +++ b/frontend/src/views/Feed.vue @@ -99,6 +99,18 @@ function commentaryStatusType(s?: string | null): 'success' | 'warning' | 'error return 'default' } +// === 评论三态语义 === +// status 'ok' + 有内容 → 显示评论 +// status 'ok' + 无内容 → 视为等待(防御性,正常不会触发) +// status 'pending' / 'n/a' / null → 等待中 +// status 'failed' → 显示失败提示 +type CommentaryState = 'ok' | 'waiting' | 'failed' +function commentaryState(status?: string | null, content?: string | null): CommentaryState { + if (status === 'failed') return 'failed' + if (status === 'ok' && content) return 'ok' + return 'waiting' +} + // 正文摘要(取 body_zh_text 前 N 字;没有就 fallback 到 summary_zh) function bodyExcerpt(text?: string | null, max = 200): string { if (!text) return '' @@ -224,35 +236,71 @@ onMounted(async () => { {{ bodyExcerpt(a.body_zh_text || a.summary_zh, 220) }}
- +
-