From ee52ae132d382896db09e2b273300c74c1cd2bdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8F=B2=E9=B8=BD?= <1020103647@qq.com> Date: Sat, 11 May 2024 09:36:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=87=AA=E5=AE=9A=E4=B9=89tabbar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages.config.ts | 11 ++- src/components/fg-tabbar/fg-tabbar.vue | 103 +++++++------------------ src/components/fg-tabbar/tabbar.ts | 21 +++++ src/pages/my/index.vue | 20 +++++ src/store/tabbar.ts | 42 ---------- src/utils/index.ts | 1 - 6 files changed, 75 insertions(+), 123 deletions(-) create mode 100644 src/components/fg-tabbar/tabbar.ts create mode 100644 src/pages/my/index.vue delete mode 100644 src/store/tabbar.ts diff --git a/pages.config.ts b/pages.config.ts index cdbcb94..f2d86cb 100644 --- a/pages.config.ts +++ b/pages.config.ts @@ -27,16 +27,15 @@ export default defineUniPages({ spacing: '3px', list: [ { - iconPath: 'static/tabbar/home.png', - selectedIconPath: 'static/tabbar/homeHL.png', pagePath: 'pages/index/index', + icon: 'home', text: '首页', }, { - iconPath: 'static/tabbar/example.png', - selectedIconPath: 'static/tabbar/exampleHL.png', - pagePath: 'pages/index/about', - text: '关于', + pagePath: 'pages/my/index', + icon: 'i-carbon-user-avatar', + isUnocssIcon: true, + text: '我的', }, ], }, diff --git a/src/components/fg-tabbar/fg-tabbar.vue b/src/components/fg-tabbar/fg-tabbar.vue index 554286c..25dad4e 100644 --- a/src/components/fg-tabbar/fg-tabbar.vue +++ b/src/components/fg-tabbar/fg-tabbar.vue @@ -1,82 +1,37 @@ - - diff --git a/src/components/fg-tabbar/tabbar.ts b/src/components/fg-tabbar/tabbar.ts new file mode 100644 index 0000000..479090c --- /dev/null +++ b/src/components/fg-tabbar/tabbar.ts @@ -0,0 +1,21 @@ +export const tabbarList = [ + { + path: '/pages/index/about', + icon: 'home', + isWotIcon: true, + title: '首页', + }, + { + path: '/pages/index/index', + icon: 'i-carbon-user-avatar', + isWotIcon: false, + title: '我的', + }, +] + +export const tabbarStore = reactive({ + curIdx: 0, + setCurIdx(idx: number) { + this.curIdx = idx + }, +}) diff --git a/src/pages/my/index.vue b/src/pages/my/index.vue new file mode 100644 index 0000000..ddc1334 --- /dev/null +++ b/src/pages/my/index.vue @@ -0,0 +1,20 @@ + +{ + layout: 'default', + style: { + navigationBarTitleText: '我的', + }, +} + + + + + + + diff --git a/src/store/tabbar.ts b/src/store/tabbar.ts deleted file mode 100644 index ad1d840..0000000 --- a/src/store/tabbar.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { defineStore } from 'pinia' -import { ref } from 'vue' - -export const useTabbarStore = defineStore( - 'tabbar', - () => { - interface tabBarItem { - iconPath: string - selectedIconPath: string - pagePath: string - text: string - } - const tabBarList = ref([ - { - iconPath: '/static/tabbar/home.png', - selectedIconPath: '/static/tabbar/homeHL.png', - pagePath: '/pages/index/index', - text: '首页', - }, - { - iconPath: '/static/tabbar/example.png', - selectedIconPath: '/static/tabbar/exampleHL.png', - pagePath: '/pages/index/about', - text: '关于', - }, - ]) - const tabIndex = ref(0) - - const setTabIndex = (val: number) => { - tabIndex.value = val - } - - return { - tabBarList, - tabIndex, - setTabIndex, - } - }, - { - persist: true, - }, -) diff --git a/src/utils/index.ts b/src/utils/index.ts index 14ef106..715c123 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,4 +1,3 @@ -// @ts-expect-error import json file import { pages, subPackages, tabBar } from '@/pages.json' /** 判断当前页面是否是tabbar页 */