From 3f9848c6351eac90fb8002127bf0af58111500dd Mon Sep 17 00:00:00 2001 From: hz4th_coder Date: Tue, 14 Jul 2026 11:29:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E5=BA=93=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 产品名称(product_names)不再自动填充为网页标题 - 内容库显示搜索标题(search_title)作为主标题 - 产品名称单独显示(如果有关联) --- services/task_service.py | 7 +++++-- static/css/library.css | 4 ++-- static/js/library.js | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/services/task_service.py b/services/task_service.py index 0689f57..b3da287 100644 --- a/services/task_service.py +++ b/services/task_service.py @@ -102,15 +102,18 @@ class BackgroundTaskService: # 检查URL是否已存在 existing = db.search_articles(url) if not any(a.get('url') == url for a in existing): + # 获取抓取到的网页标题 + page_title = fetch_result.get('title', '') or title + article_id = db.add_article( - product_names=[title], + product_names=[], # 产品名称留空,后续手动关联 category=category or '', keywords=keywords or [], summary=content[:200], content=content, source=url, url=url, - search_title=title + search_title=title # 搜索结果的标题 ) if article_id: saved_count += 1 diff --git a/static/css/library.css b/static/css/library.css index 1c98faf..e68d447 100644 --- a/static/css/library.css +++ b/static/css/library.css @@ -250,7 +250,7 @@ color: #667eea; } -.article-page-title { +.article-products { font-size: 13px; color: #666; margin-bottom: 10px; @@ -259,7 +259,7 @@ border-radius: 4px; } -.article-page-title i { +.article-products i { color: #4caf50; } diff --git a/static/js/library.js b/static/js/library.js index bd62171..888a1ee 100644 --- a/static/js/library.js +++ b/static/js/library.js @@ -110,7 +110,7 @@ function displayArticles() { const productNames = safeParseJSON(article.product_names, []); const keywords = safeParseJSON(article.keywords, []); - // 确定显示标题:优先 search_title,其次 product_names,最后来源 + // 确定显示标题:优先 search_title(搜索标题),其次 product_names(产品名称),最后来源 const displayTitle = article.search_title || productNames.join(', ') || article.source || '未命名'; return ` @@ -133,9 +133,9 @@ function displayArticles() { - ${article.search_title && productNames.length > 0 && article.search_title !== productNames.join(', ') ? ` -
- 网页标题: ${escapeHtml(productNames.join(', '))} + ${productNames.length > 0 ? ` +
+ 产品: ${escapeHtml(productNames.join(', '))}
` : ''}