diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/config.ts b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/config.ts index b549512ee..ef1deb016 100644 --- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/config.ts +++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/config.ts @@ -1,13 +1,35 @@ import type { Rect } from '../../../../magic-cube-editor/util'; import type { DiyComponent } from '../../../util'; +export const NAVIGATION_BAR_SHOW_TYPES = ['always', 'scroll'] as const; +export type NavigationBarShowType = (typeof NAVIGATION_BAR_SHOW_TYPES)[number]; +export const isNavigationBarShowType = ( + showType: unknown, +): showType is NavigationBarShowType => + NAVIGATION_BAR_SHOW_TYPES.includes(showType as NavigationBarShowType); +const NAVIGATION_BAR_SCROLL_SHOW_VALUES = new Set([ + 0, + '0', + false, + 'false', +]); +export const isNavigationBarAlwaysShow = ( + property: Pick, +) => { + if (isNavigationBarShowType(property.showType)) { + return property.showType === 'always'; + } + return !NAVIGATION_BAR_SCROLL_SHOW_VALUES.has(property.alwaysShow); +}; + /** 顶部导航栏属性 */ export interface NavigationBarProperty { bgType: 'color' | 'img'; // 背景类型 bgColor: string; // 背景颜色 bgImg: string; // 图片链接 styleType: 'inner' | 'normal'; // 样式类型:默认 | 沉浸式 - alwaysShow: boolean; // 常驻显示 + showType: NavigationBarShowType; // 显示方式:常驻显示 | 滚动显示 + alwaysShow?: boolean | number | string; // 兼容旧版移动端:是否常驻显示 mpCells: NavigationBarCellProperty[]; // 小程序单元格列表 otherCells: NavigationBarCellProperty[]; // 其它平台单元格列表 _local: { @@ -40,6 +62,7 @@ export const component = { bgColor: '#fff', bgImg: '', styleType: 'normal', + showType: 'always', alwaysShow: true, mpCells: [ { diff --git a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/property.vue b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/property.vue index 3603c46a0..0d7fc9c0a 100644 --- a/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/property.vue +++ b/apps/web-antd/src/views/mall/promotion/components/diy-editor/components/mobile/navigation-bar/property.vue @@ -1,6 +1,8 @@