diff --git a/examples/mini-program-example/src/pages/api/redirection/index.tsx b/examples/mini-program-example/src/pages/api/redirection/index.tsx index 0fae968e580a..351cedd72cfe 100644 --- a/examples/mini-program-example/src/pages/api/redirection/index.tsx +++ b/examples/mini-program-example/src/pages/api/redirection/index.tsx @@ -16,6 +16,10 @@ export default class Index extends React.Component { id: 'openBusinessView', func: null, }, + { + id: 'openOfficialAccountArticle', + func: null + }, { id: 'openEmbeddedMiniProgram', func: null, diff --git a/packages/babel-plugin-transform-taroapi/__tests__/__mocks__/harmony-definition.json b/packages/babel-plugin-transform-taroapi/__tests__/__mocks__/harmony-definition.json index 57d56081abe6..3e7ed2054f7f 100644 --- a/packages/babel-plugin-transform-taroapi/__tests__/__mocks__/harmony-definition.json +++ b/packages/babel-plugin-transform-taroapi/__tests__/__mocks__/harmony-definition.json @@ -1287,6 +1287,11 @@ "success": "void", "return": "Promise & Record & CallbackResult>" }, + "openOfficialAccountArticle": { + "object": "*", + "success": "void", + "return": "Promise & Record & CallbackResult>" + }, "openEmbeddedMiniProgram": { "object": "*", "success": "void", diff --git a/packages/taro-h5/src/api/navigate/index.ts b/packages/taro-h5/src/api/navigate/index.ts index d3db506899fd..65aad8f998a4 100644 --- a/packages/taro-h5/src/api/navigate/index.ts +++ b/packages/taro-h5/src/api/navigate/index.ts @@ -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') diff --git a/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json b/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json index e348f111a397..78b885006539 100644 --- a/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json +++ b/packages/taro-platform-harmony-hybrid/build/config/harmony-definition.json @@ -1547,6 +1547,7 @@ "openChannelsUserProfile": true, "openCustomerServiceChat": false, "openDocument": true, + "openOfficialAccountArticle": false, "openEmbeddedMiniProgram": false, "openLocation": { "object": { diff --git a/packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts b/packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts index 3e68b6b0db70..500f27daa2f3 100644 --- a/packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts +++ b/packages/taro-platform-harmony-hybrid/src/api/apis/comments.ts @@ -1170,6 +1170,12 @@ * @canNotUse openCustomerServiceChat */ +/** + * 通过小程序打开任意公众号文章 + * + * @canNotUse openOfficialAccountArticle + */ + /** * 打开半屏小程序 * diff --git a/packages/taro-platform-harmony/src/apis/navigate/index.ts b/packages/taro-platform-harmony/src/apis/navigate/index.ts index 4cb41a46de20..fbb971fb2a49 100644 --- a/packages/taro-platform-harmony/src/apis/navigate/index.ts +++ b/packages/taro-platform-harmony/src/apis/navigate/index.ts @@ -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') diff --git a/packages/taro/types/api/navigate/index.d.ts b/packages/taro/types/api/navigate/index.d.ts index d1a7d89c110c..3ae5c9fa3035 100644 --- a/packages/taro/types/api/navigate/index.d.ts +++ b/packages/taro/types/api/navigate/index.d.ts @@ -1,6 +1,19 @@ import Taro from '../../index' declare module '../../index' { + namespace openOfficialAccountArticle { + interface Option { + /** 需要打开的公众号地址 **/ + url: string + /** 接口调用成功的回调函数 **/ + success?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + } + } + namespace openEmbeddedMiniProgram { interface Option { /** 要打开的小程序 appId */