diff --git a/src/layouts/default.vue b/src/layouts/default.vue
index 360c6b2..d362f86 100644
--- a/src/layouts/default.vue
+++ b/src/layouts/default.vue
@@ -1,15 +1,11 @@
-
+
diff --git a/src/layouts/tabbar.vue b/src/layouts/tabbar.vue
index 7e8d345..d55fb51 100644
--- a/src/layouts/tabbar.vue
+++ b/src/layouts/tabbar.vue
@@ -1,12 +1,9 @@
-
+
diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue
index 4353702..1be810f 100644
--- a/src/pages/index/index.vue
+++ b/src/pages/index/index.vue
@@ -11,10 +11,14 @@
diff --git a/src/tabbar/store.ts b/src/tabbar/store.ts
index 2b72f32..da00a61 100644
--- a/src/tabbar/store.ts
+++ b/src/tabbar/store.ts
@@ -1,21 +1,21 @@
+import type { CustomTabBarItem } from './config'
import { tabbarList as _tabbarList } from './config'
// TODO 1/2: 中间的鼓包tabbarItem的开关
const BULGE_ENABLE = true
/** tabbarList 里面的 path 从 pages.config.ts 得到 */
-const tabbarList = _tabbarList.map(item => ({ ...item, path: `/${item.pagePath}` }))
+const tabbarList: CustomTabBarItem[] = _tabbarList.map(item => ({ ...item, pagePath: item.pagePath.startsWith('/') ? item.pagePath : `/${item.pagePath}` }))
+
if (BULGE_ENABLE) {
if (tabbarList.length % 2 === 1) {
console.error('tabbar 数量必须是偶数,否则样式很奇怪!!')
}
tabbarList.splice(tabbarList.length / 2, 0, {
isBulge: true,
- } as any)
+ } as CustomTabBarItem)
}
-export { tabbarList }
-
export function isPageTabbar(path: string) {
return tabbarList.some(item => item.pagePath === path)
}
@@ -25,7 +25,7 @@ export function isPageTabbar(path: string) {
* tabbar 状态,增加 storageSync 保证刷新浏览器时在正确的 tabbar 页面
* 使用reactive简单状态,而不是 pinia 全局状态
*/
-export const tabbarStore = reactive({
+const tabbarStore = reactive({
curIdx: uni.getStorageSync('app-tabbar-index') || 0,
prevIdx: uni.getStorageSync('app-tabbar-index') || 0,
setCurIdx(idx: number) {
@@ -33,7 +33,7 @@ export const tabbarStore = reactive({
uni.setStorageSync('app-tabbar-index', idx)
},
setAutoCurIdx(path: string) {
- const index = tabbarList.findIndex(item => item.path === path)
+ const index = tabbarList.findIndex(item => item.pagePath === path)
console.log('index:', index, path)
// console.log('tabbarList:', tabbarList)
if (index === -1) {
@@ -50,3 +50,5 @@ export const tabbarStore = reactive({
this.prevIdx = uni.getStorageSync('app-tabbar-index') || 0
},
})
+
+export { tabbarList, tabbarStore }