实现代码:

import { ModuleWithProviders, NgModule } from '@angular/core';
import {provideConfig,provideDefaultConfig,provideDefaultConfigFactory,
} from '@spartacus/core';
import { CmsLibModule } from '../cms-components/cms-lib.module';
import { StorefrontConfig } from '../storefront-config';
import { layoutConfig, mediaConfig } from './config/index';
import { defaultCmsContentConfig } from './config/static-cms-structure/default-cms-content.config';
import { StorefrontModule } from './storefront.module';@NgModule({imports: [StorefrontModule,// the cms lib module contains all components that added in the bundleCmsLibModule,],providers: [provideDefaultConfig({pwa: {enabled: true,addToHomeScreen: true,},}),provideDefaultConfig(layoutConfig),provideDefaultConfig(mediaConfig),provideDefaultConfigFactory(defaultCmsContentConfig),],exports: [StorefrontModule],
})
export class B2cStorefrontModule {static withConfig(config?: StorefrontConfig): ModuleWithProviders<B2cStorefrontModule> {return {ngModule: B2cStorefrontModule,providers: [provideConfig(config)],};}
}

3个默认配置:

layoutConfig

import { LayoutConfig } from '../../layout/config/layout-config';/*** The layout configuration is used to define the overall layout of the storefront.* The configuration includes the following aspects:* - breakpoint layout (AKA screen layout)* - Page sections slot configuration (i.e. header vs footer)* - page template slot configuration (i.e. landing page template vs PDP page template)* - deferred loading configuration** The page slot configurations is directly related to the data in the backend. If you use the* Spartacus sample-data, you will have an aligned setup. However, if you introduce custom page* templates and/or slots, you most likely need to further adjust or replace this configuration.*/
export const layoutConfig: LayoutConfig = {// deferredLoading: {//   strategy: DeferLoadingStrategy.DEFER,//   intersectionMargin: '50px',// },layoutSlots: {header: {lg: {slots: ['PreHeader','SiteContext','SiteLinks','SiteLogo','SearchBox','SiteLogin','MiniCart','NavigationBar',],},slots: ['PreHeader', 'SiteLogo', 'SearchBox', 'MiniCart'],},navigation: {lg: { slots: [] },slots: ['SiteLogin', 'NavigationBar', 'SiteContext', 'SiteLinks'],},footer: {slots: ['Footer'],},LandingPage2Template: {pageFold: 'Section2B',slots: ['Section1','Section2A','Section2B','Section2C','Section3','Section4','Section5',],},ContentPage1Template: {slots: ['Section2A', 'Section2B'],},CategoryPageTemplate: {pageFold: 'Section2',slots: ['Section1', 'Section2', 'Section3'],},ProductListPageTemplate: {slots: ['ProductLeftRefinements', 'ProductListSlot'],},ProductGridPageTemplate: {slots: ['ProductLeftRefinements', 'ProductGridSlot'],},SearchResultsListPageTemplate: {slots: ['Section2','ProductLeftRefinements','SearchResultsListSlot','Section4',],},SearchResultsGridPageTemplate: {slots: ['Section2','ProductLeftRefinements','SearchResultsGridSlot','Section4',],},ProductDetailsPageTemplate: {lg: {pageFold: 'UpSelling',},pageFold: 'Summary',slots: ['Summary','UpSelling','CrossSelling','Tabs','PlaceholderContentSlot',],},CartPageTemplate: {slots: ['TopContent', 'CenterRightContentSlot', 'EmptyCartMiddleContent'],},AccountPageTemplate: {slots: ['BodyContent', 'SideContent'],},LoginPageTemplate: {slots: ['LeftContentSlot', 'RightContentSlot'],},ErrorPageTemplate: {slots: ['TopContent', 'MiddleContent', 'BottomContent'],},OrderConfirmationPageTemplate: {slots: ['BodyContent', 'SideContent'],},MultiStepCheckoutSummaryPageTemplate: {slots: ['TopContent', 'BodyContent', 'SideContent', 'BottomContent'],},CheckoutLoginPageTemplate: {slots: ['RightContentSlot'],},},
};/*** @deprecated the b2cLayoutConfig will be dropped with version 4.0.** With Spartacus 3.0 we started to align various layout configurations. Moreover, we move* into a pattern where layout configurations are shattered through various (lazy loaded) modules.*/
export const b2cLayoutConfig: LayoutConfig = layoutConfig;

mediaConfig

import { MediaConfig } from '../../shared/components/media/media.config';export const mediaConfig: MediaConfig = {mediaFormats: {mobile: {width: 400,},tablet: {width: 770,},desktop: {width: 1140,},widescreen: {width: 1400,},// product mediacartIcon: {width: 65,},thumbnail: {width: 96,},product: {width: 284,},zoom: {width: 515,},},
};

CmsContentConfig

import { CmsStructureConfig } from '@spartacus/core';
import {defaultPageHeaderConfig,headerComponents,
} from './default-header.config';export function defaultCmsContentConfig(): CmsStructureConfig {return {cmsStructure: {components: {...headerComponents,},slots: {...defaultPageHeaderConfig,},pages: [],},};
}
import { CmsPageSlotsConfig, ContentSlotComponentData } from '@spartacus/core';export const headerComponents: {[key: string]: ContentSlotComponentData | any;
} = {HamburgerMenuComponent: {typeCode: 'HamburgerMenuComponent',flexType: 'HamburgerMenuComponent',},LoginComponent: {typeCode: 'LoginComponent',flexType: 'LoginComponent',uid: 'LoginComponent',},
};export const defaultPageHeaderConfig: CmsPageSlotsConfig = {PreHeader: {componentIds: ['HamburgerMenuComponent'],},SiteLogin: {componentIds: ['LoginComponent'],},
};

SAP Spartacus B2cStorefrontModule里提供的默认配置相关推荐

  1. SAP Spartacus cxOutlet里的元数据存储,outlet名称和待渲染Component的映射关系

    cxOutlet合集 SAP Spartacus自定义指令cxOutlet的工作原理 SAP Spartacus table cell如何通过cxOutlet在运行时动态注入组件 SAP Sparta ...

  2. SAP Spartacus cxOutlet 里的 templatesRefs 的填充逻辑

    cxOutlet合集 SAP Spartacus自定义指令cxOutlet的工作原理 SAP Spartacus table cell如何通过cxOutlet在运行时动态注入组件 SAP Sparta ...

  3. SAP Spartacus url里默认electronics-spa的由来

    单步调试时密切关注url的变化,初始url为localhost:4200: 这个electronics-spa即使在后台没有连通的情况下也能用,说明肯定不是从后台返回的: 这篇文章SAP Sparta ...

  4. 如何查看 SAP Spartacus PageLayoutComponent 里的 template$ 的值

    SAP Spartacus PageLayoutService.ts 里的 templateName$ get 操作:返回一个 Observable 对象,包裹的类型为 string. pipe 的第 ...

  5. SAP Spartacus store里引用的library是如何编译出来的

    看一个基于SAP Spartacus library开发的storefront Angular应用的依赖: "@spartacus/assets": "^2.1.0&qu ...

  6. Django REST framework 源码中提供的默认配置

    DEFAULTS 是默认配置,IMPORT_STRINGS 是要相对应导入的类 键 大写大写大写 ########################### settings.py ########### ...

  7. 使用 selector 从 SAP Spartacus state 里读取 Cart 数据

    选择器 selector 是用于获取存储状态 state 切片的纯函数. @ngrx/store 提供了一些帮助函数来优化这个选择. 选择器在选择状态切片时提供了许多功能. 使用 createSele ...

  8. SAP Spartacus B2cStorefrontModule 和 StorefrontModule 的区别

    这是一个 Recipe module,实现体里包含三个子 module: HttpClientModule StorefrontModule // the cms lib module contain ...

  9. SAP Spartacus PagelayoutComponent里的section和slot

    Page包含slots,slots包含Components. Spartacus使用page template来组织slots和Components. 一个page template包含了一些可被全局 ...

最新文章

  1. python毕业设计开题报告-基于Python的教学互动系统的设计与实现开题报告
  2. Swift 异常处理
  3. android 字母排序,android – 按字母顺序排序列表
  4. 使用python将excel数据导入数据库
  5. 爱奇艺如何开启两指双击触发奇观功能
  6. mooc中的习题--然后是几点
  7. 学会python爬虫能发财么_python如何赚钱? python爬虫如何进阶? python就业? 如何快速入门python?...
  8. vba 正与服务器联系以获取信息,vba读取云服务器的数据库连接
  9. 浙大翁凯老师Java课堂学习记录(第三周)
  10. 项目Kick Off的作用
  11. QQ和360大战的这场戏我的看法
  12. 《JavaScript百炼成仙》 全书知识点整理
  13. (63)计数器设计(递增计数器)
  14. 电感线圈绕制常用的漆包线
  15. 【autojs】Auto.js Pro安卓QQ语音红包秒抢挂免费脚本源码
  16. 电脑重装系统演示,惠普电脑怎么进入bios,一看就会懂的重装方法
  17. 如何把Kotlin代码转成Java代码、把Java代码转成Kotlin代码
  18. oracle中segment_name,Oracle segment_name为数字的怪象
  19. 关于“分节符(下一页)”和“分节符(奇数页)”的问题
  20. App推广技术如何帮助App推广

热门文章

  1. How do I get the lowest value of all the non zero value pixels?
  2. 对java:comp/env的研究
  3. tabindex, taborder和notab属性的区别
  4. centos(7) 使用yum进行安装lamp环境
  5. VBS脚本恶作剧:关机+重启后自动关机
  6. Wordcount on YARN 一个MapReduce示例
  7. Day 06 元组,字典,集合
  8. Java数据结构-基于数组的栈和泛型
  9. Newtonsoft.Json.dll序列化为json,null值自动过滤
  10. Team Foundation Server安装指南