Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Commit 32d2f7a

Browse files
committed
feat(ui): Add data migration and Milky webhook token configuration
1 parent b1b13a1 commit 32d2f7a

2 files changed

Lines changed: 25 additions & 5 deletions

File tree

ui/home_page.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -849,6 +849,7 @@ def _do_stop_services(self, stop_qq: bool = False):
849849

850850
def _on_global_start_click(self, e):
851851
import logging
852+
import shutil
852853
from datetime import datetime
853854
from core.log_collector import LogEntry
854855
logger = logging.getLogger(__name__)
@@ -858,6 +859,17 @@ def _on_global_start_click(self, e):
858859
logger.info("正在下载中,忽略点击")
859860
return
860861

862+
# 迁移旧版 llonebot 数据目录到 llbot
863+
old_data_dir = Path("bin/llonebot/data")
864+
new_data_dir = Path("bin/llbot/data")
865+
if old_data_dir.exists() and not new_data_dir.exists():
866+
try:
867+
new_data_dir.parent.mkdir(parents=True, exist_ok=True)
868+
shutil.copytree(old_data_dir, new_data_dir)
869+
logger.info(f"已迁移数据目录: {old_data_dir} -> {new_data_dir}")
870+
except Exception as ex:
871+
logger.warning(f"迁移数据目录失败: {ex}")
872+
861873
# 立即更新按钮状态为"已启动",提供即时反馈
862874
self._update_button_state(True)
863875

ui/llbot_config_page.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class LLBotConfigPage:
1616
"enable": False,
1717
"reportSelfMessage": False,
1818
"http": {"port": 3010, "prefix": "", "accessToken": ""},
19-
"webhook": {"urls": []}
19+
"webhook": {"urls": [], "accessToken": ""}
2020
},
2121
"enableLocalFile2Url": False,
2222
"log": True,
@@ -130,7 +130,9 @@ def build(self):
130130
value=milky_cfg.get("http", {}).get("prefix", ""))
131131
self.milky_http_token = ft.TextField(label="AccessToken", width=200,
132132
value=milky_cfg.get("http", {}).get("accessToken", ""))
133-
# Webhook URLs 动态列表
133+
# Webhook
134+
self.milky_webhook_token = ft.TextField(label="Webhook AccessToken", width=200,
135+
value=milky_cfg.get("webhook", {}).get("accessToken", ""))
134136
self.milky_webhook_url_controls: List[ft.TextField] = []
135137
self.milky_webhook_container = ft.Column(spacing=8)
136138
self._rebuild_webhook_urls(milky_cfg.get("webhook", {}).get("urls", []))
@@ -211,13 +213,17 @@ def build(self):
211213
ft.Row([self.milky_http_port, self.milky_http_prefix, self.milky_http_token], spacing=16),
212214
ft.Container(
213215
content=ft.Column([
216+
ft.Row([
217+
ft.Text("Webhook", size=14, weight=ft.FontWeight.W_500),
218+
self.milky_webhook_token,
219+
], spacing=8, vertical_alignment=ft.CrossAxisAlignment.CENTER),
214220
ft.Row([
215221
ft.Text("Webhook URLs", size=14, weight=ft.FontWeight.W_500),
216222
ft.IconButton(icon=ft.Icons.ADD_CIRCLE, tooltip="添加URL",
217223
on_click=self._on_add_webhook_url, icon_size=20),
218-
], spacing=8),
224+
], spacing=8, vertical_alignment=ft.CrossAxisAlignment.CENTER),
219225
self.milky_webhook_container,
220-
], spacing=4),
226+
], spacing=8),
221227
),
222228
]),
223229
self._section("其他配置", ft.Icons.MORE_HORIZ, [
@@ -466,7 +472,8 @@ def _on_save(self, e):
466472
"accessToken": self.milky_http_token.value or ""
467473
},
468474
"webhook": {
469-
"urls": self._collect_webhook_urls()
475+
"urls": self._collect_webhook_urls(),
476+
"accessToken": self.milky_webhook_token.value or ""
470477
}
471478
},
472479
"enableLocalFile2Url": self.enable_local_file2url.value,
@@ -502,6 +509,7 @@ def _update_ui(self):
502509
self.milky_http_port.value = str(milky_cfg.get("http", {}).get("port", 3010))
503510
self.milky_http_prefix.value = milky_cfg.get("http", {}).get("prefix", "")
504511
self.milky_http_token.value = milky_cfg.get("http", {}).get("accessToken", "")
512+
self.milky_webhook_token.value = milky_cfg.get("webhook", {}).get("accessToken", "")
505513
self._rebuild_webhook_urls(milky_cfg.get("webhook", {}).get("urls", []))
506514
self.enable_local_file2url.value = cfg.get("enableLocalFile2Url", False)
507515
self.log_enable.value = cfg.get("log", True)

0 commit comments

Comments
 (0)