fix(DailySummary): 修复详情页面不显示问题

- 参考 BrushFlow 的 get_page 结构,将所有内容放在单个 VRow 内
- 无数据时返回「暂无数据」提示
- 表格 height 改为 '30rem'(字符串)
- 统计卡片对齐官方组件风格
This commit is contained in:
YuHoYe
2026-02-09 00:41:43 +08:00
parent ff7d7b1fa4
commit 82c825e349

View File

@@ -339,75 +339,91 @@ class DailySummary(_PluginBase):
# ─── 历史记录页面 ───
def get_page(self) -> Optional[List[dict]]:
def get_page(self) -> List[dict]:
history = self.get_data("history") or []
if not history:
return [
{
'component': 'div',
'text': '暂无数据',
'props': {
'class': 'text-center',
}
}
]
daily_count = sum(1 for r in history if r.get("type") == "daily")
weekly_count = sum(1 for r in history if r.get("type") == "weekly")
monthly_count = sum(1 for r in history if r.get("type") == "monthly")
# 表格数据
items = [
{
'time': r.get('time', ''),
'type_label': {'daily': '日报', 'weekly': '周报', 'monthly': '月报'}.get(r.get('type'), ''),
'title': r.get('title', ''),
'preview': (r.get('text', '')[:80] + '...') if len(r.get('text', '')) > 80 else r.get('text', ''),
}
for r in reversed(history)
]
return [
# 统计卡片
{
"component": "VRow",
"content": [
self._stat_card("📊 日报", f"{daily_count}"),
self._stat_card("📈 周报", f"{weekly_count}"),
self._stat_card("📅 月报", f"{monthly_count}"),
],
},
# 历史记录表格
{
"component": "VRow",
"content": [
'component': 'VRow',
'content': [
# 统计卡片
self._stat_card('📊 日报', f'{daily_count}'),
self._stat_card('📈 周报', f'{weekly_count}'),
self._stat_card('📅 月报', f'{monthly_count}'),
# 历史记录表格
{
"component": "VCol",
"props": {"cols": 12},
"content": [
'component': 'VCol',
'props': {'cols': 12, 'class': 'd-none d-sm-block'},
'content': [
{
"component": "VDataTableVirtual",
"props": {
"headers": [
{"title": "时间", "key": "time", "sortable": True, "width": "160px"},
{"title": "类型", "key": "type_label", "sortable": True, "width": "80px"},
{"title": "标题", "key": "title", "sortable": False},
{"title": "预览", "key": "preview", "sortable": False},
'component': 'VDataTableVirtual',
'props': {
'class': 'text-sm',
'headers': [
{'title': '时间', 'key': 'time', 'sortable': True},
{'title': '类型', 'key': 'type_label', 'sortable': True},
{'title': '标题', 'key': 'title', 'sortable': False},
{'title': '预览', 'key': 'preview', 'sortable': False},
],
"items": [
{
"time": r.get("time", ""),
"type_label": {"daily": "日报", "weekly": "周报", "monthly": "月报"}.get(r.get("type"), ""),
"title": r.get("title", ""),
"preview": (r.get("text", "")[:80] + "...") if len(r.get("text", "")) > 80 else r.get("text", ""),
}
for r in reversed(history)
],
"height": 400,
"fixed-header": True,
"density": "compact",
"hover": True,
'items': items,
'height': '30rem',
'density': 'compact',
'fixed-header': True,
'hide-no-data': True,
'hover': True,
},
}
],
}
},
],
},
}
]
@staticmethod
def _stat_card(title: str, value: str) -> dict:
return {
"component": "VCol",
"props": {"cols": 12, "md": 4},
"content": [{
"component": "VCard",
"props": {"variant": "tonal"},
"content": [{
"component": "VCardText",
"props": {"class": "text-center"},
"content": [
{"component": "div", "props": {"class": "text-subtitle-2"}, "text": title},
{"component": "div", "props": {"class": "text-h5 mt-1"}, "text": value},
'component': 'VCol',
'props': {'cols': 6, 'md': 4},
'content': [{
'component': 'VCard',
'props': {'variant': 'tonal'},
'content': [{
'component': 'VCardText',
'props': {'class': 'd-flex align-center'},
'content': [
{
'component': 'div',
'content': [
{'component': 'span', 'props': {'class': 'text-subtitle-2'}, 'text': title},
{'component': 'div', 'props': {'class': 'text-h6'}, 'text': value},
],
},
],
}],
}],