Files
WAI_Project_UNIX/components/tabbar.uvue

82 lines
1.5 KiB
Plaintext
Raw Normal View History

2025-07-21 16:47:04 +08:00
<template>
<cl-footer
:pt="{
content: {
className: '!p-0 h-[60px]'
}
}"
>
2025-09-03 10:01:28 +08:00
<view class="custom-tabbar" :class="{ 'is-dark': isDark }">
2025-07-21 16:47:04 +08:00
<view
2025-09-03 10:01:28 +08:00
class="custom-tabbar-item"
2025-07-21 16:47:04 +08:00
v-for="item in list"
:key="item.pagePath"
@tap="router.to(item.pagePath)"
>
<cl-image
2025-07-22 14:55:22 +08:00
:src="path == item.pagePath ? item.icon2 : item.icon"
2025-07-21 16:47:04 +08:00
:height="56"
:width="56"
></cl-image>
<cl-text
v-if="item.text != null"
:pt="{
className: parseClass([
'!text-xs mt-1',
2025-07-22 14:55:22 +08:00
[path == item.pagePath, '!text-primary-500', '!text-surface-400']
2025-07-21 16:47:04 +08:00
])
}"
>{{ t(item.text!) }}</cl-text
>
</view>
</view>
</cl-footer>
</template>
<script setup lang="ts">
import { ctx, isDark, parseClass, router } from "@/cool";
import { t } from "@/locale";
import { computed } from "vue";
2025-09-03 10:01:28 +08:00
defineOptions({
name: "custom-tabbar"
});
2025-07-21 16:47:04 +08:00
type Item = {
icon: string;
icon2: string;
pagePath: string;
text: string | null;
};
2025-07-22 14:55:22 +08:00
const path = computed(() => router.path());
2025-07-21 16:47:04 +08:00
// tabbar 列表
const list = computed<Item[]>(() => {
return (ctx.tabBar.list ?? []).map((e) => {
return {
icon: e.iconPath!,
icon2: e.selectedIconPath!,
pagePath: e.pagePath,
text: t(e.text?.replaceAll("%", "")!)
} as Item;
});
});
// 隐藏原生 tabBar
2025-07-27 22:27:53 +08:00
// #ifndef MP
2025-07-21 16:47:04 +08:00
uni.hideTabBar();
2025-07-27 22:27:53 +08:00
// #endif
2025-07-21 16:47:04 +08:00
</script>
<style lang="scss" scoped>
2025-09-03 10:01:28 +08:00
.custom-tabbar {
2025-07-21 16:47:04 +08:00
@apply flex flex-row items-center flex-1;
2025-09-03 10:01:28 +08:00
&-item {
2025-07-21 16:47:04 +08:00
@apply flex flex-col items-center justify-center flex-1;
}
}
</style>