Skip to content

Commit

Permalink
feat: 微信小程序添加 openOfficialAccountArticle 接口
Browse files Browse the repository at this point in the history
  • Loading branch information
CatSouta committed Sep 16, 2024
1 parent 1ed101a commit bb56697
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/taro-platform-weapp/src/apis-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const needPromiseApis = new Set([
'openChannelsLive',
'openChannelsUserProfile',
'openCustomerServiceChat',
'openOfficialAccountArticle',
'openVideoEditor',
'saveFileToDisk',
'scanItem',
Expand Down
34 changes: 34 additions & 0 deletions packages/taro/types/api/navigate/index.d.ts
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down Expand Up @@ -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<openOfficialAccountArticle.SuccessCallbackResult>

/** 打开半屏小程序。接入指引请参考 [半屏小程序能力](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
Expand Down

0 comments on commit bb56697

Please sign in to comment.