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 接口 #16519

Closed
wants to merge 6 commits into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export default class Index extends React.Component {
id: 'openBusinessView',
func: null,
},
{
id: 'openOfficialAccountArticle',
func: null
},
{
id: 'openEmbeddedMiniProgram',
func: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,11 @@
"success": "void",
"return": "Promise<Partial<CallbackResult> & Record<string, unknown> & CallbackResult>"
},
"openOfficialAccountArticle": {
"object": "*",
"success": "void",
"return": "Promise<Partial<CallbackResult> & Record<string, unknown> & CallbackResult>"
},
"openEmbeddedMiniProgram": {
"object": "*",
"success": "void",
Expand Down
1 change: 1 addition & 0 deletions packages/taro-h5/src/api/navigate/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { temporarilyNotSupport } from '../../utils'

// 跳转
export const openOfficialAccountArticle = /* @__PURE__ */ temporarilyNotSupport('openOfficialAccountArticle')
export const openEmbeddedMiniProgram = /* @__PURE__ */ temporarilyNotSupport('openEmbeddedMiniProgram')
export const navigateToMiniProgram = /* @__PURE__ */ temporarilyNotSupport('navigateToMiniProgram')
export const navigateBackMiniProgram = /* @__PURE__ */ temporarilyNotSupport('navigateBackMiniProgram')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,7 @@
"openChannelsUserProfile": true,
"openCustomerServiceChat": false,
"openDocument": true,
"openOfficialAccountArticle": false,
"openEmbeddedMiniProgram": false,
"openLocation": {
"object": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1170,6 +1170,12 @@
* @canNotUse openCustomerServiceChat
*/

/**
* 通过小程序打开任意公众号文章
*
* @canNotUse openOfficialAccountArticle
*/

/**
* 打开半屏小程序
*
Expand Down
1 change: 1 addition & 0 deletions packages/taro-platform-harmony/src/apis/navigate/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { temporarilyNotSupport } from '../utils'

// 跳转
export const openOfficialAccountArticle = /* @__PURE__ */ temporarilyNotSupport('openOfficialAccountArticle')
export const openEmbeddedMiniProgram = /* @__PURE__ */ temporarilyNotSupport('openEmbeddedMiniProgram')
export const navigateToMiniProgram = /* @__PURE__ */ temporarilyNotSupport('navigateToMiniProgram')
export const navigateBackMiniProgram = /* @__PURE__ */ temporarilyNotSupport('navigateBackMiniProgram')
Expand Down
3 changes: 2 additions & 1 deletion packages/taro-platform-weapp/src/apis-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ export const needPromiseApis = new Set([
'openChannelsLive',
'openChannelsUserProfile',
'openCustomerServiceChat',
'openOfficialAccountArticle',
'openVideoEditor',
'saveFileToDisk',
'scanItem',
'setEnable1v1Chat',
'setWindowSize',
'sendBizRedPacket',
'startFacialRecognitionVerify',
'startFacialRecognitionVerify'
])
40 changes: 40 additions & 0 deletions packages/taro/types/api/navigate/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
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 TaroGeneral.CallbackResult {
/** 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭) */
cancel: boolean
/** 为 true 时,表示用户点击了确定按钮 */
confirm: boolean
/** 用户点击了确定按钮后返回内容 */
content?: null
}
}

namespace openEmbeddedMiniProgram {
interface Option {
/** 要打开的小程序 appId */
Expand Down Expand Up @@ -222,6 +256,12 @@ 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