https://sap.github.io/spartacus-docs/reference-app-structure/

该概念在 SAP Spartacus 3.1 版本引入。

这个 Reference App Structure 是 SAP 推荐客户在搭建自己的 Spartacus Storefront 时所用的参考。

Spartacus 包含若干可以 lazy load 的 feature libraries.

Customizations and third-party code add further complexity, and you can end up with modules that are difficult to maintain because they mix too many of these elements together.

定制化和第三方代码进一步增加了项目复杂度,如果处理不得当,很容易出现堆砌了大量 module,难于维护的情况。

This can be solved by defining and adhering to a standardized structure, such as the Spartacus reference app structure.

而遵循 Spartacus reference app structure 来开发,就能避免此类问题出现。

Having a standardized structure also makes it easier to onboard new developers to your project, to handle external support cases, and to take care of audits.

有一套标准的工程结构,也便于新开发人员进入项目后,快速熟悉项目并上手。

结构

1. AppModule

2. SpartacusModule

3.BaseStorefrontModule

从 @spartacus/storefront 里导入,再导出。

4.SpartacusFeatureModule

5. feature related modules

6. 配置 module

Every Angular application has a root app module, usually named AppModule. In the reference app strcuture, this module includes application-wide imports, and avoids complex module imports related to Spartacus by handling only one SpartacusModule.

每个 Angular 应用都有一个 root app module,通常命名为 AppModule. 在 SAP Spartacus reference app structure 里,AppModule 包含了应用层级的 imports:

Both Angular Router and NgRx are used by Spartacus, but these affect the global application, so they are kept outside of the SpartacusModule and are imported directly in the AppModule.

从上图可见,StoreModule 和 EffectsModule 等 module,因为整个应用的其他定制开发很可能也会用到,因此直接在 AppModule 里 import,而没有放到 SpartacusModule 里。

SpartacusModule 包含三部分:

  1. The BaseStorefrontModule, which encapsulates core Spartacus imports that are usually required by most Spartacus applications.

包含了任何 Spartacus 应用都必需的 imports.

The BaseStorefrontModule is imported directly from @spartacus/storefront.

  1. The SpartacusFeaturesModule, which encapsulates Spartacus features.

Spartacus feature 又分为两部分:来自 @Spartacus/storefront 和 features 文件夹下的 modules.

  1. The SpartacusConfigurationModule, which encapsulates the general Spartacus configuration.

配置信息:

Feature-specific configurations can be kept either in feature modules, or in the SpartacusConfigurationModule. Keeping them in feature modules helps to maintain a good separation of concerns, so it is generally recommended.

feature 相关的配置信息,推荐放到 feature modules 里,从而遵循关注点分离的原则。

更多Jerry的原创文章,尽在:“汪子熙”:

SAP Spartacus Reference App Structure相关推荐

  1. SAP Spartacus 定义在app.module.ts里的providers依赖注入元数据何时得到处理

    我基于 SAP Spartacus library创建了一个自定义的Storefront实现.在其app.module.ts里,我采用自定义的MyCurrentProductService,去替换 S ...

  2. SAP Spartacus module 层级结构设计的一种实践

    Reference App Structure 这个推荐的 Spartacus 应用程序结构旨在作为您设置自己的 Spartacus 应用程序时的参考. Spartacus 是一个 Angular 库 ...

  3. 如何找到SAP Spartacus UI可以扩展的outlet

    Spartacus两种outlet: CMS data driven outlet software driven outlet 文件位置: C:\Code\SPA\spartacus\project ...

  4. SAP Spartacus 3.0 的一些变化

    SAP Spartacus 确实使用到了Bootstrap这个框架: Technical Changes in Spartacus 3.0 Breaking Changes Translations ...

  5. SAP Spartacus Template-Driven Outlets

    Template-Driven Outlets 基于模板驱动的 outlets The basic syntax for adding UI is based on a TemplateRef tha ...

  6. 关于 SAP Spartacus Loader Meta Reducer 的用途 - loading 在 true 和 false之前切换的逻辑

    为了给用户更好的反馈,基于他们的行为,我们经常需要保留诸如"正在加载购物车"."获取用户地址失败"等信息. 对于每个单独的应用程序状态,我们必须将元数据放在旁边 ...

  7. SAP Spartacus internationalization ( i18n ) 翻译问题的排错指南

    有 partners 在使用 SAP Spartacus 进行二次开发时,遇到这个警告消息:Translation key missing 'common.search' in the chunk ' ...

  8. 给基于SAP Spartacus 3.4.1 版本的 Storefront 添加对服务器端渲染的支持

    这个 Storefront 的本地地址:C:\Code\SPA\spa3.1\mystore31 基于的 SAP Spartacus 版本:大于 3.1.3,小于 4.0: 查看 package-lo ...

  9. SAP Spartacus 中的依赖注入 Dependency Injection 介绍

    先了解 Angular 中的依赖注入 依赖项是指某个类执行其功能所需的服务或对象.依赖项注入(DI)是一种设计模式,在这种设计模式中,类会从外部源请求依赖项而不是让类自己来创建它们. Angular ...

最新文章

  1. c#子线程线程中操作窗体更新的报错
  2. 1.2.4 计算机的工作过程(从源程序到可执行文件、指令执行过程的描述)
  3. gradient boosted regression tree
  4. ECMAScript面向对象(三)——之继承
  5. MySql数据库常用命令宝典
  6. android 点击热区,增大UIButton的点击热区
  7. 592zn rom/apk 自动签名工具_关于邮件签名证书的常见问题
  8. IOS多选单选相册图片
  9. 计算机教师帮扶记录,信息技术辅导记录.doc
  10. 两台服务器身份验证,OAuth 2 从入门到精通(一) - 身份认证服务器
  11. php 文件上传框架,Laravel框架实现文件上传的方法分析
  12. redis新数据类型-bitmaps
  13. 【CarMaker学习笔记】与Simulink联合仿真
  14. java框架常见的面试题
  15. python3 利用Instaloader下载instagram数据示例
  16. 【牛客网】马三来刷题之数组单调和
  17. C语言理论小学案例试讲,【精选】C语言试讲 演示文稿C语言试讲 演示文稿.ppt
  18. Oracle EBS MRP模块之预测冲减
  19. 名帖329 王羲之 草书《游目帖》
  20. word 文档如何加密

热门文章

  1. 设计一种面向对象脚本语言
  2. H5 C3中的概念(一)
  3. Windows 7 完美安装 Visual C++ 6.0
  4. new、delelte和malloc、free的关系
  5. HSRP(Hot Standby Router Protocol)热备份路由协议
  6. 通过VsPhere体验MAC OS X
  7. go语言按行读取文件
  8. centos who命令 查看当前登录系统用户信息
  9. Java实现遍历N级树形目录结构
  10. Oracle数据库mybatis 插入空值时报错(with JdbcType OTHER)