DirectSurface UIDirectSurface UI
开始使用
文档/API 参考

Runtime API 参考

本文示例使用:

import { Application, RenderWindow, type AppHost } from 'ds-ui'

应用级 UI 服务始终来自正在运行的 AppHost

function openRuntimeTools(host: AppHost): void {  const uiServices = host.uiServices  uiServices.showDevTools({ activeTab: 'runtime' })}

Runtime API 负责应用运行期的 canvas 管理、窗口挂载、布局绘制调度、图层合成、Popup/Tooltip 接入、布局检查、性能采样和运行时快照。业务系统通常通过 Application / AppHost 使用它;只有框架扩展、诊断工具和高级宿主集成才需要直接操作 RuntimeHost

Runtime API 不负责业务状态管理。业务状态应放在页面 controller、store、App Context 或后端服务中。

导出清单

应用入口:

  • Application
  • AppHost
  • ApplicationRunOptions
  • AppOverlayService
  • AppOverlayServiceConsumer

运行时核心:

  • RuntimeHost
  • RuntimeSize
  • RuntimeCaptureRect
  • RuntimeCaptureImageOptions
  • RuntimePaintRequestKind
  • RuntimePaintRequestSource
  • RuntimePaintRequestRecord

性能诊断:

  • RuntimePerformanceMonitor
  • RuntimePerformanceMonitorOptions
  • RuntimePerformanceDebugState
  • RuntimeFramePerformanceSample
  • PerformanceOverlayPosition
  • RenderRuntimeDiagnosticsPanel
  • RenderRuntimeDiagnosticsSnapshotViewer

布局检查:

  • LayoutInspectorService
  • LayoutInspectorDebugState
  • LayoutInspectorTreeNode
  • LayoutInspectorAppContextEntry
  • LayoutInspectorListener

诊断快照:

  • RuntimeDiagnosticsSnapshot
  • RuntimeDiagnosticsEnvironmentSnapshot
  • RuntimeDiagnosticsRuntimeSnapshot
  • RuntimeDiagnosticsLayerSnapshot
  • RuntimeDiagnosticsHotspot
  • RuntimeDiagnosticsPerformanceSnapshot
  • RuntimeDiagnosticsLayoutInspectorSnapshot
  • RuntimeDiagnosticsAppContextEntry
  • RuntimeDiagnosticsRenderTreeNode
  • RuntimeDiagnosticsWindowSnapshot
  • parseRuntimeDiagnosticsSnapshotJson
  • validateRuntimeDiagnosticsSnapshot
  • RuntimeDiagnosticsSnapshotValidationError

Overlay 服务相关:

  • AppModalOptions
  • AppAlertDialogOptions
  • AppConfirmDialogOptions
  • AppPromptDialogOptions
  • AppLoadingOptions
  • AppLoadingHandle
  • AppLoadingTask
  • AppOverlayContextOptions
  • AppPerformanceOverlayController
  • AppRuntimeDebugController
  • AppCanvasImageDownloadOptions

Application

Application 是推荐的应用启动入口。

const runtimeWindow = new RenderWindow({ title: 'CIS' })const runtimeHost = Application.mount('#app').run(runtimeWindow)

Application.mount(selector)

参数 类型 说明
selector string 指向已有 HTMLCanvasElement 的 CSS selector。

如果 selector 找不到 canvas,或匹配元素不是 HTMLCanvasElement,会抛错。框架不会替业务自动创建 canvas。

属性:

属性 类型 说明
canvas HTMLCanvasElement | null 当前挂载的 canvas。

方法:

方法 返回值 说明
run(mainWindow, options?) AppHost 创建 runtime,挂载主窗口并启动首帧调度。

ApplicationRunOptions

字段 类型 默认值 说明
dpr number `window.devicePixelRatio
enableLayoutInspector boolean false 是否注册内置布局检查快捷键(Ctrl/Cmd+Shift+I 与相关 Escape 处理);Layout API 和 DevTools 的 Layout tab 始终可用。
enablePerformanceMonitoring boolean false 是否在后台采集帧性能数据,不创建或绘制性能浮层。
enablePerformanceOverlay boolean false 是否默认显示性能浮层;启用时也会自动开启性能采集。
getViewportSize () => { width; height } window.innerWidth/innerHeight 逻辑视口尺寸来源。
onResize (size: RuntimeSize) => void undefined canvas 尺寸变化后回调。
theme ThemeData 主窗口主题或默认暗色主题 初始主题。
context AppContextInitialValues 新建空上下文 应用级 App Context 初始值。

宿主框架嵌入时,推荐显式提供 getViewportSize,让 canvas 尺寸跟宿主容器一致,而不是默认使用整个浏览器窗口。

AppHost

AppHost 是应用实例生命周期壳,持有 runtime、overlay 服务和应用级上下文。

属性:

属性 类型 说明
theme ThemeData 当前 runtime 主题。
uiServices AppOverlayService 应用级 overlay、通知、加载、调试服务。
context AppContextRegistry 应用级上下文。

方法:

方法 返回值 说明
captureImageDataUrl(options?) string 导出当前 canvas 画面为 data URL。
captureImageBlob(options?) Promise<Blob> 导出当前 canvas 画面为 Blob。
dispose() void 释放快捷键、overlay 服务、runtime 和应用级上下文。

宿主框架的 unmount / destroy 生命周期中应调用 host.dispose()。如果 canvas DOM 是宿主传入的,dispose 不会移除该 DOM。

RuntimeHostOptions

RuntimeHost 是底层运行时。通常由 AppHost 创建。

构造参数:

字段 类型 默认值 说明
canvas HTMLCanvasElement 必填 绘制目标 canvas。
onResize (size: RuntimeSize) => void undefined resize 后回调。
onFrame () => void undefined 每次 frame 渲染后回调。
dpr number `window.devicePixelRatio
getViewportSize () => { width; height } window.innerWidth/innerHeight 逻辑视口尺寸。
appContext AppContextRegistry 新建空上下文 runtime 根上下文。
enablePerformanceMonitoring boolean false 是否在后台采集帧性能数据。
enablePerformanceOverlay boolean false 是否启用性能浮层;启用时也会自动开启性能采集。
debugPaintRequests boolean URL/localStorage 配置 是否在控制台输出 paint request。

RuntimeSize

字段 类型 说明
width number 逻辑宽度。
height number 逻辑高度。
dpr number 设备像素比。

RuntimeHost 属性

属性 类型 说明
canvas HTMLCanvasElement 绘制目标。
dpr number 设备像素比。
compositor Compositor 图层合成器。
dispatcher EventDispatcher 指针、键盘、命中测试分发器。
frameScheduler FrameScheduler 帧调度器。
pipelineOwner PipelineOwner layout/paint 管线所有者。
layerManager 内部图层管理器 图层注册与绘制管理。
layoutInspector LayoutInspectorService 布局检查服务。
performanceMonitor RuntimePerformanceMonitor 性能采样和浮层控制器。
canvasWidth number 当前逻辑 canvas 宽度。
canvasHeight number 当前逻辑 canvas 高度。
viewportWidth number 当前逻辑视口宽度。
viewportHeight number 当前逻辑视口高度。
theme ThemeData 当前主题。
performanceOverlayVisible boolean 性能浮层是否可见。
paintRequestDebugEnabled boolean paint request 调试日志是否开启。

帧调度和绘制

方法 返回值 说明
scheduleFrame(reason?, detail?) void 请求下一帧绘制。
scheduleLayout(reason?, detail?) void 请求 layout + paint。
consumeLayoutNeeded() boolean 消费当前 layout-needed 标记。
renderFrame() void 立即执行一帧。一般由 scheduler 调用。
resize() RuntimeSize 重新读取视口尺寸、调整 canvas 和根约束。
flushLayout() void 刷新 pipeline layout。
flushPaint(context) void 刷新 pipeline paint。
clearPaintRequests() void 清空 pipeline paint 请求。

scheduleFrame() 只表示需要绘制;scheduleLayout() 表示需要重新 layout。组件内部应通过 markNeedsPaint() / markNeedsLayout() 触发管线,不应绕过管线直接调用 runtime。

主窗口和根节点

方法 返回值 说明
runMainWindow(mainWindow, options?) void 挂载唯一主窗口。重复调用会抛错。
addRoot(root) void 添加根 render object。
removeRoot(root) void 移除根对象并从 pipeline 忘记它。
bringToFront(root) void 将根或窗口分支提升到最前。
getRoots() RenderObject[] 获取当前根对象。
paintRoots(context, shouldPaint?, offsetFor?) void 绘制根对象。
setRootConstraints(root, constraints) void 设置根 layout 约束并标记 layout。

RuntimeMainWindowOptions

字段 类型 说明
onMainWindowClose () => void 主窗口关闭时回调。AppHost 用它触发 dispose。

主窗口关闭会释放整个应用实例;普通 owned window 关闭只移除该窗口分支。

主题

方法 返回值 说明
initTheme(theme) void 初始化主题。通常在运行前调用。
setTheme(theme) void 切换主题,根节点会重新 layout,所有图层标脏。

如果主窗口 resolveWindowTheme() 返回不同主题,runtime 在布局前会同步主窗口主题。

尺寸同步目标

尺寸同步适合给图表、外部 canvas、调试面板等对象同步 runtime 尺寸。

RuntimeSizeDependent

方法 说明
updateCanvas(width, height, size) runtime 尺寸变化时调用。

方法:

方法 返回值 说明
addSizeDependent(target, notifyImmediately?) () => void 注册尺寸监听函数或对象。默认立即通知。
removeSizeDependent(target) void 移除尺寸监听。
addManagedTarget(target, options?) () => void 注册可管理目标,目前支持尺寸同步。

RuntimeManagedTargetOptions

字段 类型 默认值 说明
size boolean 根据 target 自动判断 是否启用尺寸同步。
notifyImmediately boolean true 注册后是否立即通知。

图层

方法 返回值 说明
registerLayer(registration) () => void 注册图层。
registerLayerPainter(registration) () => void 注册图层绘制器。
markLayerDirty(layer) void 标记整个图层脏。
markLayerDirtyRect(layer, rect) void 标记图层局部脏矩形。
markAllLayersDirty() void 标记全部图层脏。
isLayerDirty(layer) boolean 判断图层是否脏。
paintLayers() LayerPaintTimings 绘制全部需要更新的图层。
hasDirtyPaintForRoot(root) boolean 根子树是否有脏 paint。
hasDirtyPaintForRoots(roots) boolean 任意根子树是否有脏 paint。
getDirtyPaintRectForRoots(roots) DirtyRect | undefined 合并根集合的脏矩形。

业务组件通常不直接注册 runtime 图层。新增框架级 overlay、调试层或特殊合成层时才需要使用。

Paint Request 调试

RuntimePaintRequestRecord 用于分析是谁请求了重绘或 layout。

字段 类型 说明
seq number 请求序号。
time number 时间戳。
kind 'frame' | 'layout' 请求类型。
source 'pipeline' | 'overlay' | 'runtime' | 'window' | 'debug' 按 reason 推断的来源。
reason string 请求原因。
detail unknown 安全化后的附加信息。
alreadyScheduled boolean 请求时是否已有 frame。
layoutNeeded boolean 请求时是否已需要 layout。
dirtyLayers object[] 当时脏图层信息。
pipeline object 当时 pipeline paint 状态。
stack string[] | undefined 开启 debug 后记录的调用栈。

方法:

方法 返回值 说明
setPaintRequestDebugEnabled(enabled) void 开关控制台日志和 stack 记录。
getPaintRequestHistory(limit?) RuntimePaintRequestRecord[] 获取最近请求,默认最多 80 条。
clearPaintRequestHistory() void 清空历史。

debugPaintRequests 适合定位异常频繁重绘。不要在生产环境长期开启 stack 记录。

性能浮层

RuntimePerformanceMonitor 采集帧耗时,并绘制可拖动、可缩小的性能浮层。

RuntimePerformanceMonitorOptions

字段 类型 默认值 说明
enabled boolean false 是否采集帧性能数据;visibletrue 时会强制启用。
visible boolean false 初始是否显示性能浮层;显示时会自动开启采集。
position 'top-left' | 'top-right' 'top-right' 默认位置。
maxSamples number 120 样本保留数量,最小 10。
slowFrameThresholdMs number 16.7 慢帧阈值。
onInvalidate () => void undefined 浮层自身状态变化后的重绘回调。

常用方法:

方法 返回值 说明
setPerformanceMonitoringEnabled(enabled) void 开关后台帧采集;浮层可见时不能关闭采集。
setPerformanceOverlayVisible(visible) void 设置性能浮层可见性。
togglePerformanceOverlay() boolean 切换性能浮层并返回新状态。
performanceMonitor.debugState() RuntimePerformanceDebugState 获取浮层状态、平均耗时、慢帧数量和矩形。
performanceMonitor.debugSamples(limit?) RuntimeFramePerformanceSample[] 获取最近帧样本。

后台采集与浮层显示是两个状态:可以只开启 enabled 在后台采集而不创建浮层;但只要浮层可见,采集就一定处于开启状态。隐藏浮层不会自动清空历史样本,也不会替调用方关闭已经开启的后台采集。

RuntimeFramePerformanceSample

字段 类型 说明
seq number 样本序号。
totalMs number 整帧总耗时。
layoutMs number layout 耗时。
paintMs number 图层绘制耗时。
contentPaintMs number | undefined 主内容图层耗时。
transientPaintMs number | undefined transient 图层耗时。
compositeMs number 合成耗时。
layoutNeeded boolean 本帧是否执行 layout。
rootCount number 根对象数量。
layerCount number 图层数量。

布局检查

LayoutInspectorService 用于检查 render tree、命中路径、节点矩形和 App Context。

节点类型名来自 RenderObject.debugInfo().typeName。框架组件应声明稳定的 static debugTypeName,业务实例可用 debugTypeName 覆盖类型语义,用 debugName 标识实例语义。constructor.name 只作为 fallback,不应作为发布态调试标识依赖。

属性:

属性 类型 说明
enabled boolean 是否启用检查。
overlayVisible boolean overlay 是否可见。
hoverPath HitTestResult | null 当前 hover 命中路径。
selectedPath HitTestResult | null 当前选中命中路径。

方法:

方法 返回值 说明
hoverAt(position) void 更新 hover 命中路径。
inspectAt(position) void 选中某个坐标下的 render 路径。
lockSelection() void 将当前 hover 路径锁定为选中路径。
selectSelectedPathIndex(index) boolean 选择命中路径上的某一级节点。
clearSelection() void 清空 hover 和 selection。
deactivate() void 关闭并清理布局检查状态。
toggleOverlay(force?) boolean 切换 overlay 可见性。
setIgnoredRoot(root, ignored) void 设置某个 root 是否被 debug hit test 忽略。
selectTreeNode(debugId) boolean 从 render tree 面板选择节点。
subscribe(listener) () => void 订阅 debug state。订阅时会立即回调一次。
debugState() LayoutInspectorDebugState 获取当前状态。
shouldPaint() boolean overlay 是否需要绘制。
paint(context) void 绘制检查 overlay。

LayoutInspectorDebugState

字段 类型 说明
enabled boolean 是否启用。
overlayVisible boolean overlay 是否可见。
hoverPathLength number hover 路径长度。
selectedPathLength number selected 路径长度。
selectedPathIndex number 当前选中的路径层级。
hoverPathInfo 节点调试信息数组 hover 路径上的节点信息。
selectedPathInfo 节点调试信息数组 selected 路径上的节点信息。
selectedAppContext LayoutInspectorAppContextEntry[] | undefined 当前节点可见上下文。
renderTree LayoutInspectorTreeNode | undefined 当前 root 的 render tree。
hover 节点调试信息或 undefined 当前 hover 节点。
selected 节点调试信息或 undefined 当前 selected 节点。
selectedRenderObject RenderObject | undefined 当前 selected render object。

诊断快照

createDiagnosticsSnapshot() 会生成 RuntimeDiagnosticsSnapshot

顶层字段:

字段 类型 说明
version 1 快照版本。
createdAt string ISO 时间。
environment RuntimeDiagnosticsEnvironmentSnapshot 浏览器、viewport、canvas、dpr。
runtime RuntimeDiagnosticsRuntimeSnapshot runtime 状态。
layers RuntimeDiagnosticsLayerSnapshot 注册和脏图层。
pipeline object pipeline 状态。
paintRequests RuntimePaintRequestRecord[] 最近绘制请求。
hotspots RuntimeDiagnosticsHotspot[] 聚合后的重绘热点。
performance RuntimeDiagnosticsPerformanceSnapshot 性能状态和样本。
layoutInspector RuntimeDiagnosticsLayoutInspectorSnapshot 布局检查状态。
appContext RuntimeDiagnosticsAppContextEntry[] 根上下文摘要。
roots RuntimeDiagnosticsRenderTreeNode[] render tree 快照。
windows RuntimeDiagnosticsWindowSnapshot[] 窗口状态。

快照用于问题定位和离线分析,不是业务持久化格式。快照可能包含业务状态摘要,导出前应按系统要求脱敏。

Canvas 截图

RuntimeHostAppHost 都提供截图导出。

RuntimeCaptureImageOptions

字段 类型 默认值 说明
rect RuntimeCaptureRect 整个画布 按逻辑坐标裁剪导出区域。
type string 'image/png' 图片 MIME 类型,例如 image/pngimage/jpeg
quality number 浏览器默认 JPEG/WebP 等有损格式质量参数。
scale number 当前 dpr 输出图片每个逻辑像素对应的图片像素数。
renderPendingFrame boolean true 导出前是否先刷新 pending frame。

RuntimeCaptureRect

字段 类型 说明
x number 逻辑 x。
y number 逻辑 y。
width number 逻辑宽度,必须大于 0。
height number 逻辑高度,必须大于 0。
const runtimeCaptureWindow = new RenderWindow({ title: '截图示例' })const runtimeCaptureHost = Application.mount('#app').run(runtimeCaptureWindow) void runtimeCaptureHost.captureImageBlob({  rect: { x: 0, y: 0, width: 640, height: 360 },  scale: 2,}).then(blob => {  blob.size})

截图 API 只导出当前 canvas 像素。批量文档截图、场景切换、文件命名、隐藏浮层等属于业务或文档工具策略。

AppOverlayService

AppOverlayService 是应用级 UI 服务集合,包含通知、上下文菜单、模态框、加载、tooltip、布局检查、运行时诊断和截图下载。

属性:

属性 类型 说明
notificationManager NotificationManager 通知管理器。
tooltipManager TooltipManager tooltip 管理器。
contextMenuManager ContextMenuManager 上下文菜单管理器。
activeModal RenderModal | RenderPromptModal | null 当前活动 modal。
disposed boolean 是否已释放。
floatingWindows readonly RenderWindow[] 当前浮动窗口。
dockWindows readonly RenderWindow[] 当前宿主停靠窗口。
layoutInspectorDebugState LayoutInspectorDebugState | null 布局检查状态。
layoutInspectorPanel 布局检查窗口或 null 布局检查窗口。
runtimeDiagnosticsPanel RenderRuntimeDiagnosticsPanel | null 运行时诊断窗口。
runtimeDiagnosticsSnapshotViewer RenderRuntimeDiagnosticsSnapshotViewer | null 快照查看窗口。
performanceOverlayVisible boolean 性能浮层是否可见。
paintRequestDebugEnabled boolean paint request 调试是否开启。
paintRequestHistory RuntimePaintRequestRecord[] 最近绘制请求。

常用方法:

方法 返回值 说明
showNotification(type, title, message?, duration?) number 显示通知并返回 id。
closeNotification(id?) void 关闭指定通知或全部通知。
showContextMenu(items, position, onSelect?) void 显示上下文菜单。
hideContextMenu() void 隐藏上下文菜单。
showLoading(options) AppLoadingHandle 显示加载框。
withLoading(options, task) Promise<T> 自动显示并关闭加载框。
showTooltip(text, position, delay?) void 显示字符串 tooltip,支持 \n 多行短文本。rich tooltip 请使用 TooltipManager / TooltipService 或组件声明式 tooltip。
updateTooltip(position) void 更新 tooltip 位置。
hideTooltip() void 隐藏 tooltip。
showModal(options) RenderModal 显示自定义 modal。
alert(options) Promise<void> 显示 alert。
confirm(options) Promise<boolean> 显示确认框。
prompt(options) Promise<string | null> 显示输入框。
closeModal(buttonKey?) void 关闭当前 modal。
showWindow(window, options?) RenderWindow 显示浮动窗口。
showDockWindow(window, options?) RenderWindow 把窗口停靠到宿主左侧、右侧或底部工具区。
closeDockWindow(window) void 关闭宿主停靠窗口。
setPerformanceOverlayVisible(visible) boolean 设置性能浮层。
togglePerformanceOverlay() boolean 切换性能浮层。
setPaintRequestDebugEnabled(enabled) boolean 开关 paint request 调试。
togglePaintRequestDebug() boolean 切换 paint request 调试。
getPaintRequestHistory(limit?) RuntimePaintRequestRecord[] 获取绘制请求历史。
clearPaintRequestHistory() void 清空绘制请求历史。
showRuntimeDiagnosticsPanel() RenderRuntimeDiagnosticsPanel 打开诊断窗口。
toggleRuntimeDiagnosticsPanel() boolean 切换诊断窗口。
showRuntimeDiagnosticsSnapshotViewer(snapshot) RenderRuntimeDiagnosticsSnapshotViewer 打开快照查看器。
inspectLayoutAt(position) LayoutInspectorDebugState 检查某坐标下布局。
toggleLayoutInspectorOverlay(position?) LayoutInspectorDebugState 切换布局检查 overlay。
clearLayoutInspectorSelection() LayoutInspectorDebugState 清空布局检查选区。
selectLayoutInspectorPathIndex(index) LayoutInspectorDebugState 选择命中路径层级。
selectLayoutInspectorTreeNode(debugId) LayoutInspectorDebugState 在 render tree 中选择节点。
downloadCanvasImage(options?) Promise<Blob> 截图并触发浏览器下载。
captureCanvasImageDataUrl(options?) string 截图为 data URL。
captureCanvasImageBlob(options?) Promise<Blob> 截图为 Blob。

Overlay 方法中的 sourcecontextcontextValuesdisposeContextOnClose 用于控制弹窗上下文。需要继承页面上下文时传入触发源 source

showDockWindow() 用于开发者工具、请求日志、布局检查器这类宿主级工具区。停靠窗口是独立 runtime root,不是主窗口 owned window;主内容 viewport 会被停靠区域挤压,普通 modal、loading、popup 只覆盖主内容区。停靠窗口使用 host-docked chrome:标题栏提供左侧/右侧/底部/浮动切换,不提供最大化按钮;和主内容相邻的边缘可拖拽调整尺寸。同一 side 上的多个停靠窗口会共享该 side 的厚度,并沿垂直或水平方向分段显示,避免互相覆盖。业务流程中的抽屉、局部选择器和阻断遮罩仍应使用 Drawer、Modal、Popup 或 RenderOverlayHost

AppDockWindowOptions 继承 AppOverlayContextOptions,并支持:

选项 类型 默认值 说明
side 'left' | 'right' | 'bottom' 'right' 停靠方位。
size number 420 停靠区域目标尺寸。
minSize number 0 停靠区域最小尺寸。
maxSize number 根据 viewport 自动限制 停靠区域最大尺寸。

生命周期和销毁

RuntimeHost.dispose() 会处理:

  • 卸载主窗口、owned windows 和宿主停靠窗口。
  • 从 dispatcher 移除 roots。
  • pipelineOwner.forget(root)root.dispose()
  • 释放 frame scheduler、dispatcher、tooltip manager。
  • 重置焦点、输入、键盘绑定、Popup 和 overlay invalidator 等运行时单例。
  • 释放 pipelineOwner.appContext
  • 清空 size dependents 和 paint request history。

AppHost.dispose() 还会释放 overlay 服务和应用级上下文。宿主框架关闭页面、Vue/React unmount 或切换微前端实例时,应明确调用它。

使用边界

  • 普通业务页面不要直接调用 RuntimeHost.addRoot(),优先通过窗口、workspace、modal 或 overlay 服务管理。
  • 不要在组件 paint 阶段调用 runtime layout/resize API。
  • 性能浮层和 paint request debug 适合开发与测试环境,生产环境应由业务开关控制。
  • 诊断快照可能包含业务状态摘要,导出或上传前要脱敏。
  • 截图导出的是当前 canvas,不代表打印输出。文档打印应使用专门打印管线。
  • 如果 canvas DOM 由宿主创建,runtime dispose 不会移除 DOM,宿主仍负责 DOM 生命周期。

主题来源优先级

Application.run(mainWindow, { theme }) 中显式传入的主题属于 runtime 主题源,不会在首帧被 mainWindow.resolveWindowTheme() 覆盖。

  • AppHost.setTheme(theme):设置并保持显式 runtime 主题。
  • AppHost.useMainWindowTheme():恢复跟随主窗口主题。
  • 未传入 ApplicationRunOptions.theme 时,默认跟随主窗口 resolveWindowTheme();主窗口未提供主题时使用默认暗色主题。

主题值相同但对象不同不会重复安排布局。仅颜色变化时 runtime 标记重绘;字体、尺寸或 typography 变化时才标记根节点重新布局。主窗口主题在当前布局帧内完成同步,不会因此额外安排一个无效后续帧。

相关文档