更新Company页面的UI为FUI风格
This commit is contained in:
50
app.py
50
app.py
@@ -6658,50 +6658,15 @@ class RelatedData(db.Model):
|
|||||||
|
|
||||||
|
|
||||||
class RelatedConcepts(db.Model):
|
class RelatedConcepts(db.Model):
|
||||||
"""关联数据模型"""
|
"""事件关联概念模型"""
|
||||||
|
__tablename__ = 'related_concepts'
|
||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
event_id = db.Column(db.Integer, db.ForeignKey('event.id'))
|
event_id = db.Column(db.Integer, db.ForeignKey('event.id'))
|
||||||
concept_code = db.Column(db.String(20)) # 数据标题
|
concept = db.Column(db.String(255)) # 概念名称
|
||||||
concept = db.Column(db.String(100)) # 数据类型
|
reason = db.Column(db.Text) # 关联原因(AI 分析)
|
||||||
reason = db.Column(db.Text) # 数据描述
|
|
||||||
image_paths = db.Column(db.JSON) # 数据内容(JSON格式)
|
|
||||||
created_at = db.Column(db.DateTime, default=beijing_now)
|
created_at = db.Column(db.DateTime, default=beijing_now)
|
||||||
|
|
||||||
@property
|
|
||||||
def image_paths_list(self):
|
|
||||||
"""返回解析后的图片路径列表"""
|
|
||||||
if not self.image_paths:
|
|
||||||
return []
|
|
||||||
|
|
||||||
try:
|
|
||||||
# 如果是字符串,先解析成JSON
|
|
||||||
if isinstance(self.image_paths, str):
|
|
||||||
paths = json.loads(self.image_paths)
|
|
||||||
else:
|
|
||||||
paths = self.image_paths
|
|
||||||
|
|
||||||
# 确保paths是列表
|
|
||||||
if not isinstance(paths, list):
|
|
||||||
paths = [paths]
|
|
||||||
|
|
||||||
# 从每个对象中提取path字段
|
|
||||||
return [item['path'] if isinstance(item, dict) and 'path' in item
|
|
||||||
else item for item in paths]
|
|
||||||
except Exception as e:
|
|
||||||
print(f"Error processing image paths: {e}")
|
|
||||||
return []
|
|
||||||
|
|
||||||
def get_first_image_path(self):
|
|
||||||
"""获取第一张图片的完整路径"""
|
|
||||||
paths = self.image_paths_list
|
|
||||||
if not paths:
|
|
||||||
return None
|
|
||||||
|
|
||||||
# 获取第一个路径
|
|
||||||
first_path = paths[0]
|
|
||||||
# 返回完整路径
|
|
||||||
return first_path
|
|
||||||
|
|
||||||
|
|
||||||
class EventHotHistory(db.Model):
|
class EventHotHistory(db.Model):
|
||||||
"""事件热度历史记录"""
|
"""事件热度历史记录"""
|
||||||
@@ -7174,7 +7139,7 @@ def get_events_by_stocks():
|
|||||||
|
|
||||||
@app.route('/api/events/<int:event_id>/concepts', methods=['GET'])
|
@app.route('/api/events/<int:event_id>/concepts', methods=['GET'])
|
||||||
def get_related_concepts(event_id):
|
def get_related_concepts(event_id):
|
||||||
"""获取相关概念列表"""
|
"""获取相关概念列表(从 related_concepts 表)"""
|
||||||
try:
|
try:
|
||||||
# 订阅控制:相关概念需要 Pro 及以上
|
# 订阅控制:相关概念需要 Pro 及以上
|
||||||
if not _has_required_level('pro'):
|
if not _has_required_level('pro'):
|
||||||
@@ -7186,11 +7151,8 @@ def get_related_concepts(event_id):
|
|||||||
for concept in concepts:
|
for concept in concepts:
|
||||||
concepts_data.append({
|
concepts_data.append({
|
||||||
'id': concept.id,
|
'id': concept.id,
|
||||||
'concept_code': concept.concept_code,
|
|
||||||
'concept': concept.concept,
|
'concept': concept.concept,
|
||||||
'reason': concept.reason,
|
'reason': concept.reason,
|
||||||
'image_paths': concept.image_paths_list,
|
|
||||||
'first_image_path': concept.get_first_image_path(),
|
|
||||||
'created_at': concept.created_at.isoformat() if concept.created_at else None
|
'created_at': concept.created_at.isoformat() if concept.created_at else None
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ const RelatedConceptsSection = ({
|
|||||||
const formattedConcepts = data.data.map(item => ({
|
const formattedConcepts = data.data.map(item => ({
|
||||||
concept: item.concept,
|
concept: item.concept,
|
||||||
reason: item.reason,
|
reason: item.reason,
|
||||||
concept_code: item.concept_code,
|
|
||||||
// 保留原有字段以兼容 DetailedConceptCard
|
// 保留原有字段以兼容 DetailedConceptCard
|
||||||
score: 1, // 数据库中的都是高相关度
|
score: 1, // 数据库中的都是高相关度
|
||||||
description: item.reason, // reason 作为描述
|
description: item.reason, // reason 作为描述
|
||||||
|
|||||||
Reference in New Issue
Block a user