release: v2.2.0 - 博查新闻搜索功能
新增功能: - 集成博查Web Search API,自动获取网站相关新闻 - News模型添加source_name和source_icon字段 - 新闻管理后台界面优化 - 网站详情页新闻展示(标题、摘要、来源、链接) - 定期任务脚本支持批量获取新闻 - 完整的API路由和测试脚本 技术实现: - NewsSearcher工具类封装博查API - 智能新闻搜索和去重机制 - 数据库迁移脚本migrate_news_fields.py - API路由:/api/fetch-site-news 和 /api/fetch-all-news - Cron任务脚本:fetch_news_cron.py 修改文件: - config.py: 添加博查API配置 - models.py: News模型扩展 - app.py: 新闻获取路由和NewsAdmin优化 - templates/detail_new.html: 新闻展示UI 新增文件: - utils/news_searcher.py (271行) - migrate_news_fields.py (99行) - fetch_news_cron.py (167行) - test_news_feature.py (142行) - NEWS_FEATURE_v2.2.md (408行) 统计:9个文件,1348行新增 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -628,10 +628,43 @@
|
||||
</h2>
|
||||
{% for news in news_list %}
|
||||
<div class="news-item">
|
||||
<span class="news-badge">{{ news.news_type }}</span>
|
||||
<h4>{{ news.title }}</h4>
|
||||
<p>{{ news.content[:200] }}...</p>
|
||||
<div class="news-date">{{ news.published_at.strftime('%b %d, %Y') }}</div>
|
||||
<div style="display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px;">
|
||||
<span class="news-badge">{{ news.news_type }}</span>
|
||||
{% if news.source_name %}
|
||||
<div style="display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted);">
|
||||
{% if news.source_icon %}
|
||||
<img src="{{ news.source_icon }}" alt="{{ news.source_name }}" style="width: 16px; height: 16px; border-radius: 2px;">
|
||||
{% endif %}
|
||||
<span>{{ news.source_name }}</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<h4>
|
||||
{% if news.url %}
|
||||
<a href="{{ news.url }}" target="_blank" rel="noopener noreferrer" style="color: var(--text-primary); text-decoration: none;">
|
||||
{{ news.title }}
|
||||
</a>
|
||||
{% else %}
|
||||
{{ news.title }}
|
||||
{% endif %}
|
||||
</h4>
|
||||
{% if news.content %}
|
||||
<p>{{ news.content[:200] }}{% if news.content|length > 200 %}...{% endif %}</p>
|
||||
{% endif %}
|
||||
<div style="display: flex; justify-content: space-between; align-items: center;">
|
||||
<div class="news-date">
|
||||
{% if news.published_at %}
|
||||
{{ news.published_at.strftime('%Y年%m月%d日') }}
|
||||
{% else %}
|
||||
未知日期
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if news.url %}
|
||||
<a href="{{ news.url }}" target="_blank" rel="noopener noreferrer" style="font-size: 12px; color: var(--primary-blue); text-decoration: none;">
|
||||
阅读全文 ↗
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user