From c092d3b86a223e279ccf57be27d8f1eb315de089 Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期三, 26 二月 2025 17:21:56 +0800
Subject: [PATCH] fix: 对接
---
apps/taro/src/hooks/router.ts | 27 +++++++++++++++++++++++++++
1 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/apps/taro/src/hooks/router.ts b/apps/taro/src/hooks/router.ts
index 6d7bf5f..b1236c1 100644
--- a/apps/taro/src/hooks/router.ts
+++ b/apps/taro/src/hooks/router.ts
@@ -1,6 +1,8 @@
import Taro from '@tarojs/taro';
import { TabBarPageRouter } from '@/constants';
import { useSystemStore } from '@/stores/modules/system';
+import { useAppStore } from '@/stores/modules/app';
+import { isInAlipay } from '@/utils/env';
export function useSwitchTab() {
const systemStore = useSystemStore();
@@ -41,3 +43,28 @@
isFocus,
};
}
+
+export function useTabRouteEnhance() {
+ const appStore = useAppStore();
+ const { latestRoute } = storeToRefs(appStore);
+
+ const router = Taro.useRouter();
+
+ Taro.useDidShow(() => {
+ const isTabbarPage = Object.values(TabBarPageRouter).some((x) =>
+ latestRoute.value.toLowerCase().includes(x.toLowerCase())
+ );
+ if (isTabbarPage) {
+ Taro.reLaunch({
+ url: router.path,
+ success() {
+ appStore.setLatestRoute('');
+ },
+ });
+ }
+ });
+
+ Taro.useDidHide(() => {
+ appStore.setLatestRoute(router.path);
+ });
+}
--
Gitblit v1.10.0