Compare commits
73 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ade652c4b1 | ||
![]() |
9952611dd1 | ||
![]() |
741975114c | ||
![]() |
7e4e5a19ad | ||
![]() |
a6aeab23e1 | ||
![]() |
e60d924281 | ||
![]() |
48a37ab36e | ||
![]() |
9664664762 | ||
![]() |
9c907d3cd2 | ||
![]() |
f1833571bd | ||
![]() |
1fbac1d13a | ||
![]() |
533f968a7f | ||
![]() |
1784880890 | ||
![]() |
13be95ad42 | ||
![]() |
03071099a7 | ||
![]() |
cd1cff5e4b | ||
![]() |
9ed17c5acb | ||
![]() |
5dcaf77949 | ||
![]() |
b8d0133200 | ||
![]() |
76f21fa406 | ||
![]() |
5e79debf2c | ||
![]() |
51ff0413c0 | ||
![]() |
3cc8c43ff5 | ||
![]() |
d56ba37c6d | ||
![]() |
0700391fe2 | ||
![]() |
1cc6ba0e8c | ||
![]() |
b1535fdae5 | ||
![]() |
6c9fb3ff51 | ||
![]() |
d4d2608c46 | ||
![]() |
cd52284a5b | ||
![]() |
d1d00b7f75 | ||
![]() |
e9f81aa347 | ||
![]() |
a605313eb9 | ||
![]() |
f23ff75a68 | ||
![]() |
f4207824bf | ||
![]() |
b240690ea8 | ||
![]() |
9aacf11a63 | ||
![]() |
1d35a08e11 | ||
![]() |
a31ceadf7b | ||
![]() |
9b0eb79074 | ||
![]() |
32d9c1b64a | ||
![]() |
93ad9785c6 | ||
![]() |
2889a7055b | ||
![]() |
381343a4cf | ||
![]() |
c78f927bb8 | ||
![]() |
d2b4d7f3c4 | ||
![]() |
5603dc4aa0 | ||
![]() |
5ee75213d5 | ||
![]() |
0f104bedff | ||
![]() |
af29c1991d | ||
![]() |
1239c5e89a | ||
![]() |
54e67c43c4 | ||
![]() |
817b6c4a81 | ||
![]() |
bfdab82d39 | ||
![]() |
566e5c6031 | ||
![]() |
08f3f1ae9b | ||
![]() |
938ca363e5 | ||
![]() |
b7b0f04557 | ||
![]() |
ba11c710c0 | ||
![]() |
27f23173fd | ||
![]() |
e123a5cb1b | ||
![]() |
cfced2e6d8 | ||
![]() |
f91fff8004 | ||
![]() |
57addd9531 | ||
![]() |
c3a26b0df9 | ||
![]() |
b9ee449c5c | ||
![]() |
2c404a072b | ||
![]() |
c115cb8ab4 | ||
![]() |
61264eba09 | ||
![]() |
1693727f56 | ||
![]() |
fd64936e36 | ||
![]() |
775690c405 | ||
![]() |
bff59b33b1 |
@ -17,29 +17,5 @@ export default defineUniPages({
|
|||||||
'z-paging/components/z-paging$1/z-paging$1.vue',
|
'z-paging/components/z-paging$1/z-paging$1.vue',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// 如果不需要tabBar,推荐使用 spa 模板。(pnpm create xxx -t spa)
|
// 如果不需要tabBar,可以注释掉这个配置,或者直接删除
|
||||||
tabBar: {
|
|
||||||
color: '#999999',
|
|
||||||
selectedColor: '#018d71',
|
|
||||||
backgroundColor: '#F8F8F8',
|
|
||||||
borderStyle: 'black',
|
|
||||||
height: '50px',
|
|
||||||
fontSize: '10px',
|
|
||||||
iconWidth: '24px',
|
|
||||||
spacing: '3px',
|
|
||||||
list: [
|
|
||||||
{
|
|
||||||
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/about/about',
|
|
||||||
text: '关于',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
|
60
src/layouts/tabbar.vue
Normal file
60
src/layouts/tabbar.vue
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<template>
|
||||||
|
<wd-config-provider :themeVars="themeVars">
|
||||||
|
<wd-notify />
|
||||||
|
<wd-toast />
|
||||||
|
<wd-message-box />
|
||||||
|
<!-- <privacy-popup></privacy-popup> -->
|
||||||
|
<slot></slot>
|
||||||
|
<wd-tabbar
|
||||||
|
fixed
|
||||||
|
:model-value="tabbarStore.getActive.name"
|
||||||
|
@change="handleChange"
|
||||||
|
bordered
|
||||||
|
safeAreaInsetBottom
|
||||||
|
placeholder
|
||||||
|
>
|
||||||
|
<wd-tabbar-item
|
||||||
|
v-for="(item, index) in tabbarStore.getTabbarItems"
|
||||||
|
:key="index"
|
||||||
|
:name="item.name"
|
||||||
|
:value="tabbarStore.getTabbarItemValue(item.name)"
|
||||||
|
:title="item.title"
|
||||||
|
:icon="item.icon"
|
||||||
|
></wd-tabbar-item>
|
||||||
|
</wd-tabbar>
|
||||||
|
</wd-config-provider>
|
||||||
|
</template>
|
||||||
|
<script lang="ts">
|
||||||
|
export default {
|
||||||
|
options: {
|
||||||
|
addGlobalClass: true,
|
||||||
|
virtualHost: true,
|
||||||
|
styleIsolation: 'shared',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { useTabbarStore } from '@/store/tabbar'
|
||||||
|
import { ConfigProviderThemeVars } from 'wot-design-uni'
|
||||||
|
|
||||||
|
const tabbarStore = useTabbarStore()
|
||||||
|
|
||||||
|
const themeVars = reactive<ConfigProviderThemeVars>({
|
||||||
|
colorTheme: '#fa4126',
|
||||||
|
tabsNavLineBgColor: 'red',
|
||||||
|
})
|
||||||
|
|
||||||
|
function handleChange({ value }) {
|
||||||
|
tabbarStore.setTabbarItemActive(value)
|
||||||
|
uni.navigateTo({
|
||||||
|
url: tabbarStore.getTabbarItemRoute(value),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onShow(() => {
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
uni.hideTabBar()
|
||||||
|
// #endif
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
<style lang="scss" scoped></style>
|
@ -14,35 +14,11 @@
|
|||||||
"^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue"
|
"^(?!z-paging-refresh|z-paging-load-more)z-paging(.*)": "z-paging/components/z-paging$1/z-paging$1.vue"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tabBar": {
|
|
||||||
"color": "#999999",
|
|
||||||
"selectedColor": "#018d71",
|
|
||||||
"backgroundColor": "#F8F8F8",
|
|
||||||
"borderStyle": "black",
|
|
||||||
"height": "50px",
|
|
||||||
"fontSize": "10px",
|
|
||||||
"iconWidth": "24px",
|
|
||||||
"spacing": "3px",
|
|
||||||
"list": [
|
|
||||||
{
|
|
||||||
"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/about/about",
|
|
||||||
"text": "关于"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"__esModule": true,
|
|
||||||
"pages": [
|
"pages": [
|
||||||
{
|
{
|
||||||
"path": "pages/index/index",
|
"path": "pages/index/index",
|
||||||
"type": "home",
|
"type": "home",
|
||||||
|
"layout": "tabbar",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationStyle": "custom",
|
"navigationStyle": "custom",
|
||||||
"navigationBarTitleText": "首页"
|
"navigationBarTitleText": "首页"
|
||||||
@ -51,9 +27,9 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/about/about",
|
"path": "pages/about/about",
|
||||||
"type": "page",
|
"type": "page",
|
||||||
|
"layout": "tabbar",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "关于",
|
"navigationBarTitleText": "关于"
|
||||||
"navigationStyle": "custom"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
<route lang="json5">
|
<route lang="json5">
|
||||||
{
|
{
|
||||||
|
layout: 'tabbar',
|
||||||
style: {
|
style: {
|
||||||
navigationBarTitleText: '关于',
|
navigationBarTitleText: '关于',
|
||||||
navigationStyle: 'custom', // 开启自定义导航栏
|
// navigationStyle: 'custom', // 开启自定义导航栏
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<fg-navbar>关于</fg-navbar>
|
<!-- <fg-navbar>关于</fg-navbar> -->
|
||||||
<view
|
<view
|
||||||
class="bg-white overflow-hidden pt-2 px-4"
|
class="bg-white overflow-hidden pt-2 px-4"
|
||||||
:style="{ marginTop: safeAreaInsets?.top + 'px' }"
|
:style="{ marginTop: safeAreaInsets?.top + 'px' }"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<!-- 使用 type="home" 属性设置首页,其他页面不需要设置,默认为page;推荐使用json5,更强大,且允许注释 -->
|
<!-- 使用 type="home" 属性设置首页,其他页面不需要设置,默认为page;推荐使用json5,更强大,且允许注释 -->
|
||||||
<route lang="json5" type="home">
|
<route lang="json5" type="home">
|
||||||
{
|
{
|
||||||
|
layout: 'tabbar',
|
||||||
style: {
|
style: {
|
||||||
navigationStyle: 'custom',
|
navigationStyle: 'custom',
|
||||||
navigationBarTitleText: '首页',
|
navigationBarTitleText: '首页',
|
||||||
@ -25,7 +26,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="text-center mt-4">
|
<view class="text-center mt-4">
|
||||||
模板分支是:
|
模板分支是:
|
||||||
<text class="text-green-500">base</text>
|
<text class="text-green-500">spa</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
@ -15,3 +15,4 @@ export default store
|
|||||||
|
|
||||||
// 模块统一导出
|
// 模块统一导出
|
||||||
export * from './user'
|
export * from './user'
|
||||||
|
export * from './tabbar'
|
||||||
|
71
src/store/tabbar.ts
Normal file
71
src/store/tabbar.ts
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export interface TabbarItem {
|
||||||
|
name: string
|
||||||
|
value: number | null
|
||||||
|
active: boolean
|
||||||
|
route: string
|
||||||
|
title: string
|
||||||
|
icon: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useTabbarStore = defineStore('tabbar', {
|
||||||
|
state: (): { tabbarItems: TabbarItem[] } => ({
|
||||||
|
tabbarItems: [
|
||||||
|
{
|
||||||
|
name: 'index',
|
||||||
|
value: null,
|
||||||
|
active: true,
|
||||||
|
route: '/pages/index/index',
|
||||||
|
title: '首页',
|
||||||
|
icon: 'home',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'about',
|
||||||
|
value: null,
|
||||||
|
active: false,
|
||||||
|
route: '/pages/about/about',
|
||||||
|
title: '关于',
|
||||||
|
icon: 'user',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
getters: {
|
||||||
|
getTabbarItems: (state) => {
|
||||||
|
return state.tabbarItems
|
||||||
|
},
|
||||||
|
getActive: (state) => {
|
||||||
|
const item = state.tabbarItems.find((item) => item.active)
|
||||||
|
return item || state.tabbarItems[0]
|
||||||
|
},
|
||||||
|
getTabbarItemValue: (state) => {
|
||||||
|
return (name: string) => {
|
||||||
|
const item = state.tabbarItems.find((item) => item.name === name)
|
||||||
|
return item && item.value ? item.value : null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getTabbarItemRoute: (state) => {
|
||||||
|
return (name: string) => {
|
||||||
|
const item = state.tabbarItems.find((item) => item.name === name)
|
||||||
|
return (item && item.route) ?? null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
setTabbarItem(name: string, value: number) {
|
||||||
|
const tabbarItem = this.tabbarItems.find((item) => item.name === name)
|
||||||
|
if (tabbarItem) {
|
||||||
|
tabbarItem.value = value
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setTabbarItemActive(name: string) {
|
||||||
|
this.tabbarItems.forEach((item) => {
|
||||||
|
if (item.name === name) {
|
||||||
|
item.active = true
|
||||||
|
} else {
|
||||||
|
item.active = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user