Skip to content

Commit 977501c

Browse files
committed
feat: Add Tabbar component (#81)
1 parent e329f29 commit 977501c

File tree

12 files changed

+78
-10
lines changed

12 files changed

+78
-10
lines changed

src/auto-imports.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ declare global {
3535
const debouncedWatch: typeof import('@vueuse/core')['debouncedWatch']
3636
const defineAsyncComponent: typeof import('vue')['defineAsyncComponent']
3737
const defineComponent: typeof import('vue')['defineComponent']
38-
const defineLoader: typeof import('vue-router/auto')['defineLoader']
3938
const definePage: typeof import('unplugin-vue-router/runtime')['definePage']
4039
const describe: typeof import('vitest')['describe']
4140
const eagerComputed: typeof import('@vueuse/core')['eagerComputed']

src/components.d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ declare module 'vue' {
1111
NavBar: typeof import('./components/NavBar.vue')['default']
1212
RouterLink: typeof import('vue-router')['RouterLink']
1313
RouterView: typeof import('vue-router')['RouterView']
14+
TabBar: typeof import('./components/TabBar.vue')['default']
1415
VanButton: typeof import('vant/es')['Button']
1516
VanCell: typeof import('vant/es')['Cell']
1617
VanCellGroup: typeof import('vant/es')['CellGroup']
@@ -24,5 +25,7 @@ declare module 'vue' {
2425
VanRadio: typeof import('vant/es')['Radio']
2526
VanSpace: typeof import('vant/es')['Space']
2627
VanSwitch: typeof import('vant/es')['Switch']
28+
VanTabbar: typeof import('vant/es')['Tabbar']
29+
VanTabbarItem: typeof import('vant/es')['TabbarItem']
2730
}
2831
}

src/components/TabBar.vue

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script setup lang="ts">
2+
const { t } = useI18n()
3+
const active = ref(0)
4+
</script>
5+
6+
<template>
7+
<van-tabbar v-model="active" route>
8+
<van-tabbar-item replace icon="home-o" to="/">
9+
{{ t('layouts.home') }}
10+
</van-tabbar-item>
11+
<van-tabbar-item replace icon="user-circle-o" to="/profile">
12+
{{ t('layouts.profile') }}
13+
</van-tabbar-item>
14+
</van-tabbar>
15+
</template>

src/layouts/default.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
<script setup lang="ts">
2+
const { t } = useI18n()
3+
</script>
4+
15
<template>
26
<main p="16" text="gray-700 dark:gray-200">
37
<RouterView />
48

59
<div mx-auto mb-60 pt-15 text-center text-10 text-gray-500>
6-
[Default Layout]
10+
[{{ t('layouts.defaultLayout') }}]
711
</div>
812
</main>
913
</template>

src/layouts/home.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
<script setup lang="ts">
2+
const { t } = useI18n()
3+
</script>
4+
15
<template>
26
<main text="gray-700 dark:gray-200">
37
<RouterView />
48

59
<div mx-auto mt-15 text-center text-10 text-gray-500>
6-
[Home Layout]
10+
[{{ t('layouts.homeLayout') }}]
711
</div>
12+
13+
<TabBar />
814
</main>
915
</template>

src/locales/en-US.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,14 @@
2121
"April": "Apr",
2222
"May": "May",
2323
"June": "Jun"
24+
},
25+
"layouts": {
26+
"home": "HOME",
27+
"profile": "PROFILE",
28+
"homeLayout": "Home Layout",
29+
"defaultLayout": "Default Layout"
30+
},
31+
"profile": {
32+
"placeholder": "WIP"
2433
}
2534
}

src/locales/zh-CN.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,14 @@
2121
"April": "4月",
2222
"May": "5月",
2323
"June": "6月"
24+
},
25+
"layouts": {
26+
"home": "首页",
27+
"profile": "我的",
28+
"homeLayout": "首页布局",
29+
"defaultLayout": "默认布局"
30+
},
31+
"profile": {
32+
"placeholder": "未完成"
2433
}
2534
}

src/pages/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import useAppStore from '@/stores/modules/app'
44
import { languageColumns, locale } from '@/utils/i18n'
55
66
definePage({
7-
name: 'main',
7+
name: 'home',
88
meta: {
99
level: 1,
1010
},

src/pages/profile/index.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<script setup lang="ts">
2+
definePage({
3+
name: 'profile',
4+
meta: {
5+
level: 1,
6+
},
7+
})
8+
9+
const { t } = useI18n()
10+
</script>
11+
12+
<template>
13+
<div mx-auto mb-60 pt-15 text-center text-16 text-dark dark:text-white>
14+
{{ t('profile.placeholder') }}
15+
</div>
16+
</template>
17+
18+
<route lang="yaml">
19+
meta:
20+
layout: home
21+
</route>

src/styles/app.less

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ body {
2525
}
2626

2727
::-webkit-scrollbar {
28-
/** Don't remove this line **/
29-
width: 1px;
28+
width: 0;
3029
background: transparent;
3130
}
3231

@@ -48,4 +47,3 @@ body {
4847
transform: translateX(-20px);
4948
opacity: 0;
5049
}
51-

0 commit comments

Comments
 (0)