feat(data): add repository layer with Auth/Chat/User/Metrics + shared Result<T>

引入仓库层(`src/data/repositories/`),对齐原 Dart `lib/data/repositories/`
的四个仓库:Auth(hybrid: API+AuthStorage+UserStorage)、Chat(hybrid:
API+LocalChatStorage via Dexie)、User(纯远程)、Metrics(纯远程)。

同步抽取 4 个 `*_api.ts` 中重复的 envelope-unwrap 代码到
`src/data/api/response_helper.ts`,失败时抛 `ApiError`(之前抛裸 Error)。

新建 `src/data/result.ts` 提供仓库层统一 `Result<T>`(`{success,data}` 形态),
与 `src/data/storage/result.ts`(`{kind,value}` 形态)并存。

更新 `barrelsby.json` 让 `src/data/repositories/` 加入 barrel 生成。
This commit is contained in:
2026-06-08 19:16:28 +08:00
parent 75e685d418
commit a240f5965d
13 changed files with 695 additions and 71 deletions
+2 -1
View File
@@ -10,7 +10,8 @@
"./src/data/storage/auth",
"./src/data/storage/user",
"./src/data/storage/chat",
"./src/data/storage/app",
"./src/data/storage/app",
"./src/data/repositories",
"./src/design"
]
}