宿主 API 参考
API
API 目录按能力分类生成。官方接口名称统一为 ac.*,页面通过 script: ({ Page, ac }) => Page(...) 捕获 ac 后调用。
存储
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.clearStorage | 清空当前小程序的宿主侧存储。 | - | - |
ac.getStorage | 读取当前小程序的宿主侧存储值。 | - | - |
ac.removeStorage | 移除当前小程序的宿主侧存储值。 | - | - |
ac.setStorage | 写入当前小程序的宿主侧存储值。 | - | - |
地图
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.getMapCenterLocation | 读取宿主地图 provider 当前中心点。 | map | - |
ac.includeMapPoints | 调整地图视野以包含指定点位。 | map | - |
ac.moveMapToLocation | 将地图移动到指定经纬度。 | map | - |
ac.openLocation | 在宿主地图 provider 中打开位置。 | map | - |
画布
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.canvasToTempFilePath | 将画布内容导出为临时文件路径。 | - | - |
ac.clearCanvas | 清空指定画布内容。 | - | - |
ac.drawCanvas | 向指定画布绘制图形指令。 | - | - |
ac.measureCanvasText | 测量画布文本宽度。 | - | - |
剪贴板
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.getClipboardData | 读取宿主剪贴板文本内容。 | clipboard | - |
ac.setClipboardData | 写入宿主剪贴板文本。 | clipboard | - |
界面
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.hideLoading | 隐藏加载提示。 | ui | - |
ac.hideToast | 隐藏轻量提示。 | ui | - |
ac.setNavigationBarColor | 设置导航栏颜色。 | ui | - |
ac.setNavigationBarTitle | 设置导航栏标题。 | ui | - |
ac.showActionSheet | 展示操作菜单。 | ui | - |
ac.showLoading | 展示加载提示。 | ui | - |
ac.showModal | 展示模态确认框。 | ui | - |
ac.showToast | 展示轻量提示。 | ui | - |
开发者管理
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.openMiniApp | 打开测试小程序或目标小程序安装。 | ac.openMiniApp | - |
流
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.requestStream | 发起流式网络请求。 | stream | - |
媒体
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.chooseMedia | 从宿主媒体选择器选择图片或视频。 | media | - |
ac.getMediaInfo | 读取媒体文件信息。 | media | - |
ac.pauseMedia | 暂停媒体播放。 | media | - |
ac.playMedia | 播放媒体资源。 | media | - |
ac.seekMedia | 跳转媒体播放进度。 | media | - |
权限
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.authorize | 请求指定能力的授权。 | - | - |
ac.getSetting | 读取当前授权设置。 | - | - |
ac.openSetting | 打开授权设置页。 | - | - |
扫码
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.scanCode | 调用宿主扫码能力。 | scan | - |
设备
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.getDeviceInfo | 读取宿主设备信息。 | - | - |
ac.getSystemInfo | 读取系统信息。 | - | - |
ac.getWindowInfo | 读取窗口信息。 | - | - |
网络
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.downloadFile | 通过宿主能力下载文件。 | network | - |
ac.getNetworkType | 读取当前网络类型。 | - | - |
ac.offNetworkStatusChange | 取消网络状态变化监听。 | - | - |
ac.onNetworkStatusChange | 监听网络状态变化。 | - | - |
ac.request | 发起网络请求。 | network | - |
ac.uploadFile | 通过宿主能力上传文件。 | network | - |
位置
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.chooseLocation | 打开宿主位置选择器并返回所选位置。 | location | - |
ac.getLocation | 获取当前位置。 | location | - |
ac.startLocationUpdate | 开始持续位置更新。 | location | - |
ac.stopLocationUpdate | 停止持续位置更新。 | location | - |
文件
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.getFileInfo | 读取文件元信息。 | file | - |
ac.getSavedFileList | 读取已保存文件列表。 | file | - |
ac.openDocument | 通过宿主打开文档。 | file | - |
ac.readFile | 读取文件内容。 | file | - |
ac.removeSavedFile | 删除已保存文件。 | file | - |
ac.saveFile | 保存临时文件。 | file | - |
ac.writeFile | 写入文件内容。 | file | - |
相机
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.captureCamera | 从宿主相机 provider 捕获图片。 | camera | - |
ac.startCameraPreview | 启动相机预览。 | camera | - |
ac.stopCameraPreview | 停止相机预览。 | camera | - |
用户资料
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.getUserProfile | 读取当前登录用户或开发者的个人信息。 | profile | - |
ac
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.captureNode | 捕获指定节点内容,用于导出或分享。 | - | - |
ac.developer.createBuildRequest | Create an AI MiniApp build request owned by the current developer. | developer | - |
ac.developer.createManagementLink | Create or refresh a developer management link for the current developer token record. | developer | - |
ac.developer.createManagementToken | Create a developer management token. The secret token is returned only in this creation response. | developer | - |
ac.developer.createMiniApp | Create a MiniApp owned by the current developer. | developer | - |
ac.developer.createToken | Alias of ac.developer.createManagementToken for existing developer assistants. | developer | - |
ac.developer.deleteMiniAppVersion | Delete an uploaded MiniApp package version owned by the current developer when the host allows deletion. | developer | - |
ac.developer.getManagementToken | Read the current developer management token record without returning the secret token. | developer | - |
ac.developer.getMiniApp | Read one MiniApp owned by the current developer, including versions when the host supports it. | developer | - |
ac.developer.getMiniAppVersion | Read one uploaded MiniApp package version owned by the current developer. | developer | - |
ac.developer.getToken | Alias of ac.developer.getManagementToken for existing developer assistants. | developer | - |
ac.developer.getUserProfile | Read the current developer user's profile. Reserved for the official developer assistant MiniApp. | developer | - |
ac.developer.installMiniApp | Install or upgrade a MiniApp version for testing. | developer | - |
ac.developer.listBuildRequests | List MiniApp build requests owned by the current developer. | developer | - |
ac.developer.listMiniApps | List MiniApps owned by the current developer. | developer | - |
ac.developer.openMiniApp | Open an installed MiniApp or install then open a target MiniApp for testing. | developer | - |
ac.developer.publishMiniAppVersion | Publish or import a MiniApp package version from an uploaded package file. | developer | - |
ac.developer.revokeToken | Revoke the current developer management token. | developer | - |
ac.developer.updateMiniApp | Update base metadata for a MiniApp owned by the current developer. | developer | - |
ac.emitComponentEvent | Emit an auditable event from a component card to the host. | ac.emitComponentEvent | - |
ac.getAppContext | Read the AppsChat-scoped context for the current mini app installation. | ac.getAppContext | - |
ac.openChat | Open the AppsChat conversation for the current mini app installation. | ac.openChat | - |
ac.pageScrollTo | 滚动当前页面到指定位置。 | - | - |
ac.previewImage | 预览图片。 | media | - |
ac.previewMedia | 预览媒体资源。 | media | - |
ac.readMemory | Read memories scoped to the current AppsChat user, mini app, and installation. | ac.readMemory | - |
ac.renderMermaid | 将 Mermaid 源码渲染为安全 SVG。 | - | - |
ac.requestComponentResize | Request a bounded height update for the current component card. | ac.requestComponentResize | - |
ac.saveImageToPhotosAlbum | 保存图片到系统相册。 | media | - |
ac.saveVideoToPhotosAlbum | 保存视频到系统相册。 | media | - |
ac.sendChat | Queue a user message in the AppsChat conversation for the current mini app installation. | ac.sendChat | - |
ac.setClipboardImage | 写入宿主剪贴板图片。 | clipboard | - |
ac.startPullDownRefresh | 启动下拉刷新状态。 | - | - |
ac.stopPullDownRefresh | 停止下拉刷新状态。 | - | - |
ac.writeMemory | Write a memory scoped to the current AppsChat user, mini app, and installation. | ac.writeMemory | - |
Socket
| 名称 | 功能 | 权限 | 错误码 |
|---|---|---|---|
ac.connectSocket | 建立 Socket 连接。 | socket | - |