fix(admin): 主人账号编辑器草稿改存无损形态 ——「+ 添加账号 ID」不再点了没点
根因:`emit` 把每次改动都写成 `flattenAccounts(groups)`(写盘形态,空行被丢掉),而 草稿本身就是界面手势的往返载体 ⇒ 刚点出来的占位空行当场蒸发,界面照旧(主人报的 「配置指定适配器主人账号的卡片内的添加账号ID按钮似乎没用」)。`+ 添加平台` 走同一条 通路(空平台组同样被丢),实测同样失效。 改法:分清两种扁平形态 —— · 草稿 `draftAccounts`(编辑期,无损:空行/未选平台的组都留着;不 trim 正在输入的字) · 写盘形态 `accountsForSave`(保存期,只留平台与账号 ID 都非空的条目) 后端契约与 `configs/users/owner.yaml` 格式一个字不改。保存路径写盘前必须收形:半成品 条目(有 id 没平台)会被后端 `Validate()` 直接 400(internal/user/load.go)。 测试:`OwnerAccountsView` 从编辑器里拆出来(无 hook),测试可直接调用它、点它自己的 按钮、把 onChange 收到的真草稿再喂回去重渲染 —— 走的是「手势 → 草稿 → 界面」真往返 (本项目没有 jsdom)。修前该测试红在「点『+ 添加账号 ID』⇒ 界面上真的多出一行 — got 1, want 2」。
This commit is contained in:
1 parent
b01e2ddb1a
commit
625ae33c1e
5 files changed
+369
-19
No files matched your search
@@ -357,6 +357,13 @@ export interface OwnerProfile {
|
||||
defaultPersona: string;
|
||||
identityFile: string;
|
||||
notes: string;
|
||||
/**
|
||||
* Channel account whitelist. While the panel is being edited this array is a **draft**: a row may
|
||||
* legitimately be blank (`accountId: ""`, or no platform picked yet) because every UI gesture
|
||||
* round-trips through it — dropping blank rows here makes a freshly added row disappear, i.e. the
|
||||
* button looks dead. Only the save path narrows it (`accountsForSave`), so owner.yaml and the PUT
|
||||
* contract keep carrying entries with both `platform` and `accountId` set.
|
||||
*/
|
||||
accounts: OwnerAccount[];
|
||||
}
|
||||
export interface OwnerAccount {
|
||||
|
||||
Reference in new issue
Block a user