Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 微信小程序添加 openOfficialAccountArticle 接口 #16549

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading