宿主 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.hideShareMenu隐藏分享菜单。share-
ac.shareAppMessage发起小程序分享。share-
ac.showShareMenu展示分享菜单。share-

画布

名称功能权限错误码
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.createBuildRequestCreate an AI MiniApp build request owned by the current developer.developer-
ac.developer.createManagementLinkCreate or refresh a developer management link for the current developer token record.developer-
ac.developer.createManagementTokenCreate a developer management token. The secret token is returned only in this creation response.developer-
ac.developer.createMiniAppCreate a MiniApp owned by the current developer.developer-
ac.developer.createTokenAlias of ac.developer.createManagementToken for existing developer assistants.developer-
ac.developer.deleteMiniAppVersionDelete an uploaded MiniApp package version owned by the current developer when the host allows deletion.developer-
ac.developer.getManagementTokenRead the current developer management token record without returning the secret token.developer-
ac.developer.getMiniAppRead one MiniApp owned by the current developer, including versions when the host supports it.developer-
ac.developer.getMiniAppVersionRead one uploaded MiniApp package version owned by the current developer.developer-
ac.developer.getTokenAlias of ac.developer.getManagementToken for existing developer assistants.developer-
ac.developer.getUserProfileRead the current developer user's profile. Reserved for the official developer assistant MiniApp.developer-
ac.developer.installMiniAppInstall or upgrade a MiniApp version for testing.developer-
ac.developer.listBuildRequestsList MiniApp build requests owned by the current developer.developer-
ac.developer.listMiniAppsList MiniApps owned by the current developer.developer-
ac.developer.openMiniAppOpen an installed MiniApp or install then open a target MiniApp for testing.developer-
ac.developer.publishMiniAppVersionPublish or import a MiniApp package version from an uploaded package file.developer-
ac.developer.revokeTokenRevoke the current developer management token.developer-
ac.developer.updateMiniAppUpdate base metadata for a MiniApp owned by the current developer.developer-
ac.emitComponentEventEmit an auditable event from a component card to the host.ac.emitComponentEvent-
ac.getAppContextRead the AppsChat-scoped context for the current mini app installation.ac.getAppContext-
ac.openChatOpen the AppsChat conversation for the current mini app installation.ac.openChat-
ac.pageScrollTo滚动当前页面到指定位置。--
ac.previewImage预览图片。media-
ac.previewMedia预览媒体资源。media-
ac.readMemoryRead memories scoped to the current AppsChat user, mini app, and installation.ac.readMemory-
ac.renderMermaid将 Mermaid 源码渲染为安全 SVG。--
ac.requestComponentResizeRequest a bounded height update for the current component card.ac.requestComponentResize-
ac.saveImageToPhotosAlbum保存图片到系统相册。media-
ac.saveVideoToPhotosAlbum保存视频到系统相册。media-
ac.sendChatQueue a user message in the AppsChat conversation for the current mini app installation.ac.sendChat-
ac.setClipboardImage写入宿主剪贴板图片。clipboard-
ac.startPullDownRefresh启动下拉刷新状态。--
ac.stopPullDownRefresh停止下拉刷新状态。--
ac.writeMemoryWrite a memory scoped to the current AppsChat user, mini app, and installation.ac.writeMemory-

Socket

名称功能权限错误码
ac.connectSocket建立 Socket 连接。socket-