Skip to content

实现 User Preferences 支持通用用户偏好与 Favorites 长期方案 #1100

@hotlong

Description

@hotlong

目标

设计并落地实现符合 ObjectStack Config Resolution 协议的 User Preferences Service。

  • 支持所有用户个性化配置,包括通用 scalar、结构型数据(如 favorites, recent_items)
  • 能安全替换现有 MVP 方案 (localStorage)
  • 长期架构可持续、盲升为 config 系统第2层实现

方案概要

  1. 规范 Schema(Spec 层)

    • 创建 packages/spec/src/identity/user-preference.zod.ts,定义 UserPreferenceEntry、FavoriteEntry、FavoritesValueSchema 等规范。
    • key 支持 well-known (theme, locale, favorites 等) 及插件自定义。
  2. 服务接口定义

    • 创建 packages/spec/src/contracts/user-preferences.ts,声明 IUserPreferencesService 统一交互接口,提供 get/set/delete/getAll/setMany 等方法。
  3. 服务插件实现

    • 使用 objectql 读写数据。
  4. 内核注册与暴露

    • 插件 init 时 ctx.registerService('user-preferences', impl)
    • 其他插件通过 ctx.getService('user-preferences') 消费。
  5. HTTP 路由对外暴露统一接口

    • /api/v1/user/preferences 支持 get, set, batch, delete, prefix 查询
    • /api/v1/user/preferences/favorites 专门支持收藏功能的 get/set
  6. 前端与 Studio 集成

    • Studio/Launcher 调用与本地缓存完全解耦。

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions