跳到主要内容

Interface: ContentProps<T>

Defined in: registry.tsx:25

registry — 内容类型注册表:每种 contentType 注册"标题 + 默认实例状态 + 渲染组件"。

通过 registerContent() 注册;T 由 defaults 推断并强制与 Comp 共享同一类型, 组件收到的 state/setState 均为该类型,无需强转。组件内仍可通过 useScene 等 hook 访问共享层(共享数据按身份全局一份)。

实例状态本身存于 areaStore(按 areaId × contentType 双键分槽,随 split/join/swap/dock 迁移), 这里只在组件渲染时按 (areaId, type) 桥接注入。

区域内容实例生命周期(区域几何创建/销毁由 layoutStore 负责,见 layoutStore/areaStore): 几何创建(G.addArea) → 首次渲染(defaults 注入 → onMount) → 存活期(setState 读写槽位) → 内容切换(旧类型 onUnmount → 新类型 onMount,状态分槽互不干扰) → 区域销毁(join/restore: onUnmount → ref 注销 → removeAreaStates)。 → 类型注销(unregisterContent: 手动 onUnmount → removeAreaStatesByType)。

Type Parameters

T

T = Record<string, unknown>

Properties

areaId

areaId: number

Defined in: registry.tsx:26


setState

setState: (patch) => void

Defined in: registry.tsx:32

增量更新本区域实例状态(只接受本类型字段)

Parameters

patch

Partial<T>

Returns

void


state

state: Partial<T>

Defined in: registry.tsx:30

本区域实例状态(类型即注册时 defaults 的推断类型)。 注意:defaults 在首帧渲染后的 useLayoutEffect 中注入,首帧 render 时可能缺字段, 故读取端类型为 Partial<T>,组件必须对缺字段兜底(如 state.view ?? 默认值)。