SAP Spartacus B2cStorefrontModule里提供的默认配置
生活随笔
收集整理的這篇文章主要介紹了
SAP Spartacus B2cStorefrontModule里提供的默认配置
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
實現代碼:
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里提供的默认配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 放置奇兵怎么建同区小号
- 下一篇: 飞猪:“五一”假期首日出行的国内游商品成