From 44dd7f30cf4a8a7638369b91f63c9acf8655074e Mon Sep 17 00:00:00 2001 From: ZF sun <34314687@qq.com> Date: Tue, 30 Dec 2025 09:13:29 +0800 Subject: [PATCH] =?UTF-8?q?chore(=E5=88=86=E5=8C=85):=20tarBar=E8=BE=BE?= =?UTF-8?q?=E5=88=B0=E5=88=86=E5=8C=85=E5=89=8D=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/util.js | 22 ++++++++++++---------- pages.json | 17 +++++++---------- pages/empty/index.vue | 4 ++++ 3 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 pages/empty/index.vue diff --git a/common/js/util.js b/common/js/util.js index 45116dd..4b16a58 100644 --- a/common/js/util.js +++ b/common/js/util.js @@ -6,13 +6,17 @@ import { } from 'common/js/wx-jssdk.js'; + +// 首页路径 +export const INDEX_PAGE_URL = '/pages/index/index'; + // 当前最新的tabBar.list (参见pages.json 中的tabBar.list 配置) export const systemTabBarList = [ - '/pages/index/index', - '/pages_goods/category', - '/pages_tool/contact/contact', - '/pages_tool/member/index' - ]; + INDEX_PAGE_URL, + '/pages_goods/category', + '/pages_tool/contact/contact', + '/pages_tool/member/index' +]; /** * 适配子包路径 @@ -86,9 +90,8 @@ export default { for (let i = 0; i < systemTabBarList.length; i++) { const tabBarUrl = systemTabBarList[i]; if (url.indexOf(tabBarUrl) == 0) { - uni.switchTab({ - url - }); + // 首页特殊处理,采用switchTab, 其他页面采用redirectTo, 不能返回,不能退回 + (tabBarUrl == INDEX_PAGE_URL ? uni.switchTab : uni.redirectTo)({url}); return; } } @@ -115,12 +118,11 @@ export default { break; default: // 保留当前页面,跳转到应用内的某个页面 + console.log('保留当前页面,跳转到应用内的某个页面', url); uni.navigateTo({ url }); } - - console.log('无任何处理', url); }, /** * 图片路径转换 diff --git a/pages.json b/pages.json index 471928c..a9d549f 100644 --- a/pages.json +++ b/pages.json @@ -1,12 +1,17 @@ { "pages": [ - // pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages { "path": "pages/index/index", "style": { // "navigationStyle": "custom", "enablePullDownRefresh": true } + }, + { + "path": "pages/empty/index", + "style": { + "enablePullDownRefresh": true + } } ], "subPackages": [ @@ -932,15 +937,7 @@ "text": "" }, { - "pagePath": "pages_goods/category", - "text": "" - }, - { - "pagePath": "pages_tool/contact/contact", - "text": "" - }, - { - "pagePath": "pages_tool/member/index", + "pagePath": "pages/empty/index", "text": "" } ] diff --git a/pages/empty/index.vue b/pages/empty/index.vue new file mode 100644 index 0000000..3da8009 --- /dev/null +++ b/pages/empty/index.vue @@ -0,0 +1,4 @@ + \ No newline at end of file