From 4abd5408fbe2aaf33e9780e7b41868ced1f056ba Mon Sep 17 00:00:00 2001 From: xuanzebin <38971117+xuanzebin@users.noreply.github.com> Date: Fri, 21 Jul 2023 17:26:33 +0800 Subject: [PATCH] =?UTF-8?q?feat(jd):=20=E4=BA=AC=E4=B8=9C=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E6=B7=BB=E5=8A=A0=20getTabBar=20=E6=96=B9?= =?UTF-8?q?=E6=B3=95=20(#14182)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 京东小程序添加 getTabBar 方法 * test(snapshot): 更新测试快照 * test(snapshot): 更新测试快照 --------- Co-authored-by: xuanzebin Co-authored-by: chenjiajian <798095202@qq.com> --- packages/taro-jd/src/apis.ts | 6 ++++++ .../src/__tests__/__snapshots__/jd.spec.ts.snap | 6 ++++++ .../src/__tests__/__snapshots__/mini-platform.spec.ts.snap | 6 ++++++ packages/taro/types/api/taro.extend.d.ts | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/taro-jd/src/apis.ts b/packages/taro-jd/src/apis.ts index ef08b53caf26..ee88bdab9b7b 100644 --- a/packages/taro-jd/src/apis.ts +++ b/packages/taro-jd/src/apis.ts @@ -4,4 +4,10 @@ declare const jd: any export function initNativeApi (taro) { processApis(taro, jd) + + taro.getTabBar = function (pageCtx) { + if (typeof pageCtx?.getTabBar === 'function') { + return pageCtx.getTabBar()?.$taroInstances + } + } } diff --git a/packages/taro-mini-runner/src/__tests__/__snapshots__/jd.spec.ts.snap b/packages/taro-mini-runner/src/__tests__/__snapshots__/jd.spec.ts.snap index 68831450edef..9306bb7e1209 100644 --- a/packages/taro-mini-runner/src/__tests__/__snapshots__/jd.spec.ts.snap +++ b/packages/taro-mini-runner/src/__tests__/__snapshots__/jd.spec.ts.snap @@ -58,6 +58,12 @@ require("./taro"); function useScope() {} function initNativeApi(taro) { processApis(taro, jd); + taro.getTabBar = function(pageCtx) { + var _a; + if (typeof (pageCtx === null || pageCtx === void 0 ? void 0 : pageCtx.getTabBar) === "function") { + return (_a = pageCtx.getTabBar()) === null || _a === void 0 ? void 0 : _a.$taroInstances; + } + }; } var components = { Swiper: { diff --git a/packages/taro-webpack5-runner/src/__tests__/__snapshots__/mini-platform.spec.ts.snap b/packages/taro-webpack5-runner/src/__tests__/__snapshots__/mini-platform.spec.ts.snap index e83ec49f0522..8b4bd3ef5c41 100644 --- a/packages/taro-webpack5-runner/src/__tests__/__snapshots__/mini-platform.spec.ts.snap +++ b/packages/taro-webpack5-runner/src/__tests__/__snapshots__/mini-platform.spec.ts.snap @@ -2839,6 +2839,12 @@ require("./runtime"); var taro_shared = "taro-shared-mock"; function initNativeApi(taro) { processApis(taro, jd); + taro.getTabBar = function(pageCtx) { + var _a; + if (typeof (pageCtx === null || pageCtx === void 0 ? void 0 : pageCtx.getTabBar) === "function") { + return (_a = pageCtx.getTabBar()) === null || _a === void 0 ? void 0 : _a.$taroInstances; + } + }; } var components = { Swiper: { diff --git a/packages/taro/types/api/taro.extend.d.ts b/packages/taro/types/api/taro.extend.d.ts index 899a4bd52f92..dcdc9dcda561 100644 --- a/packages/taro/types/api/taro.extend.d.ts +++ b/packages/taro/types/api/taro.extend.d.ts @@ -130,7 +130,7 @@ declare module '../index' { setGlobalDataPlugin: setGlobalDataPlugin.Plugin /** 获取自定义 TabBar 对应的 React 或 Vue 组件实例 - * @supported weapp + * @supported weapp, jd * @param page 小程序页面对象,可以通过 Taro.getCurrentInstance().page 获取 */ getTabBar(page: getCurrentInstance.Current['page']): T | undefined