refactor(fg-tabbar): 定义 FgTabBarItem 类型并更新 tabbarList 类型
使用 FgTabBarItem 类型扩展 TabBar['list'][0],添加 icon 和 iconType 字段 更新 tabbarList 类型为 FgTabBarItem[] 并调整 _tabbar.list 的类型断言
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import type { TabBar } from '@uni-helper/vite-plugin-uni-pages'
|
||||
|
||||
type FgTabBarItem = TabBar['list'][0] & {
|
||||
icon: string
|
||||
iconType: 'uiLib' | 'unocss' | 'iconfont'
|
||||
}
|
||||
|
||||
/**
|
||||
* tabbar 选择的策略,更详细的介绍见 tabbar.md 文件
|
||||
* 0: 'NO_TABBAR' `无 tabbar`
|
||||
@@ -21,7 +26,7 @@ export const selectedTabbarStrategy = TABBAR_MAP.NATIVE_TABBAR
|
||||
// selectedTabbarStrategy==NATIVE_TABBAR(1) 时,需要填 iconPath 和 selectedIconPath
|
||||
// selectedTabbarStrategy==CUSTOM_TABBAR(2,3) 时,需要填 icon 和 iconType
|
||||
// selectedTabbarStrategy==NO_TABBAR(0) 时,tabbarList 不生效
|
||||
export const tabbarList: TabBar['list'] = [
|
||||
export const tabbarList: FgTabBarItem[] = [
|
||||
{
|
||||
iconPath: 'static/tabbar/home.png',
|
||||
selectedIconPath: 'static/tabbar/homeHL.png',
|
||||
@@ -69,7 +74,7 @@ const _tabbar: TabBar = {
|
||||
fontSize: '10px',
|
||||
iconWidth: '24px',
|
||||
spacing: '3px',
|
||||
list: tabbarList,
|
||||
list: tabbarList as unknown as TabBar['list'],
|
||||
}
|
||||
|
||||
// 0和1 需要显示底部的tabbar的各种配置,以利用缓存
|
||||
|
||||
Reference in New Issue
Block a user