Skip to content

UI JS API

本页是 概览,完整列表见:

1. 核心全局函数

  • 生命周期:onMounted / onUnmounted / onActivated / onDeactivated
  • 响应式:ref / computed / watch / nextTick
  • 查询:useQuery / usePrefetch / invalidateQueries
  • UI 管理:requestOpenUI / closeUI / requestCloseUI
  • 动画:animate / enter / leave
  • 拖放:useDraggable / useDroppable / startDrag

2. 全局对象

  • Texture:纹理工厂
  • hotkeys:UI 级热键注册
  • sound:UI 级音效播放
  • internalSyncStore:同步数据(只读)
  • localStorage:UI 本地持久化

3. 常用示例

js
onMounted(() => {
  const btn = ref("ok")
  btn.setOnClick(() => sound.play("ui/confirm"))
})

hotkeys.register({ pattern: "CTRL, K", trigger: "press" }, () => {
  console.log("快捷键触发")
})