fix(DailySummary): 简化配置界面 + 修复通知标题重复

- 移除高级设置 tab(signin_plugin_id / brush_plugin_ids / storage_paths)
  这些内部实现细节不该暴露给用户,改为代码内硬编码默认值
  存储路径改为纯自动检测 MP 的 LIBRARY_PATH / DOWNLOAD_PATH
- 去掉 VTabs,报告模块选择器直接平铺
- Cron 字段和开关移到 VTabs 外面,避免弹出菜单被裁剪
- 修复通知标题重复:text 中不再拼接 header,由 post_message 的 title 参数单独传递
This commit is contained in:
YuHoYe
2026-02-09 23:23:39 +08:00
parent bb1f159198
commit 028103b900

View File

@@ -89,10 +89,6 @@ class DailySummary(_PluginBase):
_weekly_modules: list = None
_monthly_modules: list = None
_signin_plugin_id: str = "AutoSignIn"
_brush_plugin_ids: str = "BrushFlow"
_storage_paths: str = ""
def init_plugin(self, config: dict = None):
if config:
self._enabled = config.get("enabled", False)
@@ -105,12 +101,6 @@ class DailySummary(_PluginBase):
self._daily_modules = config.get("daily_modules") or DEFAULT_DAILY_MODULES
self._weekly_modules = config.get("weekly_modules") or DEFAULT_WEEKLY_MODULES
self._monthly_modules = config.get("monthly_modules") or DEFAULT_MONTHLY_MODULES
self._signin_plugin_id = config.get("signin_plugin_id", "AutoSignIn")
self._brush_plugin_ids = config.get("brush_plugin_ids", "BrushFlow")
self._storage_paths = config.get("storage_paths", "")
# 旧版本配置缺少新字段时,回写完整配置让前端能读到默认值
if "daily_modules" not in config:
self._save_config()
else:
self._daily_modules = DEFAULT_DAILY_MODULES
self._weekly_modules = DEFAULT_WEEKLY_MODULES
@@ -146,9 +136,6 @@ class DailySummary(_PluginBase):
"daily_modules": self._daily_modules,
"weekly_modules": self._weekly_modules,
"monthly_modules": self._monthly_modules,
"signin_plugin_id": self._signin_plugin_id,
"brush_plugin_ids": self._brush_plugin_ids,
"storage_paths": self._storage_paths,
})
def get_state(self) -> bool:
@@ -217,109 +204,58 @@ class DailySummary(_PluginBase):
{
"component": "VForm",
"content": [
# ── 基本设置VTabs 外面,避免弹出菜单被裁剪) ──
{
"component": "VTabs",
"props": {"model": "_tab", "style": "margin-top: -18px; margin-bottom: 12px;"},
"content": [
{"component": "VTab", "props": {"value": "basic"}, "text": "基本设置"},
{"component": "VTab", "props": {"value": "modules"}, "text": "报告内容"},
{"component": "VTab", "props": {"value": "advanced"}, "text": "高级设置"},
'component': 'VRow',
'content': [
{'component': 'VCol', 'props': {'cols': 12, 'md': 3},
'content': [{'component': 'VSwitch', 'props': {'model': 'enabled', 'label': '启用插件'}}]},
{'component': 'VCol', 'props': {'cols': 12, 'md': 3},
'content': [{'component': 'VSwitch', 'props': {'model': 'notify', 'label': '发送通知'}}]},
{'component': 'VCol', 'props': {'cols': 12, 'md': 3},
'content': [{'component': 'VSwitch', 'props': {'model': 'onlyonce', 'label': '立即测试一次'}}]},
{'component': 'VCol', 'props': {'cols': 12, 'md': 3},
'content': [{'component': 'VSelect', 'props': {'model': 'test_type', 'label': '测试类型', 'items': test_options}}]},
],
},
{
"component": "VWindow",
"props": {"model": "_tab"},
'component': 'VRow',
'content': [
{'component': 'VCol', 'props': {'cols': 12, 'md': 4},
'content': [{'component': 'VCronField', 'props': {'model': 'daily_cron', 'label': '每日周期', 'placeholder': '5位cron表达式'}}]},
{'component': 'VCol', 'props': {'cols': 12, 'md': 4},
'content': [{'component': 'VCronField', 'props': {'model': 'weekly_cron', 'label': '每周周期', 'placeholder': '5位cron表达式'}}]},
{'component': 'VCol', 'props': {'cols': 12, 'md': 4},
'content': [{'component': 'VCronField', 'props': {'model': 'monthly_cron', 'label': '每月周期', 'placeholder': '5位cron表达式'}}]},
],
},
# ── 报告内容 ──
{
"component": "VRow",
"props": {"style": "margin-top: 8px;"},
"content": [
# ── Tab 1: 基本设置 ──
{
"component": "VWindowItem",
"props": {"value": "basic"},
"content": [
{
"component": "VRow",
"content": [
{"component": "VCol", "props": {"cols": 12, "md": 4},
"content": [{"component": "VSwitch", "props": {"model": "enabled", "label": "启用插件"}}]},
{"component": "VCol", "props": {"cols": 12, "md": 4},
"content": [{"component": "VSwitch", "props": {"model": "notify", "label": "发送通知"}}]},
{"component": "VCol", "props": {"cols": 12, "md": 4},
"content": [{"component": "VSwitch", "props": {"model": "onlyonce", "label": "立即测试一次"}}]},
],
},
{
"component": "VRow",
"content": [
{"component": "VCol", "props": {"cols": 12, "md": 3},
"content": [{"component": "VCronField", "props": {"model": "daily_cron", "label": "每日周期"}}]},
{"component": "VCol", "props": {"cols": 12, "md": 3},
"content": [{"component": "VCronField", "props": {"model": "weekly_cron", "label": "每周周期"}}]},
{"component": "VCol", "props": {"cols": 12, "md": 3},
"content": [{"component": "VCronField", "props": {"model": "monthly_cron", "label": "每月周期"}}]},
{"component": "VCol", "props": {"cols": 12, "md": 3},
"content": [{"component": "VSelect", "props": {"model": "test_type", "label": "测试类型", "items": test_options}}]},
],
},
],
},
# ── Tab 2: 报告内容 ──
{
"component": "VWindowItem",
"props": {"value": "modules"},
"content": [
{
"component": "VRow",
"content": [
{"component": "VCol", "props": {"cols": 12},
"content": [{"component": "VAlert", "props": {"type": "info", "variant": "tonal", "text": "选择各报告中包含的信息模块,模块按选择顺序显示在报告中"}}]},
],
},
{
"component": "VRow",
"content": [
{"component": "VCol", "props": {"cols": 12, "md": 4},
"content": [{"component": "VSelect", "props": {
"model": "daily_modules", "label": "日报模块",
"items": MODULE_OPTIONS, "multiple": True, "chips": True, "closable-chips": True,
}}]},
{"component": "VCol", "props": {"cols": 12, "md": 4},
"content": [{"component": "VSelect", "props": {
"model": "weekly_modules", "label": "周报模块",
"items": MODULE_OPTIONS, "multiple": True, "chips": True, "closable-chips": True,
}}]},
{"component": "VCol", "props": {"cols": 12, "md": 4},
"content": [{"component": "VSelect", "props": {
"model": "monthly_modules", "label": "月报模块",
"items": MODULE_OPTIONS, "multiple": True, "chips": True, "closable-chips": True,
}}]},
],
},
],
},
# ── Tab 3: 高级设置 ──
{
"component": "VWindowItem",
"props": {"value": "advanced"},
"content": [
{
"component": "VRow",
"content": [
{"component": "VCol", "props": {"cols": 12},
"content": [{"component": "VAlert", "props": {"type": "info", "variant": "tonal", "text": "以下为高级配置,一般无需修改"}}]},
],
},
{
"component": "VRow",
"content": [
{"component": "VCol", "props": {"cols": 12, "md": 4},
"content": [{"component": "VTextField", "props": {"model": "signin_plugin_id", "label": "签到插件 ID", "placeholder": "AutoSignIn"}}]},
{"component": "VCol", "props": {"cols": 12, "md": 4},
"content": [{"component": "VTextField", "props": {"model": "brush_plugin_ids", "label": "刷流插件 ID", "placeholder": "BrushFlow", "hint": "多个用逗号分隔"}}]},
{"component": "VCol", "props": {"cols": 12, "md": 4},
"content": [{"component": "VTextField", "props": {"model": "storage_paths", "label": "存储监控路径", "placeholder": "留空自动检测", "hint": "格式: /media:媒体盘,/downloads:下载盘"}}]},
],
},
],
},
{"component": "VCol", "props": {"cols": 12},
"content": [{"component": "VAlert", "props": {"type": "info", "variant": "tonal", "text": "选择各报告中包含的信息模块,模块按选择顺序显示在报告中"}}]},
],
},
{
"component": "VRow",
"content": [
{"component": "VCol", "props": {"cols": 12, "md": 4},
"content": [{"component": "VSelect", "props": {
"model": "daily_modules", "label": "日报模块",
"items": MODULE_OPTIONS, "multiple": True, "chips": True, "closable-chips": True,
}}]},
{"component": "VCol", "props": {"cols": 12, "md": 4},
"content": [{"component": "VSelect", "props": {
"model": "weekly_modules", "label": "周报模块",
"items": MODULE_OPTIONS, "multiple": True, "chips": True, "closable-chips": True,
}}]},
{"component": "VCol", "props": {"cols": 12, "md": 4},
"content": [{"component": "VSelect", "props": {
"model": "monthly_modules", "label": "月报模块",
"items": MODULE_OPTIONS, "multiple": True, "chips": True, "closable-chips": True,
}}]},
],
},
],
@@ -335,9 +271,6 @@ class DailySummary(_PluginBase):
"daily_modules": DEFAULT_DAILY_MODULES,
"weekly_modules": DEFAULT_WEEKLY_MODULES,
"monthly_modules": DEFAULT_MONTHLY_MODULES,
"signin_plugin_id": "AutoSignIn",
"brush_plugin_ids": "BrushFlow",
"storage_paths": "",
}
# ─── 历史记录页面 ───
@@ -504,7 +437,7 @@ class DailySummary(_PluginBase):
sections.append(result)
header = self._make_header(report_type, tr)
text = header + "\n\n" + "\n\n".join(sections) if sections else header + "\n\n无数据"
text = "\n\n".join(sections) if sections else "无数据"
return header, text
def _calc_time_range(self, report_type: str) -> TimeRange:
@@ -608,7 +541,7 @@ class DailySummary(_PluginBase):
def _section_signin(self, tr: TimeRange) -> str:
pdo = PluginDataOper()
plugin_id = self._signin_plugin_id or "AutoSignIn"
plugin_id = "AutoSignIn"
now = tr.end
key = f"{now.month}{now.day}"
data = pdo.get_data(plugin_id, key)
@@ -628,7 +561,7 @@ class DailySummary(_PluginBase):
def _section_brush(self, tr: TimeRange) -> str:
pdo = PluginDataOper()
plugin_ids = [pid.strip() for pid in (self._brush_plugin_ids or "BrushFlow").split(",") if pid.strip()]
plugin_ids = ["BrushFlow"]
total_uploaded = 0
total_downloaded = 0
@@ -768,19 +701,7 @@ class DailySummary(_PluginBase):
return "\n".join(lines) if has_data else None
def _parse_storage_paths(self) -> List[Tuple[str, str]]:
"""解析用户配置的存储路径,或自动检测 MP 的 LIBRARY_PATH / DOWNLOAD_PATH"""
if self._storage_paths:
result = []
for item in self._storage_paths.split(","):
item = item.strip()
if ":" in item:
path, label = item.split(":", 1)
result.append((path.strip(), label.strip()))
elif item:
result.append((item, item))
return result
# 自动检测
"""自动检测 MP 的 LIBRARY_PATH / DOWNLOAD_PATH"""
paths = []
if hasattr(settings, "LIBRARY_PATH") and settings.LIBRARY_PATH:
paths.append((settings.LIBRARY_PATH, "媒体库"))