Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dabc4d0b7 | ||
|
|
981b3c9c5c | ||
|
|
127654a558 | ||
|
|
322ca28cb4 | ||
|
|
1a2d6ada88 | ||
|
|
00609980a8 | ||
|
|
76e24c4fa3 | ||
|
|
d23d526629 |
+24
-9
@@ -32,6 +32,7 @@ class Database:
|
|||||||
CREATE TABLE IF NOT EXISTS articles (
|
CREATE TABLE IF NOT EXISTS articles (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
product_names TEXT NOT NULL,
|
product_names TEXT NOT NULL,
|
||||||
|
search_title TEXT,
|
||||||
category TEXT,
|
category TEXT,
|
||||||
keywords TEXT,
|
keywords TEXT,
|
||||||
summary TEXT,
|
summary TEXT,
|
||||||
@@ -44,6 +45,12 @@ class Database:
|
|||||||
)
|
)
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
# 为旧表添加字段(如果不存在)
|
||||||
|
try:
|
||||||
|
cursor.execute('ALTER TABLE articles ADD COLUMN search_title TEXT')
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
# 待处理产品列表
|
# 待处理产品列表
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
CREATE TABLE IF NOT EXISTS pending_products (
|
CREATE TABLE IF NOT EXISTS pending_products (
|
||||||
@@ -138,15 +145,15 @@ class Database:
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
# ========== 内容库操作 ==========
|
# ========== 内容库操作 ==========
|
||||||
def add_article(self, product_names, category, keywords, summary, content, source, url=None):
|
def add_article(self, product_names, category, keywords, summary, content, source, url=None, search_title=None):
|
||||||
"""添加文章到内容库"""
|
"""添加文章到内容库"""
|
||||||
with self.get_connection() as conn:
|
with self.get_connection() as conn:
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
INSERT INTO articles (product_names, category, keywords, summary, content, source, url)
|
INSERT INTO articles (product_names, search_title, category, keywords, summary, content, source, url)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
''', (json.dumps(product_names, ensure_ascii=False), category,
|
''', (json.dumps(product_names, ensure_ascii=False), search_title,
|
||||||
json.dumps(keywords, ensure_ascii=False), summary, content, source, url))
|
category, json.dumps(keywords, ensure_ascii=False), summary, content, source, url))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
return cursor.lastrowid
|
return cursor.lastrowid
|
||||||
|
|
||||||
@@ -157,16 +164,16 @@ class Database:
|
|||||||
if category:
|
if category:
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
SELECT * FROM articles
|
SELECT * FROM articles
|
||||||
WHERE (product_names LIKE ? OR keywords LIKE ? OR summary LIKE ? OR content LIKE ?)
|
WHERE (product_names LIKE ? OR keywords LIKE ? OR summary LIKE ? OR content LIKE ? OR url LIKE ?)
|
||||||
AND category = ?
|
AND category = ?
|
||||||
ORDER BY fetch_date DESC
|
ORDER BY fetch_date DESC
|
||||||
''', (f'%{keyword}%', f'%{keyword}%', f'%{keyword}%', f'%{keyword}%', category))
|
''', (f'%{keyword}%', f'%{keyword}%', f'%{keyword}%', f'%{keyword}%', f'%{keyword}%', category))
|
||||||
else:
|
else:
|
||||||
cursor.execute('''
|
cursor.execute('''
|
||||||
SELECT * FROM articles
|
SELECT * FROM articles
|
||||||
WHERE product_names LIKE ? OR keywords LIKE ? OR summary LIKE ? OR content LIKE ?
|
WHERE product_names LIKE ? OR keywords LIKE ? OR summary LIKE ? OR content LIKE ? OR url LIKE ?
|
||||||
ORDER BY fetch_date DESC
|
ORDER BY fetch_date DESC
|
||||||
''', (f'%{keyword}%', f'%{keyword}%', f'%{keyword}%', f'%{keyword}%'))
|
''', (f'%{keyword}%', f'%{keyword}%', f'%{keyword}%', f'%{keyword}%', f'%{keyword}%'))
|
||||||
return [dict(row) for row in cursor.fetchall()]
|
return [dict(row) for row in cursor.fetchall()]
|
||||||
|
|
||||||
def get_article_by_id(self, article_id):
|
def get_article_by_id(self, article_id):
|
||||||
@@ -191,6 +198,14 @@ class Database:
|
|||||||
cursor.execute('DELETE FROM articles WHERE id = ?', (article_id,))
|
cursor.execute('DELETE FROM articles WHERE id = ?', (article_id,))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
return cursor.rowcount > 0
|
return cursor.rowcount > 0
|
||||||
|
|
||||||
|
def get_articles_count(self):
|
||||||
|
"""获取文章总数"""
|
||||||
|
with self.get_connection() as conn:
|
||||||
|
cursor = conn.cursor()
|
||||||
|
cursor.execute('SELECT COUNT(*) as count FROM articles')
|
||||||
|
row = cursor.fetchone()
|
||||||
|
return row['count'] if row else 0
|
||||||
|
|
||||||
# ========== 待处理产品操作 ==========
|
# ========== 待处理产品操作 ==========
|
||||||
def add_pending_product(self, product_name, category=None, subcategory=None, priority=0, source='manual'):
|
def add_pending_product(self, product_name, category=None, subcategory=None, priority=0, source='manual'):
|
||||||
|
|||||||
+17
-4
@@ -14,6 +14,7 @@ def list_articles():
|
|||||||
offset = request.args.get('offset', 0, type=int)
|
offset = request.args.get('offset', 0, type=int)
|
||||||
|
|
||||||
articles = db.get_all_articles(limit=limit, offset=offset)
|
articles = db.get_all_articles(limit=limit, offset=offset)
|
||||||
|
total_count = db.get_articles_count() # 获取总数
|
||||||
|
|
||||||
# 解析JSON字段
|
# 解析JSON字段
|
||||||
for article in articles:
|
for article in articles:
|
||||||
@@ -23,7 +24,7 @@ def list_articles():
|
|||||||
return jsonify({
|
return jsonify({
|
||||||
'success': True,
|
'success': True,
|
||||||
'articles': articles,
|
'articles': articles,
|
||||||
'count': len(articles)
|
'count': total_count # 返回总数
|
||||||
})
|
})
|
||||||
|
|
||||||
@bp.route('/search', methods=['GET'])
|
@bp.route('/search', methods=['GET'])
|
||||||
@@ -31,11 +32,20 @@ def search_articles():
|
|||||||
"""搜索文章"""
|
"""搜索文章"""
|
||||||
keyword = request.args.get('q', '')
|
keyword = request.args.get('q', '')
|
||||||
category = request.args.get('category')
|
category = request.args.get('category')
|
||||||
|
limit = request.args.get('limit', type=int)
|
||||||
|
offset = request.args.get('offset', 0, type=int)
|
||||||
|
|
||||||
if not keyword:
|
if not keyword:
|
||||||
return jsonify({'error': '请提供搜索关键词'}), 400
|
return jsonify({'error': '请提供搜索关键词'}), 400
|
||||||
|
|
||||||
articles = db.search_articles(keyword, category)
|
all_articles = db.search_articles(keyword, category)
|
||||||
|
total_count = len(all_articles)
|
||||||
|
|
||||||
|
# 分页截取
|
||||||
|
if limit:
|
||||||
|
articles = all_articles[offset:offset + limit]
|
||||||
|
else:
|
||||||
|
articles = all_articles
|
||||||
|
|
||||||
# 解析JSON字段
|
# 解析JSON字段
|
||||||
for article in articles:
|
for article in articles:
|
||||||
@@ -45,7 +55,7 @@ def search_articles():
|
|||||||
return jsonify({
|
return jsonify({
|
||||||
'success': True,
|
'success': True,
|
||||||
'articles': articles,
|
'articles': articles,
|
||||||
'count': len(articles)
|
'count': total_count # 返回总数,用于分页
|
||||||
})
|
})
|
||||||
|
|
||||||
@bp.route('/<int:article_id>', methods=['GET'])
|
@bp.route('/<int:article_id>', methods=['GET'])
|
||||||
@@ -108,6 +118,7 @@ def fetch_article():
|
|||||||
"""从URL抓取文章"""
|
"""从URL抓取文章"""
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
url = data.get('url')
|
url = data.get('url')
|
||||||
|
search_title = data.get('search_title') # 搜索结果的标题
|
||||||
|
|
||||||
if not url:
|
if not url:
|
||||||
return jsonify({'error': '请提供URL'}), 400
|
return jsonify({'error': '请提供URL'}), 400
|
||||||
@@ -116,6 +127,7 @@ def fetch_article():
|
|||||||
|
|
||||||
if result and result.get('success'):
|
if result and result.get('success'):
|
||||||
# 自动保存到内容库
|
# 自动保存到内容库
|
||||||
|
# product_names 使用抓取到的标题,search_title 使用搜索结果的标题
|
||||||
article_id = search_service.save_to_articles(
|
article_id = search_service.save_to_articles(
|
||||||
product_names=data.get('product_names', [result['title']]),
|
product_names=data.get('product_names', [result['title']]),
|
||||||
category=data.get('category'),
|
category=data.get('category'),
|
||||||
@@ -123,7 +135,8 @@ def fetch_article():
|
|||||||
summary=result.get('description', ''),
|
summary=result.get('description', ''),
|
||||||
content=result['content'],
|
content=result['content'],
|
||||||
source=url,
|
source=url,
|
||||||
url=url
|
url=url,
|
||||||
|
search_title=search_title
|
||||||
)
|
)
|
||||||
|
|
||||||
return jsonify({
|
return jsonify({
|
||||||
|
|||||||
@@ -157,12 +157,17 @@ class SearchService:
|
|||||||
if match:
|
if match:
|
||||||
title = match.group(1)
|
title = match.group(1)
|
||||||
ref = match.group(2)
|
ref = match.group(2)
|
||||||
# 放宽过滤条件:只要不是纯域名格式就保留
|
# 过滤纯域名格式
|
||||||
if not (title.endswith('.com') or title.endswith('.cn') or title.endswith('.net')):
|
is_domain = (title.endswith('.com') or title.endswith('.cn') or
|
||||||
|
title.endswith('.net') or title.endswith('.org') or
|
||||||
|
title.endswith('.edu') or title.endswith('.gov'))
|
||||||
|
if not is_domain:
|
||||||
refs.append((title, ref))
|
refs.append((title, ref))
|
||||||
|
|
||||||
# 获取每个结果的 URL
|
# 获取每个结果的 URL,多获取几个以防解析失败
|
||||||
for title, ref in refs[:max_results]:
|
for title, ref in refs[:max_results + 5]:
|
||||||
|
if len(results) >= max_results:
|
||||||
|
break
|
||||||
url = self._get_link_url(ref)
|
url = self._get_link_url(ref)
|
||||||
if url and 'bing.com/search' not in url: # 过滤搜索结果页本身的链接
|
if url and 'bing.com/search' not in url: # 过滤搜索结果页本身的链接
|
||||||
results.append({
|
results.append({
|
||||||
@@ -385,9 +390,9 @@ class SearchService:
|
|||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def save_to_articles(self, product_names, category, keywords, summary, content, source, url=None):
|
def save_to_articles(self, product_names, category, keywords, summary, content, source, url=None, search_title=None):
|
||||||
"""保存搜索结果到内容库"""
|
"""保存搜索结果到内容库"""
|
||||||
return db.add_article(product_names, category, keywords, summary, content, source, url)
|
return db.add_article(product_names, category, keywords, summary, content, source, url, search_title)
|
||||||
|
|
||||||
# 全局搜索服务实例
|
# 全局搜索服务实例
|
||||||
search_service = SearchService()
|
search_service = SearchService()
|
||||||
@@ -102,6 +102,15 @@
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.page-size-select {
|
||||||
|
padding: 10px 15px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 6px;
|
||||||
|
font-size: 14px;
|
||||||
|
background: white;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.toolbar-right {
|
.toolbar-right {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 10px;
|
gap: 10px;
|
||||||
@@ -228,6 +237,45 @@
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.article-search-title {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
background: #f0f4ff;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-search-title i {
|
||||||
|
color: #667eea;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-page-title {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
background: #e8f5e9;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-page-title i {
|
||||||
|
color: #4caf50;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 上部分页 */
|
||||||
|
.pagination-top {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination-top span {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
.article-summary {
|
.article-summary {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #666;
|
color: #666;
|
||||||
|
|||||||
@@ -268,6 +268,19 @@
|
|||||||
color: #667eea;
|
color: #667eea;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.result-page-title {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #666;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
padding: 4px 8px;
|
||||||
|
background: #f0f4ff;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.result-page-title i {
|
||||||
|
color: #667eea;
|
||||||
|
}
|
||||||
|
|
||||||
.result-title .saved-icon {
|
.result-title .saved-icon {
|
||||||
color: #10b981;
|
color: #10b981;
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-8
@@ -4,7 +4,7 @@ const API_BASE = '';
|
|||||||
// 状态
|
// 状态
|
||||||
let articles = [];
|
let articles = [];
|
||||||
let currentPage = 1;
|
let currentPage = 1;
|
||||||
let pageSize = 20;
|
let pageSize = 20; // 默认每页20条
|
||||||
let totalCount = 0;
|
let totalCount = 0;
|
||||||
let selectedIds = new Set();
|
let selectedIds = new Set();
|
||||||
let currentArticleId = null;
|
let currentArticleId = null;
|
||||||
@@ -31,6 +31,13 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 改变每页数量
|
||||||
|
function changePageSize() {
|
||||||
|
pageSize = parseInt(document.getElementById('page-size').value);
|
||||||
|
currentPage = 1;
|
||||||
|
loadArticles();
|
||||||
|
}
|
||||||
|
|
||||||
// 加载文章列表
|
// 加载文章列表
|
||||||
async function loadArticles() {
|
async function loadArticles() {
|
||||||
const keyword = document.getElementById('search-input').value.trim();
|
const keyword = document.getElementById('search-input').value.trim();
|
||||||
@@ -42,7 +49,12 @@ async function loadArticles() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (keyword) {
|
if (keyword) {
|
||||||
const response = await fetch(`${API_BASE}/api/articles/search?q=${encodeURIComponent(keyword)}${category ? '&category=' + encodeURIComponent(category) : ''}`);
|
// 搜索时也传递 limit 和 offset 参数
|
||||||
|
let searchUrl = `${API_BASE}/api/articles/search?q=${encodeURIComponent(keyword)}`;
|
||||||
|
if (category) searchUrl += `&category=${encodeURIComponent(category)}`;
|
||||||
|
searchUrl += `&limit=${pageSize}&offset=${(currentPage - 1) * pageSize}`;
|
||||||
|
|
||||||
|
const response = await fetch(searchUrl);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
@@ -98,6 +110,9 @@ function displayArticles() {
|
|||||||
const productNames = safeParseJSON(article.product_names, []);
|
const productNames = safeParseJSON(article.product_names, []);
|
||||||
const keywords = safeParseJSON(article.keywords, []);
|
const keywords = safeParseJSON(article.keywords, []);
|
||||||
|
|
||||||
|
// 确定显示标题:优先 search_title,其次 product_names,最后来源
|
||||||
|
const displayTitle = article.search_title || productNames.join(', ') || article.source || '未命名';
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<div class="article-card ${selectedIds.has(article.id) ? 'selected' : ''}" id="article-${article.id}">
|
<div class="article-card ${selectedIds.has(article.id) ? 'selected' : ''}" id="article-${article.id}">
|
||||||
<div class="article-card-header">
|
<div class="article-card-header">
|
||||||
@@ -107,7 +122,7 @@ function displayArticles() {
|
|||||||
onchange="toggleSelect(${article.id})">
|
onchange="toggleSelect(${article.id})">
|
||||||
</label>
|
</label>
|
||||||
<div class="article-title" onclick="showDetail(${article.id})">
|
<div class="article-title" onclick="showDetail(${article.id})">
|
||||||
${escapeHtml(productNames.join(', ') || '未命名')}
|
${escapeHtml(displayTitle)}
|
||||||
</div>
|
</div>
|
||||||
<div class="article-actions">
|
<div class="article-actions">
|
||||||
<button onclick="editArticle(${article.id})" class="btn btn-sm btn-secondary">
|
<button onclick="editArticle(${article.id})" class="btn btn-sm btn-secondary">
|
||||||
@@ -118,6 +133,11 @@ function displayArticles() {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
${article.search_title && productNames.length > 0 && article.search_title !== productNames.join(', ') ? `
|
||||||
|
<div class="article-page-title">
|
||||||
|
<i class="ri-article-line"></i> 网页标题: ${escapeHtml(productNames.join(', '))}
|
||||||
|
</div>
|
||||||
|
` : ''}
|
||||||
<div class="article-meta">
|
<div class="article-meta">
|
||||||
${article.category ? `<span class="article-category">${escapeHtml(article.category)}</span>` : ''}
|
${article.category ? `<span class="article-category">${escapeHtml(article.category)}</span>` : ''}
|
||||||
<span><i class="ri-link"></i> ${escapeHtml(article.source || '未知来源')}</span>
|
<span><i class="ri-link"></i> ${escapeHtml(article.source || '未知来源')}</span>
|
||||||
@@ -137,8 +157,14 @@ function displayArticles() {
|
|||||||
// 更新分页
|
// 更新分页
|
||||||
function updatePagination() {
|
function updatePagination() {
|
||||||
const totalPages = Math.ceil(totalCount / pageSize);
|
const totalPages = Math.ceil(totalCount / pageSize);
|
||||||
document.getElementById('page-info').textContent = `第 ${currentPage} / ${totalPages || 1} 页`;
|
|
||||||
|
|
||||||
|
// 更新上部分页
|
||||||
|
document.getElementById('page-info-top').textContent = `第 ${currentPage} / ${totalPages || 1} 页`;
|
||||||
|
document.getElementById('prev-btn-top').disabled = currentPage <= 1;
|
||||||
|
document.getElementById('next-btn-top').disabled = currentPage >= totalPages;
|
||||||
|
|
||||||
|
// 更新下部分页
|
||||||
|
document.getElementById('page-info').textContent = `第 ${currentPage} / ${totalPages || 1} 页`;
|
||||||
document.getElementById('prev-btn').disabled = currentPage <= 1;
|
document.getElementById('prev-btn').disabled = currentPage <= 1;
|
||||||
document.getElementById('next-btn').disabled = currentPage >= totalPages;
|
document.getElementById('next-btn').disabled = currentPage >= totalPages;
|
||||||
}
|
}
|
||||||
@@ -225,16 +251,22 @@ async function showDetail(id) {
|
|||||||
|
|
||||||
const body = document.getElementById('detail-body');
|
const body = document.getElementById('detail-body');
|
||||||
body.innerHTML = `
|
body.innerHTML = `
|
||||||
|
${article.search_title ? `
|
||||||
|
<div class="detail-section">
|
||||||
|
<h4><i class="ri-search-line"></i> 搜索标题</h4>
|
||||||
|
<p style="color: #667eea; font-weight: 500;">${escapeHtml(article.search_title)}</p>
|
||||||
|
</div>
|
||||||
|
` : ''}
|
||||||
<div class="detail-section">
|
<div class="detail-section">
|
||||||
<h4><i class="ri-price-tag-3-line"></i> 产品名称</h4>
|
<h4><i class="ri-article-line"></i> 网页标题(产品名称)</h4>
|
||||||
<p>${escapeHtml(productNames.join(', '))}</p>
|
<p>${escapeHtml(productNames.join(', ') || '无')}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-meta" style="display: flex; gap: 20px; background: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 20px;">
|
<div class="detail-meta" style="display: flex; gap: 20px; background: #f8f9fa; padding: 15px; border-radius: 8px; margin-bottom: 20px; flex-wrap: wrap;">
|
||||||
<div><strong>分类:</strong> ${escapeHtml(article.category || '未分类')}</div>
|
<div><strong>分类:</strong> ${escapeHtml(article.category || '未分类')}</div>
|
||||||
<div><strong>来源:</strong> ${escapeHtml(article.source)}</div>
|
<div><strong>来源:</strong> ${escapeHtml(article.source)}</div>
|
||||||
<div><strong>时间:</strong> ${formatDate(article.fetch_date)}</div>
|
<div><strong>时间:</strong> ${formatDate(article.fetch_date)}</div>
|
||||||
</div>
|
</div>
|
||||||
${article.url ? `<div class="detail-section"><h4><i class="ri-link"></i> 原文链接</h4><a href="${escapeHtml(article.url)}" target="_blank">${escapeHtml(article.url)}</a></div>` : ''}
|
${article.url ? `<div class="detail-section"><h4><i class="ri-link"></i> 原文链接</h4><a href="${escapeHtml(article.url)}" target="_blank" style="color: #667eea;">${escapeHtml(article.url)}</a></div>` : ''}
|
||||||
${keywords.length > 0 ? `<div class="detail-section"><h4><i class="ri-keyword-line"></i> 关键词</h4><p>${escapeHtml(keywords.join(', '))}</p></div>` : ''}
|
${keywords.length > 0 ? `<div class="detail-section"><h4><i class="ri-keyword-line"></i> 关键词</h4><p>${escapeHtml(keywords.join(', '))}</p></div>` : ''}
|
||||||
<div class="detail-section">
|
<div class="detail-section">
|
||||||
<h4><i class="ri-file-text-line"></i> 摘要</h4>
|
<h4><i class="ri-file-text-line"></i> 摘要</h4>
|
||||||
|
|||||||
+8
-2
@@ -135,6 +135,11 @@ function displayResults() {
|
|||||||
${r.saved ? '<i class="ri-check-line saved-icon"></i>' : ''}
|
${r.saved ? '<i class="ri-check-line saved-icon"></i>' : ''}
|
||||||
${escapeHtml(r.title)}
|
${escapeHtml(r.title)}
|
||||||
</div>
|
</div>
|
||||||
|
${r.pageTitle && r.pageTitle !== r.title ? `
|
||||||
|
<div class="result-page-title">
|
||||||
|
<i class="ri-article-line"></i> 网页标题: ${escapeHtml(r.pageTitle)}
|
||||||
|
</div>
|
||||||
|
` : ''}
|
||||||
<div class="result-url">
|
<div class="result-url">
|
||||||
<a href="${escapeHtml(r.url)}" target="_blank">
|
<a href="${escapeHtml(r.url)}" target="_blank">
|
||||||
<i class="ri-external-link-line"></i>
|
<i class="ri-external-link-line"></i>
|
||||||
@@ -207,7 +212,8 @@ async function fetchResult(index) {
|
|||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
url: result.url,
|
url: result.url,
|
||||||
product_names: [result.title]
|
product_names: [result.title],
|
||||||
|
search_title: result.title // 搜索结果的标题
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -216,7 +222,7 @@ async function fetchResult(index) {
|
|||||||
if (data.success) {
|
if (data.success) {
|
||||||
searchResults[index].fetched = true;
|
searchResults[index].fetched = true;
|
||||||
searchResults[index].content = data.data.content;
|
searchResults[index].content = data.data.content;
|
||||||
searchResults[index].title = data.data.title || result.title;
|
searchResults[index].pageTitle = data.data.title || result.title; // 抓取到的标题
|
||||||
|
|
||||||
btn.innerHTML = '<i class="ri-check-line"></i> 已抓取';
|
btn.innerHTML = '<i class="ri-check-line"></i> 已抓取';
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,13 @@
|
|||||||
<select id="category-filter" class="category-select">
|
<select id="category-filter" class="category-select">
|
||||||
<option value="">全部分类</option>
|
<option value="">全部分类</option>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="page-size" class="page-size-select" onchange="changePageSize()">
|
||||||
|
<option value="20" selected>每页 20 条</option>
|
||||||
|
<option value="50">每页 50 条</option>
|
||||||
|
<option value="100">每页 100 条</option>
|
||||||
|
<option value="200">每页 200 条</option>
|
||||||
|
<option value="500">每页 500 条</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="toolbar-right">
|
<div class="toolbar-right">
|
||||||
<button onclick="showAddModal()" class="btn btn-primary">
|
<button onclick="showAddModal()" class="btn btn-primary">
|
||||||
@@ -62,6 +69,12 @@
|
|||||||
<i class="ri-delete-bin-line"></i> 批量删除
|
<i class="ri-delete-bin-line"></i> 批量删除
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- 上部分页 -->
|
||||||
|
<div class="pagination-top" id="pagination-top">
|
||||||
|
<button onclick="prevPage()" class="btn btn-secondary btn-sm" id="prev-btn-top">上一页</button>
|
||||||
|
<span id="page-info-top">第 1 页</span>
|
||||||
|
<button onclick="nextPage()" class="btn btn-secondary btn-sm" id="next-btn-top">下一页</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="articles-body">
|
<div class="articles-body">
|
||||||
<div id="articles-list" class="articles-list">
|
<div id="articles-list" class="articles-list">
|
||||||
|
|||||||
Reference in New Issue
Block a user