types.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import type { TabBar } from '@uni-helper/vite-plugin-uni-pages'
  2. import type { RemoveLeadingSlashFromUnion } from '@/typings'
  3. /**
  4. * 原生 tabbar 的单个选项配置
  5. */
  6. export type NativeTabBarItem = TabBar['list'][number] & {
  7. pagePath: RemoveLeadingSlashFromUnion<_LocationUrl>
  8. }
  9. /** badge 显示一个数字或 小红点(样式可以直接在 tabbar/index.vue 里面修改) */
  10. export type CustomTabBarItemBadge = number | 'dot'
  11. /** 自定义 tabbar 的单个选项配置 */
  12. export interface CustomTabBarItem {
  13. text: string
  14. pagePath: RemoveLeadingSlashFromUnion<_LocationUrl>
  15. /** 图标类型,不建议用 image 模式,因为需要配置 2 张图,更麻烦 */
  16. iconType: 'uiLib' | 'unocss' | 'iconfont' | 'image'
  17. /**
  18. * icon 的路径
  19. * - uiLib: wot-design-uni 图标的 icon prop
  20. * - unocss: unocss 图标的类名
  21. * - iconfont: iconfont 图标的类名
  22. * - image: 图片的路径
  23. */
  24. icon: string
  25. /** 只有在 image 模式下才需要,传递的是高亮的图片(PS: 不建议用 image 模式) */
  26. iconActive?: string
  27. /** badge 显示一个数字或 小红点 */
  28. badge?: CustomTabBarItemBadge
  29. /** 是否是中间的鼓包tabbarItem */
  30. isBulge?: boolean
  31. }