Files
Nexus/docs/changelog/2026-06-11-servers-search-history.md
T
Nexus Agent 130cc840c7 feat: 服务器搜索历史持久化到 MySQL
按管理员将 Servers 页搜索记录存入 admin_ui_preferences,换设备登录仍可恢复;首次自动迁移 localStorage。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-11 17:46:52 +08:00

1.4 KiB
Raw Blame History

Changelog — 服务器列表搜索记录存数据库

日期2026-06-11

摘要

服务器页搜索历史与上次搜索词改为按管理员存入 MySQL admin_ui_preferences,换浏览器/清缓存仍可恢复;首次加载自动迁移旧版 localStorage。

动机

用户要求搜索记录持久化到数据库,而非仅本机 localStorage。

涉及文件

  • server/domain/models/__init__.pyAdminUiPreference
  • server/infrastructure/database/admin_ui_preference_repo.py
  • server/infrastructure/database/migrations.py — 建表
  • server/utils/server_search_history.py — 归一化/合并规则
  • server/api/servers.pyGET/PUT /api/servers/search-history
  • server/api/schemas.pyServerSearchHistoryUpdate
  • frontend/src/composables/useServerSearchHistory.ts
  • frontend/src/pages/ServersPage.vue
  • tests/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

服务器页搜索 → 换浏览器同账号登录 → 历史与上次搜索仍在。