130cc840c7
按管理员将 Servers 页搜索记录存入 admin_ui_preferences,换设备登录仍可恢复;首次自动迁移 localStorage。 Co-authored-by: Cursor <cursoragent@cursor.com>
1.4 KiB
1.4 KiB
Changelog — 服务器列表搜索记录存数据库
日期:2026-06-11
摘要
服务器页搜索历史与上次搜索词改为按管理员存入 MySQL admin_ui_preferences,换浏览器/清缓存仍可恢复;首次加载自动迁移旧版 localStorage。
动机
用户要求搜索记录持久化到数据库,而非仅本机 localStorage。
涉及文件
server/domain/models/__init__.py—AdminUiPreferenceserver/infrastructure/database/admin_ui_preference_repo.pyserver/infrastructure/database/migrations.py— 建表server/utils/server_search_history.py— 归一化/合并规则server/api/servers.py—GET/PUT /api/servers/search-historyserver/api/schemas.py—ServerSearchHistoryUpdatefrontend/src/composables/useServerSearchHistory.tsfrontend/src/pages/ServersPage.vuetests/test_server_search_history.py
API
| 方法 | 路径 | 说明 |
|---|---|---|
| GET | /api/servers/search-history |
{ history: string[], last: string | null } |
| PUT | /api/servers/search-history |
{ query } 记录一条,或 { history, last? } 整表替换 |
迁移 / 重启
- 启动时 schema migration 自动建表
admin_ui_preferences - 需重启/部署后端;前端需构建部署
验证
pytest tests/test_server_search_history.py -q
cd frontend && npm run type-check
服务器页搜索 → 换浏览器同账号登录 → 历史与上次搜索仍在。