zl程序教程

您现在的位置是:首页 >  其他

当前栏目

SAP Spartacus CmsPage的加载逻辑

SAP逻辑 加载 Spartacus
2023-09-14 09:02:56 时间

和培训老师讲得一样,经过了connector->adapter->service的过程:

Returns an observable with the page structure. The page structure is

  • typically loaded from a backend, but can also be returned from static
  • configuration (see CmsStructureConfigService).
    // load page by PageContext
    const httpParams = this.getPagesRequestParams(pageContext);
    return this.http
      .get(this.getPagesEndpoint(httpParams, fields), {
        headers: this.headers,
      })
      .pipe(this.converter.pipeable(CMS_PAGE_NORMALIZER));
  }

页面pagecontext由id和type组成:

这个page context作为http请求的参数:

如果没有指定请求的fields,则使用默认的DEFAULT:

/**
   * Returns a fully qualified OCC Url (including baseUrl and baseSite)
   * @param endpoint Name of the OCC endpoint key config
   * @param urlParams  URL parameters
   * @param queryParams Query parameters
   * @param scope
   */
  getUrl(
    endpoint: string,
    urlParams?: object,
    queryParams?: object,
    scope?: string
  ): string

这里取得endpointconfig:

OccEndpointsService._activeBaseSite从哪里来的?




url:https://jerry.eastus.cloudapp.azure.com:9002/occ/v211/electronics-spa/cms/pages?fields=DEFAULT&pageType=ContentPage&pageLabelOrId=homepage

从url可见,pagecontext的id和type,出现在了HTTP请求的parameters里。

要获取更多Jerry的原创文章,请关注公众号"汪子熙":