# html API 文档

本文档描述 `html` 模块远程 API，仅保留接口视角。

## 通用约定

- 服务：`baseUrl + devSvcDispatch`
- 默认 `baseUrl`：`https://developer.apis.cloudcc.cn`
- 默认 `devSvcDispatch`：`/devconsole`
- 鉴权：请求头 `accessToken`
- 来源头：`source`，默认 `cloudcc_cli`
- Content-Type：`application/json; charset=utf-8`
- 成功标识：`result === true`，或 `returnCode === "200"`，或 `returnCode` 以 `-OK` 结尾
- 失败信息：优先 `returnInfo`，其次 `errormsg`、`message`

## 1) 查询 HTML 组件列表

- 方法：`POST`
- 路径：`/htmlComponent/pageHtmlComponent`

### 请求参数

- `pageNo`（number，可选）：页码，默认 `1`。
- `pageSize`（number，可选）：每页数量，默认 `50`。
- `condition`（object，可选）：筛选条件。
  - `htmlLabel`（string，可选）：HTML 组件显示名称。
  - `apiName`（string，可选）：HTML 组件 API 名。

### 请求体示例

```json
{
  "pageNo": 1,
  "pageSize": 50,
  "condition": {
    "htmlLabel": "",
    "apiName": ""
  }
}
```

### 返回说明

- 成功时返回 `data` 中的分页数据。
- 列表项字段以平台实际返回为准，常见字段包括 `id`、`apiName`、`htmlLabel`、`accessPath`。

---

## 2) 保存 HTML 组件

- 方法：`POST`
- 路径：`/htmlComponent/saveHtmlComponent`

### 请求参数

- `apiName`（string，必填）：HTML 组件 API 名。
- `htmlLabel`（string，必填）：HTML 组件显示名称。
- `htmlContent`（string，必填）：完整 HTML 内容。

### 请求体示例

```json
{
  "apiName": "demo_html",
  "htmlLabel": "Demo HTML",
  "htmlContent": "<!doctype html><html><body>Demo</body></html>"
}
```

### 返回说明

- 成功时 `data` 为 HTML 组件详情。
- 常见字段包括 `id`、`apiName`、`htmlLabel`、`accessPath`。
- 保存成功后可使用 `accessPath` 创建自定义页面挂载入口。

---

## 3) 查询 HTML 组件详情

- 方法：`POST`
- 路径：`/htmlComponent/detailHtmlComponent`

### 请求参数

- `id`（string，必填）：HTML 组件 ID。

### 请求体示例

```json
{
  "id": "69d780d9e4b0870b069e8fd1"
}
```

### 返回说明

- 成功时 `data` 为 HTML 组件详情。
- 常见字段包括 `id`、`apiName`、`htmlLabel`、`htmlContent`、`accessPath`。

---

## 4) 删除 HTML 组件

- 方法：`POST`
- 路径：`/htmlComponent/deleteHtmlComponent`

### 请求参数

- `id`（string，必填）：HTML 组件 ID。

### 请求体示例

```json
{
  "id": "69e599c9e4b0870b069e8fdc"
}
```

### 返回说明

- 成功：满足通用成功标识。
- 失败：错误信息取 `returnInfo`、`errormsg` 或 `message`。

---

## 5) 自动创建承载页面依赖接口

HTML 组件保存后，若需要自动创建承载页面，还会依赖自定义页面相关接口。

### 5.1 查询自定义组件

- 方法：`POST`
- 路径：`/custom/pc/1.0/post/listCustomComp`

请求体示例：

```json
{
  "orgId": ""
}
```

用途：

- 查询组件分组。
- 在所有分组中查找 `compUniName`、`component` 或 `name` 等于 `cloudcc-iframe` 的内置组件。

### 5.2 创建自定义页面

- 方法：`POST`
- 路径：`/custom/pc/1.0/post/insertCustomPage`

关键请求字段：

- `id`：创建时为空。
- `pageLabel`：页面显示名。
- `pageApi`：页面 API 名。
- `pageContent`：包含 iframe 组件配置的 JSON 字符串。
- `orgId`：组织 ID。
- `compList`：页面引用的组件列表。
- `canvasStyleData`：画布配置 JSON 字符串。

成功标识：

- `returnCode === "200"`。
