# @commercetools-frontend-extensions/export-resources-modal 中文文档

规范地址：https://npmcn.com/package/%40commercetools-frontend-extensions/export-resources-modal/

版本：5\.17\.0
npm 元数据更新时间：2026-11-02T10:13:45.162Z
中文译文更新时间：2026-11-10T12:04:10.484Z
软件包许可：BSD-3-Clause

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40commercetools-frontend-extensions/export-resources-modal
原文对照：https://npmcn.com/package/%40commercetools-frontend-extensions/export-resources-modal/?lang=original

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：1.2 MB，58 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：未声明
- 运行依赖：12 个
- peer 依赖：react 17\.x \|\| 19\.x，redux 4\.x \|\| 5\.x，react-intl 6\.x \|\| 7\.x，react-redux 7\.x \|\| 9\.x，@commercetools-uikit/icons 19\.x \|\| 20\.x，@commercetools-frontend/sdk 24\.x \|\| 25\.x \|\| 27\.x，@commercetools-frontend/i18n 24\.x \|\| 25\.x \|\| 27\.x，@commercetools-frontend/l10n 24\.x \|\| 25\.x \|\| 27\.x，@commercetools-frontend/sentry 24\.x \|\| 25\.x \|\| 27\.x，@commercetools-frontend/ui-kit 19\.x \|\| 20\.x，@commercetools-frontend/constants 24\.x \|\| 25\.x \|\| 27\.x，@commercetools-frontend/fullstory 2\.x \|\| 3\.x \|\| 4\.x，@commercetools-uikit/design-system 19\.x \|\| 20\.x，@commercetools-frontend/actions-global 24\.x \|\| 25\.x \|\| 27\.x，@commercetools-frontend/application-shell 24\.x \|\| 25\.x \|\| 27\.x，@commercetools-frontend/jest-preset-mc-app 24\.x \|\| 25\.x \|\| 27\.x，@commercetools-frontend/application-components 24\.x \|\| 25\.x \|\| 27\.x，@commercetools-frontend/application-shell-connectors 24\.x \|\| 25\.x \|\| 27\.x
- 首次发布：2022-09-17T11:59:11.984Z
- 最新版本发布：2026-11-02T10:13:44.992Z
- 近 30 天下载量：3867（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：440（近 12 个月 148 个）

## 中文简介

共同出口资源模式

## 安装

```sh
npm install @commercetools-frontend-extensions/export-resources-modal
```

也可以使用：`pnpm add @commercetools-frontend-extensions/export-resources-modal`、`yarn add @commercetools-frontend-extensions/export-resources-modal`、`bun add @commercetools-frontend-extensions/export-resources-modal`

## README

# @ 商业工具- 前端- 延伸/ 输出- 资源- 模式

从Merchant Center应用程序输出资源的软件包.

> 此库考虑到了您正在构建一个 Merchant Center 应用程序, 您可以找到文件 [这里](https://docs.commercetools.com/custom-applications/)。 。 。 . 这些组成部分遵循《公约》的同样原则 [用户界面Kit](https://github.com/commercetools/ui-kit) 组件.

## 开始

```bash
$ npm install --save @commercetools-frontend-extensions/export-resources-modal

// or

$ yarn add @commercetools-frontend-extensions/export-resources-modal
```

## 说明

导出资源 Modal是一个用于将资源导出到csv或json文件的内部组件,它正在使用 [出口商服务](https://github.com/commercetools/commercetools-exporter) 创建 Aync 导出任务.

## 使用量

```js
import ExportResourcesModal from '@commercetools-frontend-extensions/export-resources-modal';

// Use case: Exporting all resources
<ExportResourcesModal
    isOpen={true}
    outputFormat="csv"
    resourceType="category"
    totalResourcesCount={143}
    fieldGroups={[
      {
        groupLabel: 'All general fields',
        groupName: 'general-fields',
        previewGroupLabel: 'general fields',
        fields: [
          {
            name: 'key',
            label: 'Category key',
            isRequired: true,
          },
          {
            name: 'externalId',
            label: 'External id',
          },
          {
            name: 'createdAt',
            label: 'Created at',
            isSelectedByDefault: true,
          },
          {
            name: 'lastModifiedAt',
            label: 'Last modified at',
            isSelectedByDefault: true,
          },
          { name: 'name', label: 'Name', isSelectedByDefault: true },
          {
            name: 'parent',
            label: 'parent',
            isSelectedByDefault: true,
            fields: [
              {
                name: 'parent.name',
                label: 'Parent name',
              },
              {
                name: 'parent.key',
                label: 'Parent key',
              },
            ],
          },
          {
            name: 'id',
            label: 'Id',
            isSelectedByDefault: true,
          },
        ],
      },
      {
        groupLabel: 'All custom fields',
        groupName: 'custom-fields',
        previewGroupLabel: 'custom fields',
        fields: [
          {
            name: 'custom-type-key-and-type-id',
            label: 'Custom type key and type id',
          },
          {
            name: 'general-category-attributes',
            label: 'General category attributes',
            fields: [
              {
                name: 'custom.fields.season',
                label: 'Season',
              },
              {
                name: 'custom.fields.target-audience',
                label: 'Target audience',
              },
            ],
          },
          {
            name: 'book-category-attributes',
            label: 'Book category attributes',
            fields: [
              {
                name: 'custom.fields.genre',
                label: 'Genre',
              },
              {
                name: 'custom.fields.age-group',
                label: 'Age group',
              },
            ],
          },
        ],
      },
    ]}
    fieldOrder={['*', 'custom']}
    onClose={() => {
      ...
    }}
/>


// Use case: Exporting filtered resources
<ExportResourcesModal
    isOpen={true}
    outputFormat="csv"
    resourceType="category"
    filters={{
      { 
        filters: [ 'key = "category-key"'], 
        fullText: {
          text: 'category-text',
          locale: 'en'
        } 
      },
      total: 20
    }}
    totalResourcesCount={143}
    fieldGroups={[
      {
        groupLabel: 'All general fields',
        groupName: 'general-fields',
        previewGroupLabel: 'general fields',
        fields: [
          {
            name: 'key',
            label: 'Category key',
            isRequired: true,
          },
          {
            name: 'externalId',
            label: 'External id',
          },
          {
            name: 'createdAt',
            label: 'Created at',
            isSelectedByDefault: true,
          },
          {
            name: 'lastModifiedAt',
            label: 'Last modified at',
            isSelectedByDefault: true,
          },
          { name: 'name', label: 'Name', isSelectedByDefault: true },
          {
            name: 'parent',
            label: 'parent',
            isSelectedByDefault: true,
            fields: [
              {
                name: 'parent.name',
                label: 'Parent name',
              },
              {
                name: 'parent.key',
                label: 'Parent key',
              },
            ],
          },
          {
            name: 'id',
            label: 'Id',
            isSelectedByDefault: true,
          },
        ],
      },
      {
        groupLabel: 'All custom fields',
        groupName: 'custom-fields',
        previewGroupLabel: 'custom fields',
        fields: [
          {
            name: 'custom-type-key-and-type-id',
            label: 'Custom type key and type id',
          },
          {
            name: 'general-category-attributes',
            label: 'General category attributes',
            fields: [
              {
                name: 'custom.fields.season',
                label: 'Season',
              },
              {
                name: 'custom.fields.target-audience',
                label: 'Target audience',
              },
            ],
          },
          {
            name: 'book-category-attributes',
            label: 'Book category attributes',
            fields: [
              {
                name: 'custom.fields.genre',
                label: 'Genre',
              },
              {
                name: 'custom.fields.age-group',
                label: 'Age group',
              },
            ],
          },
        ],
      },
    ]}
    fieldOrder={['*', 'custom']}
    onClose={() => {
      ...
    }}
/>

// Use case: Exporting only selected resources by their IDs
<ExportResourcesModal
    isOpen={true}
    outputFormat="csv"
    resourceType="category"
    selectedResourceIds={['02ed9a7d-7c1f-40da-b2b7-4cca6752bf29', '04051276-1641-4e01-a03e-d4de16b7e4eb', 'ac7d9f7b-5c7d-4dd3-b82b-8555ab4a2a6e']}
    fields={[
      {
          groupLabel: 'All General fields',
          groupName: 'general-fields',
          previewGroupLabel: 'general fields',
          fields:[
            {
              name: 'key',
              label: 'Category key',
              isRequired: true,
              isSelectedByDefault: true,
            },
            {
              name: 'externalId',
              label: 'External id',
            },
            { name: 'createdAt', label: 'Created at', isSelectedByDefault: true, },
            { name: 'lastModifiedAt', label: 'Last modified at', isSelectedByDefault: true, },
            { name: 'name', label: 'Name', isSelectedByDefault: true, },
            {
              name: 'parent',
              isSelectedByDefault: true,
              fields: [
                {
                  name: 'parent.name',
                  label: 'Parent name',
                },
                {
                  name: 'parent.key',
                  label: 'Parent key',
                },
              ],
            },
            {
              name: 'id',
              label: 'Id',
            },
            ]
        },
        {
            groupLabel: 'All custom fields',
            groupName: 'custom-fields',
            previewGroupLabel: 'custom fields',
            fields: [
              {
                name: 'custom-type-key-and-typeid',
                label: 'Custom type key and type id',
                isSelectedByDefault: false,
              },
              {
                name: 'general-category-attributes',
                label: 'General category attributes',
                isSelectedByDefault: false,
                fields: [
                  {
                    name: 'season',
                    label: 'Season',
                  },
                  {
                    name: 'target-audience',
                    label: 'Target audience',
                  },
                ],
              },
              {
                name: 'book-category-attributes',
                label: 'Book category attributes',
                isSelectedByDefault: false,
                fields: [
                  {
                    name: 'genre',
                    label: 'Genre',
                  },
                  {
                    name: 'age-group',
                    label: 'Age group',
                  },
                ],
              },
            ]
        }
    ]}
    onClose={() => {
      ...
    }}
/>
```

## 属性

| 道具 | 类型 | 需求 | 默认 | 说明 |
| --- | --- | :-: | --- | --- |
| `isOpen` | `boolean` |  | `false` | 控制出口模式是否开放或关闭 |
| `outputFormat` | `string`  
可能的值 : `csv`, (中文(简体) ), `json` |  | `csv` | 要导出的文件格式 |
| `onExportSuccess` | `function` |  |  | 当导出操作成功时调用回调函数 |
| `onClose` | `function` |  |  | 在请求关闭模式时引用的调用函数( 在上方点击、 关闭按钮点击或) `ESC` 页:1 此函数在导出操作后也被称为 |
| `resourceType` | `string` | ✅ |  | 资源类型, 例如 : `category`, (中文(简体) ), `product`. |
| `filters` | `Filters` |  |  | 过滤器可以设置为过滤对象 `query` 属性或字符串数组。 也可以设置为简单的字符串 `where` 属性。 最后,另一个选项是将过滤器设置为 `fulltext` 对象为 `text` 财务报告和审定财务报表 `locale` 字符串属性 . |
| `baseFilters` | `Pick<Filters, 'where'>` |  |  | 这些过滤器总是被传送到API(与 `filters` 如果存在道具),并且不能被用户所绕过. |
| `totalResourcesCount` | `number` | ✅ |  | 查明的所有资源数 `resourceType` |
| `selectedResourceIds` | `array` |  |  | 选定资源的 Ids 矩阵 |
| `fieldGroups` | `array` | ✅ |  | 组数 `fields` 以导出. |
| `fieldGroups[].groupLabel` | `string` | ✅ |  | 在字段选择 UI 中显示的字段组标签 |
| `fieldGroups[].previewGroupLabel` | `string` | ✅ |  | 在预览屏幕中显示组名的标签 |
| `fieldGroups[].groupName` | `string` | ✅ |  | 用于确定扩展组状态的字段组名称 |
| `fieldGroups[].isExpanded` | `string` |  | `false` | 此属性用于控制UI中每个可扩展组段的默认状态. 若为 `isExpanded` 设置为 `true`,然后当组件加载时,相应的组会被扩展. 默认值为 `false` 意思是除非明确规定 `true`,该组在初始负载时会倒塌 |
| `fieldGroups[].fields` | `array` | ✅ |  | 要导出字段的矩阵 。 字段必须与 [aPI 计划](https://docs.commercetools.com/api/)。田园可以筑巢 `fields` 阵列. |
| `fieldGroups[].fields[].name` | `string` | ✅ |  | 代表每个字段唯一标识符的字符串。 叶子字段必须与商务工具HTTP API字段相配合,而母字段则可以针对开发者进行特制并用于分组目的. |
| `fieldGroups[].fields[].label` | `string` | ✅ |  | 在导出模式中显示的字段标签 |
| `fieldGroups[].fields[].isRequired` | `boolean` |  | `false` | `isRequired` 字段表示导出过程是否需要字段。 若为 `true` 字段默认会被选中,用户无法取消选择。 这对于对出口过程至关重要的领域是有用的。 按需要标记的字段将有一个 `*` 在UI中标签的后附 |
| `fieldGroups[].fields[].extendedFieldNames` | `array` |  |  | 在导出数据时, 一系列额外的字段名称应该与主字段名称一起包含 . |
| `fieldGroups[].fields[].dependentGroupNames` | `array` |  |  | 所提供的组名数组决定了复选框的状态. 如果报告中提到的任何群体: `dependentGroupNames` 已选择至少一个复选框,然后自动选择字段。 可以选择, `dependentFieldNames` 可用于指定组内的特定字段.  
**说明:** 字段如果有依赖性,则只读取 . |
| `fieldGroups[].fields[].dependentFieldNames` | `array` |  |  | 组合内用于确定复选框状态的特定字段的字段名称数组。 如果 `dependentFieldNames` 中,将自动选择字段. |
| `fieldGroups[].fields[].isSelectedByDefault` | `boolean` |  | `false` | 这个领域是 `fields` 数组用于控制UI中相应复选框的默认状态. 若为 `isSelectedByDefault` 设置为真,当组件加载时,默认将检查该特定字段的复选框. |
| `fieldGroups[].fields[].isExpandable` | `boolean` |  | `false` | `isExpandable` 属性表示是否可以在UI上扩展/缩放字段。 如果 `isExpandable` ,然后在 UI 上显示扩展/缩放按钮以控制 |
| `fieldGroups[].fields[].isExpanded` | `boolean` |  | `false` | 此属性与 `fieldGroups[].fields[].isExpandable` 以控制UI中每个可扩展字段的默认状态。 若为 `fieldGroups[].fields[].isExpanded` 设置为 `true`,然后当组件加载时,相应的字段会被扩展. 默认值为 `false` 意思是除非明确规定 `true`,在初始负载时会崩溃 |
| `fieldOrder` | `string[]` |  |  | 字段名称根据通过的顺序排序. 数值 `*` 可以传递以表示任何字段,例如字段命令=\['\*','custom'\]会将所有从自定义开始的字段推到列表中最后一个字段,而其他字段会位于列表开头 |
| `stores` | `Array<{ key: string; name: string }>` |  |  | 提供时 `resourceType` 定义 `exportScopeSpecificStore` ),使附加的"特定商店"范围选项带有商店选择下放. 选择存储集 `where=store(key="<key>")` 关于出口请求. |
| `selectedScopeQueryPredicateBuilder` | `(selectedResourceIds: string[]) => string` |  |  | 覆盖 `where` 为Selected范围生产出上游. 有用时 `selectedResourceIds` 引用相关的资源——例如,在标识为产品标识的地方,调整出口,所以上游必须是: `product(id in (...))` 而不是默认 `id in (...)`。 。 。 . |

## 释放

此软件包使用 [`changesets`](https://github.com/atlassian/changesets) 向国家预防机制释放人员.

如果您想要发布新版本, 并需要最新修改 :

1.  添加一个更改列表 `pnpm changeset` 选择 `@commercetools-frontend-extensions/export-resources-modal` 作为已修改的软件包.
2.  为了完成发行工作,将出现一些选项:
    -   `patch`: 使用此释放来修正或小修改
    -   `minor`: 使用此释放用于调试升级或中度更改
    -   `major`: 使用此发布来打破更改
3.  在选择选项后, 您需要为发布注释添加注释 。 我们建议对犯法者采用同样的方式.
    -   例如: `feat(utils): add utils for dates`
4.  推开 `changeset` 到您的分支和 GitHub 动作将检测 PR 包含影响已出版库的更改 .
5.  在公关合并后,将创建另一个公关 `Version Packages` 这也是GitHub Actions将发现的 向国家预防机制释放的人.
6.  确保一切正确,然后合并 `Version Packages` 公关.
7.  等待国家防范机制提供新版本,然后在CircleCI中部署自定义.

### 加那利释放

加那利版本在成功构建后通过CI自动发布到发行渠道并合并到 **主要** 树枝.

## i18n (英语)

Repo被配置为与Transifex的集成. i18n的流程与商贸中心使用的流程相同.

`pnpm i18n:build` 用于将新密钥添加到 transifex.

一旦公关合并到 `main` transifex将收到一份带有需要翻译的新密钥的通知(这就是为什么必须 `description` 财务报告和审定财务报表 `defaultMessage` 说明性足够.

每当翻译者完成翻译并按原样进行标记时,repo会收到一个PR(每个语言)来添加被翻译的信息.

一旦我们审查翻译的密钥正确无误并添加一个 `changeset` 我们可以合并公关 (别忘了部署自定义应用程序)

## 常见问题

### @commercetools-frontend-extensions/export-resources-modal 是什么？

共同出口资源模式

### 如何安装 @commercetools-frontend-extensions/export-resources-modal？

在项目目录运行 npm install @commercetools-frontend-extensions/export-resources-modal，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：react（17\.x \|\| 19\.x）、redux（4\.x \|\| 5\.x）、react-intl（6\.x \|\| 7\.x）、react-redux（7\.x \|\| 9\.x）、@commercetools-uikit/icons（19\.x \|\| 20\.x）、@commercetools-frontend/sdk（24\.x \|\| 25\.x \|\| 27\.x）、@commercetools-frontend/i18n（24\.x \|\| 25\.x \|\| 27\.x）、@commercetools-frontend/l10n（24\.x \|\| 25\.x \|\| 27\.x）、@commercetools-frontend/sentry（24\.x \|\| 25\.x \|\| 27\.x）、@commercetools-frontend/ui-kit（19\.x \|\| 20\.x）、@commercetools-frontend/constants（24\.x \|\| 25\.x \|\| 27\.x）、@commercetools-frontend/fullstory（2\.x \|\| 3\.x \|\| 4\.x）、@commercetools-uikit/design-system（19\.x \|\| 20\.x）、@commercetools-frontend/actions-global（24\.x \|\| 25\.x \|\| 27\.x）、@commercetools-frontend/application-shell（24\.x \|\| 25\.x \|\| 27\.x）、@commercetools-frontend/jest-preset-mc-app（24\.x \|\| 25\.x \|\| 27\.x）、@commercetools-frontend/application-components（24\.x \|\| 25\.x \|\| 27\.x）、@commercetools-frontend/application-shell-connectors（24\.x \|\| 25\.x \|\| 27\.x）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @commercetools-frontend-extensions/export-resources-modal 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/commercetools-frontend-extensions\_\_export-resources-modal 是否存在。

### @commercetools-frontend-extensions/export-resources-modal 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @commercetools-frontend-extensions/export-resources-modal 可以商用吗？

@commercetools-frontend-extensions/export-resources-modal 使用 BSD-3-Clause 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括，不构成法律意见，请以许可原文为准。

### @commercetools-frontend-extensions/export-resources-modal 的下载量有多少？

根据 npm 官方下载统计，@commercetools-frontend-extensions/export-resources-modal 在 2026/10/11 – 2026/11/09 这 30 天内被下载 3,867 次，日均约 129 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @commercetools-frontend-extensions/export-resources-modal 还在维护吗？

最新版本 5\.17\.0 发布于 2026/11/02（8 天前）；至今共发布 440 个版本，其中过去 12 个月发布了 148 个；首次发布于 2022/09/17。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

