From bb566974f357346fa111f53433ac3dfa01f767c2 Mon Sep 17 00:00:00 2001 From: Souta Date: Mon, 16 Sep 2024 18:35:08 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E6=B7=BB=E5=8A=A0=20openOfficialAccountArticle=20?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-platform-weapp/src/apis-list.ts | 1 + packages/taro/types/api/navigate/index.d.ts | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/packages/taro-platform-weapp/src/apis-list.ts b/packages/taro-platform-weapp/src/apis-list.ts index 5cefa2f4c3f8..e419f55a989c 100644 --- a/packages/taro-platform-weapp/src/apis-list.ts +++ b/packages/taro-platform-weapp/src/apis-list.ts @@ -23,6 +23,7 @@ export const needPromiseApis = new Set([ 'openChannelsLive', 'openChannelsUserProfile', 'openCustomerServiceChat', + 'openOfficialAccountArticle', 'openVideoEditor', 'saveFileToDisk', 'scanItem', diff --git a/packages/taro/types/api/navigate/index.d.ts b/packages/taro/types/api/navigate/index.d.ts index d1a7d89c110c..86232bf298c8 100644 --- a/packages/taro/types/api/navigate/index.d.ts +++ b/packages/taro/types/api/navigate/index.d.ts @@ -1,6 +1,32 @@ import Taro from '../../index' declare module '../../index' { + namespace openOfficialAccountArticle { + interface Option { + url: string + success?: (res: SuccessCallbackResult) => void + fail?: (res: FailCallbackResult) => void + complete?: (res: CompleteCallbackResult) => void + } + + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭) */ + cancel: boolean + /** 为 true 时,表示用户点击了确定按钮 */ + confirm: boolean + } + + interface FailCallbackResult extends TaroGeneral.CallbackResult { + /** 错误码 */ + errCode: number + } + + interface CompleteCallbackResult extends SuccessCallbackResult { + /** 用户点击了确定按钮后返回内容 */ + content?: string | null + } + } + namespace openEmbeddedMiniProgram { interface Option { /** 要打开的小程序 appId */ @@ -222,6 +248,14 @@ declare module '../../index' { } interface TaroStatic { + /** 通过小程序打开任意公众号文章(不包括临时链接等异常状态下的公众号文章) + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/navigate/wx.openOfficialAccountArticle.html + */ + openOfficialAccountArticle( + option: openOfficialAccountArticle.Option + ): Promise + /** 打开半屏小程序。接入指引请参考 [半屏小程序能力](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/openEmbeddedMiniProgram.html)。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/navigate/wx.openEmbeddedMiniProgram.html