# Changelog — 服务器列表搜索记录存数据库 **日期**:2026-06-11 ## 摘要 服务器页搜索历史与上次搜索词改为按管理员存入 MySQL `admin_ui_preferences`,换浏览器/清缓存仍可恢复;首次加载自动迁移旧版 localStorage。 ## 动机 用户要求搜索记录持久化到数据库,而非仅本机 localStorage。 ## 涉及文件 - `server/domain/models/__init__.py` — `AdminUiPreference` - `server/infrastructure/database/admin_ui_preference_repo.py` - `server/infrastructure/database/migrations.py` — 建表 - `server/utils/server_search_history.py` — 归一化/合并规则 - `server/api/servers.py` — `GET/PUT /api/servers/search-history` - `server/api/schemas.py` — `ServerSearchHistoryUpdate` - `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` - 需重启/部署后端;前端需构建部署 ## 验证 ```bash pytest tests/test_server_search_history.py -q cd frontend && npm run type-check ``` 服务器页搜索 → 换浏览器同账号登录 → 历史与上次搜索仍在。