# 导入 Local Storage

节点类型 `browser_importLocalStorage`

## 功能说明

将给定键值写入页面的 Local Storage。

## 客户端配置界面

![导入 Local Storage节点的客户端配置界面](/assets/import-local-storage.fddc06e7880f552c64e75987401f8d7489d77be970c8c146e1669b69152fc33a.0538f3a9.webp)

截图来自 MoreLogin 桌面客户端 V2.73.101 的英文界面。

## 输入字段

以下字段位于 `data.browserUi.inputs`。

| 字段 | 类型或取值 | Schema 必填 | 执行默认值 | 说明与边界 |
|  --- | --- | --- | --- | --- |
| `dataSource` | `"input"` / `"file"`（支持变量引用） | 否 | `"input"` | 数据来源 编辑器初值 `"input"` |
| `importFile` | `string` / `object` | 否 | — | JSON 文件 |
| `storage` | `["null","boolean","number","string"]` / array<`JSON`> / `object`（支持变量引用） | 否 | — | Local Storage 数据 |
| `importMode` | `"merge"` / `"replace"`（支持变量引用） | 否 | `"merge"` | 导入方式 编辑器初值 `"merge"` |
| `refreshAfterImport` | `boolean`（支持变量引用） | 否 | `false` | 导入后刷新页面 编辑器初值 `false` |


## 条件与边界

- dataSource=input 要求 storage（对象或 JSON 字符串）；file 要求 importFile（JSON 正文或 {content:JSON正文}）。当前页必须是 HTTP/HTTPS。
- 校验错误码 `RPA_NODE_INPUT_INVALID`


## 输入引用

| 字段 | 允许的形式 |
|  --- | --- |
| `dataSource` | `literal`, `template` |
| `importFile` | `literal` |
| `storage` | `literal`, `template` |
| `importMode` | `literal`, `template` |
| `refreshAfterImport` | `literal`, `template` |


## 输出字段

| 输出字段 | 类型或取值 |
|  --- | --- |
| `origin` | `string` |
| `importedCount` | `number` |
| `importMode` | `"merge"` / `"replace"` |
| `refreshed` | `boolean` |


按契约用 `${nodeId.data.field}` 引用公开字段。

## JSON 示例

可放入流程 `nodes` 数组或其他节点 `blocks` 中的完整节点对象。

```json
{
  "id": "restore_settings",
  "type": "browser_importLocalStorage",
  "data": {
    "title": "恢复保存的网站设置",
    "browserAction": "importLocalStorage",
    "browserUi": {
      "inputs": {
        "dataSource": "input",
        "storage": {
          "theme": "dark",
          "language": "en"
        },
        "importMode": "merge",
        "refreshAfterImport": true
      },
      "exception": {
        "timeout": 30000,
        "policy": "interrupt"
      }
    }
  }
}
```

[返回节点目录](/zh/browser-rpa/nodes)