共用方式為


安裝 Adventure Works 佈景主題

本文介紹如何在中安裝 Adventure Works 主題 Microsoft Dynamics 365 Commerce。

重要

Adventure Works 主題和模組從 Dynamics 365 Commerce 版本 10.0.20 開始提供。 它們可從以下位置獲得 Microsoft AppSource。

前提條件

在安裝 Adventure Works 主題之前,您必須擁有 Dynamics 365 Commerce 環境 (Commerce 版本 10.0.20 或更高版本),其中包括 Retail Cloud Scale Unit (RCSU)、Commerce 在線軟體開發工具包 (SDK) 和 Commerce 模組庫。 有關如何安裝 Commerce SDK 和模組庫的資訊,請參閱 設置開發環境

安裝步驟

在應用程式中安裝 Adventure Works 主題

Adventure Works 主題包在 dynamics365-commerce 提要中 提供,作為 @msdyn365-commerce-theme/adventureworks-theme-kit。 但是,儘管 Adventure Works 主題包是該源的一部分,但它位於不同的命名空間下。 因此,您必須跟隨這些步驟才能為命名空間添加註冊表項。

  1. 更新 .npmrc 檔,使其包含以下註冊表項 (如果尚未包含該項):

    @msdyn365-commerce-theme:registry=https://pkgs.dev.azure.com/commerce-partner/Registry/_packaging/dynamics365-commerce/npm/registry/

  2. 更新 .yarnrc 檔,使其包含以下註冊表項 (如果尚未包含該條目):

    "@msdyn365-commerce-theme:registry" "https://pkgs.dev.azure.com/commerce-partner/Registry/_packaging/dynamics365-commerce/npm/registry/"

若要在本地環境中安裝包,請從命令提示符運行 yarn add THEME_PACKAGE@VERSION 命令,其中 THEME_PACKAGE 是主題包 (@msdyn365-commerce-theme/adventureworks-theme-kit), VERSION 是正在使用的模組庫的版本號。 主題包的版本和模組庫版本必須匹配,這一點很重要。 若要查找要使用的正確模組庫版本號,請打開 package.json 檔,然後在依賴項 部分下 找到 初學者包 值。 在以下示例中,package.json 檔使用映射到 Dynamics 365 Commerce 版本 10.0.22 版本的模組庫 9.32。

"dependencies": {
    "@msdyn365-commerce-modules/starter-pack": "9.32",
}

以下示例演示如何運行 yarn add 命令以添加 Adventure Works 主題的 9.32 版。 該命令會自動更新 package.json 檔,使其包含依賴項。

yarn add @msdyn365-commerce-theme/adventureworks-theme-kit@9.32

有關更新模組庫版本的詳細資訊,請參閱 SDK 和模組庫更新

重要

  • 主題版本應與模組庫版本匹配,以確保所有功能按預期工作。
  • Commerce 模組庫和 SDK 的最低版本應為 10.0.20 (9.31)。

為 Adventure Works 主題新增字型檔案

在您的應用程式中安裝 Adventure Works 主題後,您必須添加該主題所需的字體檔。 若要完成此步驟,請將所有字體檔從 \node_modules@msdyn365-commerce-theme\adventureworks-theme-kit\src\modules\adventureworks\public\webfonts 複製到合作夥伴應用程式公共目錄路徑 \public\webfonts

為 Adventure Works 主題設定資源

下一步是更新主題所需的默認資源。 若要完成此步驟,請將內容從 ode_modules@msdyn365-commerce-theme\adventureworks-theme-kit\src\modules\adventureworks \nesources\modules 下的\rglobal.json 檔案複製到\src esources\modules \r 下的合作夥伴應用程式 global.json 檔中。 如果\src\resources 目標目錄不存在,則可以將其從 \node_modules@msdyn365-commerce-theme\adventureworks-theme-kit\src\modules\adventureworks 源目錄複製到 \src 目標目錄。

拉取更新並驗證主題

有關如何拉取最新 SDK、模組庫和其他依賴項更新的資訊,請參閱 SDK 和模組庫更新 “拉取更新”部分。

下拉最新的依賴項后,您可以在開發環境中運行 yarn start 命令來啟動 Node 伺服器並測試新的 Adventure Works 主題。 使用查詢字串參數 ?theme=adventureworks 在本地瀏覽應用程式 (例如, https://localhost:4000/?theme=adventureworks)。

其他資源

冒險作品主題

模組庫概觀

SDK 和模組庫更新