# API 支持列表

API 的支持情况在原子接口环境与原子组件环境下有所不同。以下从新增 API 和原有 API 两个维度分别列出支持的 API。

# 新增 API

此模式新增的 API 都在 ft.modelContext 命名空间下。

原子接口支持的如下:

  • 创建 Skill:ft.modelContext.createSkill(skillPath: string)
  • 注册原子接口:skill.registerAPI('name', handler)
  • 注册中间件:skill.use(Middleware)
  • 获取会话 ID:ft.modelContext.getSessionId()
  • 设置所有组件过期:ft.modelContext.expireAllCards({ componentPaths, match })

原子组件支持的如下:

  • 关联小程序页面:ft.modelContext.getViewContext(this).setRelatedPage({ path, query })
  • 上行消息:ft.modelContext.getContext().sendFollowUpMessage()
  • 更新卡片状态并同步给模型:ft.modelContext.getViewContext(this).updateModelContext({ content: [{ type: 'text', text: '用户选择了xxx' }] })

半屏页面:

  • 打开半屏页面:ft.modelContext.getViewContext(this).openDetailPage({ url })
  • 预加载半屏页面:ft.modelContext.getViewContext(this).preloadDetailPage({ url })
  • 半屏页面更新卡片:ft.modelContext.getContext().reapplyApiCall({ arguments })

原子组件过期态:

  • 设置所有组件过期:ft.modelContext.expireAllCards({ componentPaths, match })
  • 设置之前的组件过期:ft.modelContext.getViewContext(this).expirePreviousCards({ componentPaths, match })

原子组件接收事件:

  • 原子组件接收事件:ft.modelContext.getViewContext(this).on(NotificationType, callback)
  • 原子接口入参:ft.modelContext.NotificationType.Input
  • 原子接口出参:ft.modelContext.NotificationType.Result
  • 内容溢出事件:ft.modelContext.NotificationType.Overflow
  • 过期事件:ft.modelContext.NotificationType.Expire

# 原有 API

小程序原有部分 API 支持在此模式下调用,但原子接口与原子组件可调用的接口有所不同,按实际调用情况为准。

© FinClip with ❤ , Since 2017