yichael 2 týždňov pred
rodič
commit
fa5c2250f5

+ 0 - 0
doc/IPC快速参考.md → doc/IPC调用说明/IPC快速参考.md


+ 40 - 0
doc/IPC调用说明/JSON_PARSER.md

@@ -0,0 +1,40 @@
+# JSON Parser 使用说明
+
+通过 IPC 调用 `json-parser.js` 对 **static 目录下**的 JSON 做创建、读取、更新和存在检查。路径相对于 `static`,如 `jason/testjson` → `static/jason/testjson.json`(无 `.json` 会自动补全)。
+
+---
+
+## 推荐:封装函数(device.js)
+
+```javascript
+import { createJsonFile, readJsonFile, updateJsonFile, checkJsonFileExists } from './device.js'
+
+await createJsonFile('jason/testjson', { devices: [] })
+const data = await readJsonFile('jason/testjson')                    // 整个文件
+const ip = await readJsonFile('jason/testjson', ['devices', 0, 'ip']) // 键路径
+await updateJsonFile('jason/testjson', { newKey: 'value' })          // 整文件合并
+await updateJsonFile('jason/testjson', true, ['settings', 'autoConnect']) // 按路径更新
+const exists = await checkJsonFileExists('jason/testjson')
+```
+
+---
+
+## 底层调用(runNodejsScript)
+
+| 操作 | 参数 | 返回 |
+|------|------|------|
+| `create` | `filePath`, `jsonString` | `{ success, message }` |
+| `read` | `filePath`, 可选 `keyPathJson` | `{ success, data }`,无文件时 `data: null` |
+| `update` | `filePath`, `jsonString`, 可选 `keyPathJson` | `{ success, message }` |
+| `check` | `filePath` | `{ success, exists }` |
+
+调用方式:`window.electronAPI.runNodejsScript('json-parser', operation, ...args)`,返回的 `stdout` 需 `JSON.parse()`。键路径为数组并 `JSON.stringify`,如 `['devices', 0, 'ip']`。
+
+---
+
+## 注意
+
+- 路径仅限 `static` 下,禁止 `..` 和绝对路径。
+- 数据传入前需 `JSON.stringify()`;读回后对 `stdout` 做 `JSON.parse()`。
+- 失败时返回 `{ success: false, error: "..." }`;读操作文件不存在为 `{ success: true, data: null }`。
+- 目录不存在时会自动创建。

+ 0 - 0
doc/调用NodeJS脚本方案.md → doc/IPC调用说明/调用NodeJS脚本方案.md


+ 0 - 0
doc/调用Python脚本方案.md → doc/IPC调用说明/调用Python脚本方案.md


+ 0 - 210
doc/JSON_PARSER.md

@@ -1,210 +0,0 @@
-# JSON Parser 使用文档
-
-## 功能说明
-
-通过 IPC 调用 `json-parser.js` 进行 JSON 文件的创建、读取、更新和存在性检查。
-
-**重要:** 所有文件只能保存在 `static` 目录下,使用相对路径即可。如果传入 `jason/testjson`,实际文件路径为 `static/jason/testjson.json`。
-
-## 操作类型
-
-### 1. create - 创建 JSON 文件
-
-创建新的 JSON 文件。
-
-**参数:**
-- `operation`: `'create'`
-- `filePath`: JSON 文件相对路径(相对于 `static` 目录),如 `jason/testjson`,会自动添加 `.json` 扩展名
-- `jsonString`: JSON 数据(字符串格式)
-
-**示例:**
-```javascript
-const response = JSON.parse((await window.electronAPI.runNodejsScript('json-parser', 'create', 'jason/testjson', JSON.stringify({devices: [], settings: {}}))).stdout)
-```
-
-**返回:**
-```json
-{
-  "success": true,
-  "message": "JSON file created successfully"
-}
-```
-
-### 2. read - 读取 JSON 文件
-
-读取 JSON 文件内容。如果文件不存在,返回 `{ success: true, data: null }`。
-
-**参数:**
-- `operation`: `'read'`
-- `filePath`: JSON 文件相对路径(相对于 `static` 目录),如 `jason/testjson`
-- `keyPathJson`: (可选)键路径数组,如 `JSON.stringify(['devices', 0, 'ip'])`
-
-**示例:**
-```javascript
-// 读取整个文件
-const readResult = await window.electronAPI.runNodejsScript('json-parser', 'read', 'device_list.json')
-const readResponse = JSON.parse(readResult.stdout)
-const data = readResponse.data
-
-// 如果文件不存在(data 为 null),则创建
-if (data === null) {
-    const createResult = await window.electronAPI.runNodejsScript('json-parser', 'create', 'device_list.json', JSON.stringify({devices: []}))
-}
-
-// 读取特定路径
-const ip = JSON.parse((await window.electronAPI.runNodejsScript('json-parser', 'read', 'jason/testjson', JSON.stringify(['devices', 0, 'ip']))).stdout).data
-```
-
-**返回:**
-```json
-// 文件存在时
-{
-  "success": true,
-  "data": {...}
-}
-
-// 文件不存在时
-{
-  "success": true,
-  "data": null
-}
-```
-
-### 3. update - 更新 JSON 文件
-
-更新 JSON 文件内容。
-
-**参数:**
-- `operation`: `'update'`
-- `filePath`: JSON 文件相对路径(相对于 `static` 目录),如 `jason/testjson`
-- `jsonString`: 要更新的 JSON 数据(字符串格式)
-- `keyPathJson`: (可选)键路径数组,用于更新特定路径
-
-**示例:**
-```javascript
-// 更新整个文件(合并)
-const response = JSON.parse((await window.electronAPI.runNodejsScript('json-parser', 'update', 'jason/testjson', JSON.stringify({newKey: 'value'}))).stdout)
-
-// 更新特定路径
-const response = JSON.parse((await window.electronAPI.runNodejsScript('json-parser', 'update', 'jason/testjson', JSON.stringify(true), JSON.stringify(['settings', 'autoConnect']))).stdout)
-```
-
-**返回:**
-```json
-{
-  "success": true,
-  "message": "JSON file updated successfully"
-}
-```
-
-### 4. check - 检查文件是否存在
-
-检查 JSON 文件是否存在。
-
-**参数:**
-- `operation`: `'check'`
-- `filePath`: JSON 文件相对路径(相对于 `static` 目录),如 `jason/testjson`
-
-**示例:**
-```javascript
-const exists = JSON.parse((await window.electronAPI.runNodejsScript('json-parser', 'check', 'jason/testjson')).stdout).exists
-```
-
-**返回:**
-```json
-{
-  "success": true,
-  "exists": true
-}
-```
-
-## 封装函数使用(推荐)
-
-在 `device.js` 中已提供封装函数,使用更简洁:
-
-```javascript
-import { 
-  createJsonFile, 
-  readJsonFile, 
-  updateJsonFile, 
-  checkJsonFileExists 
-} from './device.js'
-
-// 创建 JSON 文件
-const result = await createJsonFile('jason/testjson', {devices: []})
-
-// 读取整个文件
-const data = await readJsonFile('jason/testjson')
-
-// 读取特定路径
-const ip = await readJsonFile('jason/testjson', ['devices', 0, 'ip'])
-
-// 更新整个文件
-const result = await updateJsonFile('jason/testjson', {newKey: 'value'})
-
-// 更新特定路径
-const result = await updateJsonFile('jason/testjson', true, ['settings', 'autoConnect'])
-
-// 检查文件是否存在
-const exists = await checkJsonFileExists('jason/testjson')
-```
-
-## 键路径格式
-
-键路径使用数组格式,然后通过 `JSON.stringify()` 序列化:
-
-```javascript
-// 访问 devices[0].ip
-JSON.stringify(['devices', 0, 'ip'])
-
-// 访问 settings.theme
-JSON.stringify(['settings', 'theme'])
-
-// 访问 users[1].profile.name
-JSON.stringify(['users', 1, 'profile', 'name'])
-```
-
-## 注意事项
-
-1. **文件路径**:使用相对路径(相对于 `static` 目录),如 `jason/testjson` 会保存为 `static/jason/testjson.json`
-2. **自动添加扩展名**:如果路径没有 `.json` 扩展名,会自动添加
-3. **路径安全**:禁止使用 `..` 或绝对路径,所有文件只能在 `static` 目录下
-4. **JSON 序列化**:所有 JSON 数据必须使用 `JSON.stringify()` 序列化
-5. **返回值解析**:脚本返回的 `stdout` 是 JSON 字符串,需要 `JSON.parse()` 解析
-6. **错误处理**:检查返回的 `success` 字段判断操作是否成功
-7. **自动创建目录**:如果文件所在目录不存在,会自动创建
-8. **read 操作特性**:文件不存在时返回 `{ success: true, data: null }`,可通过 `data === null` 判断文件是否存在
-
-## 实际应用示例
-
-### 读取或创建文件
-
-```javascript
-const readResult = await window.electronAPI.runNodejsScript('json-parser', 'read', 'device_list.json')
-const readResponse = JSON.parse(readResult.stdout)
-let jsonData = readResponse.data
-
-if (jsonData === null) {
-    const createResult = await window.electronAPI.runNodejsScript('json-parser', 'create', 'device_list.json', JSON.stringify({devices: []}))
-    const createResponse = JSON.parse(createResult.stdout)
-    if (createResponse.success) {
-        jsonData = {devices: []}
-    }
-}
-```
-
-## 错误示例
-
-```json
-{
-  "success": false,
-  "error": "Missing jsonString parameter for create operation"
-}
-```
-
-```json
-{
-  "success": false,
-  "error": "Invalid file path"
-}
-```

+ 0 - 67
doc/README.md

@@ -8,70 +8,3 @@
 - `npm run electron:dev`:同时启动 Vite 开发服务器并在准备好后打开 Electron(推荐开发时使用)。
 - `npm run build`:构建生产版本。
 - `npm run preview`:预览构建后的应用。
-
-**四、将页面设置为子页面(条件渲染)
-
-**步骤:**
-
-**1. 修改 `src/pages/Home.jsx`**:
-   - 添加:`import Devices from './Devices/Devices';`
-   - 在 `HomeLogic()` 中获取:`const { showDevices, setShowDevices } = HomeLogic();`
-   - 在 return 中添加:`{showDevices && <Devices />}` 和按钮控制显示/隐藏
-
-**2. 修改 `src/pages/Home.js`**:
-   - 添加:`import { useState } from 'react';`
-   - 在 `HomeLogic` 中添加:`const [showDevices, setShowDevices] = useState(false);`
-   - return 中暴露:`showDevices, setShowDevices`
-
-**3. 修改 `src/App.jsx`**:
-   - 删除 Devices 的 import 和组件使用
-
-**五、响应式字体大小设置**
-
-根据窗口的宽高变化,字体大小自动缩放。在最外层父标签设置基础字体大小,下面所有子标签的字体都使用 `rem` 为单位即可。
-
-**示例:**
-
-```scss
-// ========== 字体大小配置 ==========
-$font-size-scale: 1.0;  // 字体缩放系数,调整此值可改变字体大小(数值越大字体越大,越小字体越小)
-
-/* 计算过程:
- * home-bg grid: Device占第一列20%
- * device-container: 20vw × 100vh
- * device-list: 20vw × 80vh (100% × 80% of device-container)
- * connect-item-container: 80% × 10% of device-list
- * 宽度:80% × 20vw = 16vw
- * 高度:10% × 80vh = 8vh
- * 
- * 调整字体大小:
- * - 修改文件顶部的 $font-size-scale 变量
- * - 增大字体:增加变量值(如改为 1.5 或 2.0)
- * - 减小字体:减小变量值(如改为 0.5 或 0.8)
- * - 数值越大,字体越大;数值越小,字体越小
- */
-font-size: min(calc(16vw * 0.06 * $font-size-scale), calc(8vh * 0.12 * $font-size-scale));
-```
-
-**参数说明:**
-
-- **`16vw`**:目标元素相对于窗口的宽度(通过层级百分比计算得出)
-- **`8vh`**:目标元素相对于窗口的高度(通过层级百分比计算得出)
-- **`0.06`**:基础宽度比例系数(元素宽度的6%)
-- **`0.12`**:基础高度比例系数(元素高度的12%)
-- **`$font-size-scale`**:字体缩放系数变量,用于统一调整字体大小
-- **`min()`**:取两个计算结果中的较小值,确保字体同时响应宽高变化
-
-**计算方法:**
-1. 从最外层容器开始,逐层计算百分比
-2. 最终得到目标元素相对于窗口的 vw 和 vh 值
-3. 例如:home-bg grid(20%) → device-container(100%) → device-list(100% × 80%) → connect-item-container(80% × 10%)
-4. 结果:16vw × 8vh
-
-**调整方法:**
-- **推荐方式**:修改 `$font-size-scale` 变量来调整字体大小
-  - 增大字体:增加变量值(如 `1.5`、`2.0`)
-  - 减小字体:减小变量值(如 `0.5`、`0.8`)
-  - 默认值 `1.0` 保持当前大小
-- **高级调整**:如需单独调整宽度或高度比例,可修改 `0.06` 和 `0.12` 的值
-- 根据实际布局层级重新计算 vw 和 vh 值

+ 0 - 0
doc/SCSS_VS_CSS.md → doc/SCSS使用教程.md


+ 0 - 45
doc/ef-compiler-coding-standards.md

@@ -1,45 +0,0 @@
-# ef-compiler 与编码规范对照
-
-参考 [CODING_STANDARDS.md](./CODING_STANDARDS.md),对 `nodejs/ef-compiler` 的适用情况与已做调整说明如下。
-
-## 已落实
-
-| 规范 | 说明 |
-|------|------|
-| **§1–2 命名** | 文件名、变量名使用连字符、有意义命名(如 `value-resolver.js`、`workflow-parser.js`)。 |
-| **§3 注释** | 各组件入口函数有注释说明用途。 |
-| **§4 函数拆分** | 逻辑已拆到 `components/`(config、value-resolver、expression-evaluator、runtime-api、workflow-parser、actions/*)。 |
-| **§7 最少代码** | 无多余封装,按需引用组件。 |
-| **§8 无 console.log** | 已移除生产代码中的 `console.log`(如 `components/actions/log-parser.js`)。 |
-| **§11 switch** | 操作类型分支使用 `switch (action.type)` / `switch (method)`。 |
-| **§12 提前 return** | 多数分支使用提前 return,减少 else。 |
-| **§13 存在性检查** | `runtime-api.js` 中 `appendLog` 不再用 `existsSync` 判断目录,直接 `fs.mkdirSync(logDir, { recursive: true })`。 |
-
-## 与规范不一致处(及原因)
-
-| 规范 | 当前做法 | 说明 |
-|------|----------|------|
-| **§5 不使用 try-catch** | 编译器内仍有多处 try-catch | 工作流引擎需要把「单步失败」当作正常结果:失败时写入 log.txt 并返回 `{ success: false }`,由调用方决定是否继续,而不是让进程直接崩溃。若全部去掉 try-catch,任何一步异常都会导致整次执行中断且无结构化错误信息。 |
-| **§13 存在性检查** | `fun/img-center-point-location.js`、`fun/img-cropping.js` 中仍有 `fs.existsSync` 选 Python 路径 | 用于在多个候选路径(venv/Scripts、py 嵌入等)中选第一个存在的。若改为「不检查、直接使用第一个」,在部分环境会直接报错。若希望严格符合 §13,可改为固定顺序尝试 `require`/执行,失败再试下一个并最终抛错,而不是先 existsSync。 |
-
-## 建议后续可做
-
-- **§5**:若希望逐步向「少用 try-catch」靠拢,可只保留「步骤执行 + 写 log」这一层 try-catch,内部解析/变量等尽量不捕错,让异常上抛到该层统一记录。
-- **§13**:`fun` 下 Python 路径解析可重构为「按顺序尝试路径,失败即抛错」,去掉 existsSync,由调用链决定是否捕获。
-
-## 文件结构(与规范对应)
-
-```
-nodejs/ef-compiler/
-├── ef-compiler.js          # 主机:解析与执行入口,引用 components
-├── components/             # 无 UI,仅逻辑,符合 §4、§6 不适用
-│   ├── compiler-config.js
-│   ├── value-resolver.js
-│   ├── expression-evaluator.js
-│   ├── runtime-api.js
-│   ├── workflow-parser.js
-│   └── actions/            # 各 type 的 parse/execute 拆分
-└── fun/                    # 各能力实现(图像、聊天等)
-```
-
-上述为当前与 [CODING_STANDARDS.md](./CODING_STANDARDS.md) 的对照与实施说明,后续若规范或 ef-compiler 职责有变更,可再更新本文档。

+ 0 - 0
doc/CODING_STANDARDS.md → doc/代码规范.md


+ 0 - 0
doc/node说明.txt → doc/可视化编程/可视化Node编程说明.md


+ 51 - 0
doc/多分辨率适配/多分辨率字体适配计算原理.md

@@ -0,0 +1,51 @@
+# 多分辨率适配
+
+## 响应式字体大小设置
+
+根据窗口的宽高变化,字体大小自动缩放。在最外层父标签设置基础字体大小,下面所有子标签的字体都使用 `rem` 为单位即可。
+
+**示例:**
+
+```scss
+// ========== 字体大小配置 ==========
+$font-size-scale: 1.0;  // 字体缩放系数,调整此值可改变字体大小(数值越大字体越大,越小字体越小)
+
+/* 计算过程:
+ * home-bg grid: Device占第一列20%
+ * device-container: 20vw × 100vh
+ * device-list: 20vw × 80vh (100% × 80% of device-container)
+ * connect-item-container: 80% × 10% of device-list
+ * 宽度:80% × 20vw = 16vw
+ * 高度:10% × 80vh = 8vh
+ * 
+ * 调整字体大小:
+ * - 修改文件顶部的 $font-size-scale 变量
+ * - 增大字体:增加变量值(如改为 1.5 或 2.0)
+ * - 减小字体:减小变量值(如改为 0.5 或 0.8)
+ * - 数值越大,字体越大;数值越小,字体越小
+ */
+font-size: min(calc(16vw * 0.06 * $font-size-scale), calc(8vh * 0.12 * $font-size-scale));
+```
+
+**参数说明:**
+
+- **`16vw`**:目标元素相对于窗口的宽度(通过层级百分比计算得出)
+- **`8vh`**:目标元素相对于窗口的高度(通过层级百分比计算得出)
+- **`0.06`**:基础宽度比例系数(元素宽度的6%)
+- **`0.12`**:基础高度比例系数(元素高度的12%)
+- **`$font-size-scale`**:字体缩放系数变量,用于统一调整字体大小
+- **`min()`**:取两个计算结果中的较小值,确保字体同时响应宽高变化
+
+**计算方法:**
+1. 从最外层容器开始,逐层计算百分比
+2. 最终得到目标元素相对于窗口的 vw 和 vh 值
+3. 例如:home-bg grid(20%) → device-container(100%) → device-list(100% × 80%) → connect-item-container(80% × 10%)
+4. 结果:16vw × 8vh
+
+**调整方法:**
+- **推荐方式**:修改 `$font-size-scale` 变量来调整字体大小
+  - 增大字体:增加变量值(如 `1.5`、`2.0`)
+  - 减小字体:减小变量值(如 `0.5`、`0.8`)
+  - 默认值 `1.0` 保持当前大小
+- **高级调整**:如需单独调整宽度或高度比例,可修改 `0.06` 和 `0.12` 的值
+- 根据实际布局层级重新计算 vw 和 vh 值

+ 140 - 166
doc/工作流语法.md

@@ -9,226 +9,200 @@
 }
 ```
 
-## 语法分层
+## 结点总结
 
-- **基础语法**:`schedule`、`if`、`while`
-- **基础 action**:`adb`(通过 method 区分)
-- **扩展标签(Func)**:`src/pages/processing/func/` 目录下的脚本文件名即为标签名
+- **控制/循环结点**:`schedule`、`if`、`for`、`while`
+- **系统结点**:`delay`、`set`、`echo`、`random`、`log`
+- **ADB 结点**:`input`、`click`、`locate`、`press`、`swipe`、`scroll`、`keyevent`
+- **扩展标签(Func)**:
+- `ocr-chat`、`extract-messages`、`ocr-chat-history`、`extract-chat-history`、`read-last-message`、`smart-chat-append`、`save-messages`、`generate-summary`、`generate-history-summary`、`read-txt` / `read-text`、`save-txt` / `save-text`、`img-center-point-location`、`img-bounding-box-location`、`img-cropping`、`ai-generate`、`string-press`
 
-## 定时执行(schedule)
+---
+
+## 结点分类说明
+
+---
+
+### 一、控制/循环结点
+
+**schedule**(定时执行)
 
 ```json
-{
-  "type": "schedule",
-  "condition": {
-    "interval": "1s",
-    "repeat": -1
-  },
-  "interval": []
-}
+{ "type": "schedule", "condition": { "interval": "1s", "repeat": -1 }, "interval": [] }
 ```
 
-- `interval`: 执行间隔("1s", "2m", "3h")
-- `repeat`: 重复次数(`-1` 表示无限循环)
+- `condition.interval`:间隔(如 `"1s"`、`"2m"`、`"3h"`)。`condition.repeat`:次数,`-1` 或 `"forever"` 为无限。`interval`:每次执行的操作数组。
 
-## ADB操作(adb
+**if**(条件判断)
 
-统一格式:
 ```json
-{
-  "type": "adb",
-  "method": "input|click|locate|swipe|scroll|press|string-press",
-  "inVars": [],
-  "outVars": []
-}
+{ "type": "if", "condition": "{变量} == '值'", "then": [], "else": [] }
 ```
 
-| method | 说明 | inVars |
-|--------|------|--------|
-| `input` | 输入文本 | `[0]`: 文本内容 |
-| `click` | 点击 | `[0]`: 位置坐标(字符串格式:`"{\"x\":123,\"y\":456}"` 或 `"123,456"`) |
-| `locate` | 定位 | `[0]`: 图片/文字,`outVars[0]`: 保存位置 |
-| `swipe` | 滑动 | `[0]`: 方向(up-down/down-up/left-right/right-left) |
-| `scroll` | 滚动 | `[0]`: 方向(up/down) |
-| `press` | 图像匹配并点击 | `[0]`: 图片路径 |
-| `string-press` | 文字识别并点击 | `[0]`: 文字内容 |
+- `condition` 支持 `{变量}`、`==` `!=` `>` `<` `>=` `<=`、`&&` `||`。兼容旧字段 **ture**。
 
-## 条件判断(if
+**for**(循环)
 
 ```json
-{
-  "type": "if",
-  "condition": "{变量} == '值'",
-  "ture": [],
-  "false": []
-}
+{ "type": "for", "variable": "{item}", "items": [1, 2, 3], "body": [] }
 ```
 
-支持操作符:`==` `!=` `>` `<` `>=` `<=`
+- `variable`:当前元素变量。`items`:数组(可写 `"{listVar}"`)。`body`:每轮操作数组。
 
-### 条件判断示例
+**while**(循环)
 
-**数值比较:**
 ```json
-{
-  "type": "if",
-  "condition": "{count} > 5",
-  "ture": [{"type": "echo", "value": "count大于5"}],
-  "false": []
-}
+{ "type": "while", "condition": "{变量} > 0", "body": [] }
 ```
 
-**字符串比较:**
+- `condition` 同 if。`body`:循环体。兼容旧字段 **ture**。
+
+---
+
+### 二、系统结点
+
+**delay**(延迟)
+
 ```json
-{
-  "type": "if",
-  "condition": "{message} == \"hello\"",
-  "ture": [{"type": "echo", "value": "消息是hello"}],
-  "false": []
-}
+{ "type": "delay", "value": "2s" }
+```
+
+- 也支持字段 `delay`。单位:`s`、`m`、`h`。
+
+**set**(变量设置)
+
+```json
+{ "type": "set", "variable": "{name}", "value": "value" }
 ```
 
-**布尔值判断:**
+- **支持的数据类型**:`number`(整数或小数)、`string`(字符串)、`bool`(`true` / `false`)。写入后参与运算或比较时按上述类型处理;布尔在变量上下文中以 `"1"` / `"0"` 存储。
+- `value` 支持 `{var}` 替换;含 `+`、`-`、`*`、`/` 时按算术表达式求值。变量定义在根级 `variables`,引用用 `"{name}"`,echo 中拼接用 `{{name}}`。
+
+**echo**(打印console.log信息)
+
 ```json
-{
-  "type": "if",
-  "condition": "{isReady} == true",
-  "ture": [{"type": "echo", "value": "已准备好"}],
-  "false": [{"type": "echo", "value": "未准备好"}]
-}
+{ "type": "echo", "value": "消息: {{var}}" }
 ```
+或
+```json
+{ "type": "echo", "inVars": ["{var1}", "{var2}"] }
+```
+
+- 打印信息到log.txt,如果报错会把报错信息显示
+
+**log**(仅 UI 输出)
 
-或直接使用布尔变量:
 ```json
-{
-  "type": "if",
-  "condition": "{isReady}",
-  "ture": [{"type": "echo", "value": "已准备好"}],
-  "false": []
-}
+{ "type": "log", "value": "调试信息" }
+```
+或
+```json
+{ "type": "log", "inVars": ["{var}"] }
 ```
 
-## 循环(while
+**random**(随机数
 
 ```json
-{
-  "type": "while",
-  "condition": "{变量} > 0",
-  "ture": []
-}
+{ "type": "random", "inVars": ["1", "100"], "outVars": ["{randomNum}"], "integer": true }
 ```
 
-> 注意:`ture` 是 `body` 的别名。
+- `inVars[0/1]`:最小/最大值。`outVars[0]`:结果变量。`integer` 默认 `true`。传统写法 `variable`、`min`、`max` 仍支持。
+
+---
 
-## 内置操作
+### 三、ADB 结点
 
-### 延迟(delay)
 ```json
-{ "type": "delay", "value": "2s" }
+{ "type": "input", "value": "文本", "clear": false }
+```
+```json
+{ "type": "click", "target": "{\"x\":100,\"y\":200}" }
+```
+```json
+{ "type": "locate", "method": "image", "target": "resources/icon.png", "variable": "{pos}" }
+```
+```json
+{ "type": "press", "value": "resources/btn.png" }
+```
+```json
+{ "type": "swipe", "value": "up-down" }
+```
+```json
+{ "type": "scroll", "value": "down" }
+```
+```json
+{ "type": "keyevent", "value": "4" }
 ```
 
-### 设置变量(set)
+---
+
+### 四、扩展标签(Func)
+
+**通用基础结构**(多数扩展标签)
+
 ```json
-{ "type": "set", "variable": "{name}", "value": "value" }
+{ "type": "标签名", "inVars": [], "outVars": [] }
 ```
 
-### 打印信息(echo)
+各扩展标签基础结构示例:
+
+- **fun**(method 为 func 目录下脚本名)
 ```json
-{ "type": "echo", "value": "当前消息: {{lastMessage}}" }
+{ "type": "fun", "method": "脚本文件名", "inVars": [], "outVars": [] }
 ```
 
-或使用 `inVars`:
+- **ocr-chat** / **extract-messages** / **ocr-chat-history** / **extract-chat-history**
 ```json
-{ "type": "echo", "inVars": ["{lastMessage}", "{lastRole}"] }
+{ "type": "ocr-chat", "inVars": ["(r,g,b)", "(r,g,b)", "区域坐标JSON"], "outVars": ["{chatHistory}"] }
 ```
 
-- `value`: 直接文本,支持 `{{variable}}` 格式的变量替换(双花括号用于字符串拼接)
-- `inVars`: 变量名数组,输出所有变量的值
+- **read-last-message**
+```json
+{ "type": "read-last-message", "inVars": ["{chatJson}"], "outVars": ["{text}", "{sender}"] }
+```
 
-> 注意:`log` 标签已废弃,请使用 `echo` 标签。
+- **smart-chat-append**
+```json
+{ "type": "smart-chat-append", "inVars": ["{history}", "{current}"], "outVars": ["{merged}"] }
+```
 
-### 随机数(random)
+- **read-txt** / **read-text**
 ```json
-{
-  "type": "random",
-  "inVars": ["1", "100"],
-  "outVars": ["{randomNum}"]
-}
+{ "type": "read-txt", "inVars": ["history/chat-history.txt"], "outVars": ["{content}"] }
 ```
 
-- `inVars[0]`: 最小值(字符串格式的数字或变量引用)
-- `inVars[1]`: 最大值(字符串格式的数字或变量引用)
-- `outVars[0]`: 输出变量(**`number` 类型**,可以是整数或小数)
+- **save-txt** / **save-text**
+```json
+{ "type": "save-txt", "inVars": ["{content}", "history/out.txt"], "outVars": [] }
+```
 
-**传统格式(已过时,建议使用上述格式):**
+- **img-center-point-location**
 ```json
-{ 
-  "type": "random", 
-  "variable": "num", 
-  "min": 1, 
-  "max": 100, 
-  "integer": true 
-}
+{ "type": "img-center-point-location", "inVars": ["template.png"], "outVars": ["{pos}"] }
+```
+
+- **img-bounding-box-location**
+```json
+{ "type": "img-bounding-box-location", "inVars": ["ScreenShot.jpg", "ChatArea.png"], "outVars": ["{corners}"] }
+```
+
+- **img-cropping**
+```json
+{ "type": "img-cropping", "inVars": ["{areaJson}", "history/crop.png"], "outVars": [] }
 ```
 
-## 变量
-
-- 定义:`"variables": {"name": "value"}`
-- 使用:`"{name}"` 在字段中引用
-- 保存:`"outVars": ["{name}"]` 或 `"variable": "{name}"`
-- 类型:支持三种数据类型:
-  - **`number`**:数值类型(整数或小数),例如:`1`、`3.14`、`-5.2`
-  - **`string`**:字符串类型,例如:`"hello"`、`""`
-  - **`bool`**:布尔类型,只能是 `true` 或 `false`(不是字符串)
-
-### 变量类型说明
-- 变量的类型由其初始值自动推断:
-  - 如果初始值是数字(如 `1`、`3.14`),类型为 `number`
-  - 如果初始值是字符串(如 `"text"`、`""`),类型为 `string`
-  - 如果初始值是布尔值(如 `true`、`false`),类型为 `bool`
-- 示例:
-  ```json
-  {
-    "variables": {
-      "count": 0,           // number 类型
-      "message": "",        // string 类型
-      "isReady": false      // bool 类型
-    }
-  }
-  ```
-
-## 时间格式
-
-- 间隔:`"1s"`, `"2m"`, `"3h"`
-- 日期:`"2026/1/14 01:21"`
-- 时间:`"09:00"`
-
-## 扩展标签
-
-扩展标签由 `src/pages/processing/func/` 目录下的脚本文件决定,每个脚本文件名即为标签名。
-
-常用标签:
-- `ocr-chat`: OCR识别对话内容
-  - `inVars`: `[好友RGB颜色, 我的RGB颜色, 区域坐标]`(RGB格式:`"(r,g,b)"`,区域坐标:JSON字符串)
-  - `outVars`: `[聊天记录变量]`(输出 chat-history.txt 格式的JSON字符串)
-- `read-last-message`: 读取最后一条消息(输出文本和发送者角色)
-- `smart-chat-append`: 智能合并历史聊天记录和当前聊天记录,自动检测并去除连续重合部分后返回新的聊天记录字符串
-  - `inVars`: `[历史记录, 当前记录]`
-  - `outVars`: `[合并后的记录]`
-- `read-txt`: 读取文本文件内容
-  - `inVars`: `[文件路径]`(相对于工作流目录,如 `"history/chat-history.txt"`)
-  - `outVars`: `[文件内容变量]`
-- `save-txt`: 保存字符串为文本文件
-  - `inVars`: `[内容, 文件路径]`(路径相对于工作流目录)
-  - `outVars`: `[]`
-- `img-center-point-location`: 图像中心点定位
-  - `inVars`: `[模板图片路径]`(相对于工作流目录的 resources 文件夹)
-  - `outVars`: `[位置坐标变量]`(输出JSON字符串格式:`{"x":123,"y":456}`)
-- `img-bounding-box-location`: 图像区域定位(在完整截图中查找区域图片的位置)
-  - `inVars`: `[截图路径, 区域图片路径]`(都相对于工作流目录的 resources 文件夹,如 `"ScreenShot.jpg"` 和 `"ChatArea.png"`)
-  - `outVars`: `[区域坐标变量]`(返回四个顶点坐标:`{topLeft: {x, y}, topRight: {x, y}, bottomLeft: {x, y}, bottomRight: {x, y}}`)
-  - 注意:此标签**不主动截图**,使用 `resources/` 文件夹下已有的截图文件进行匹配
-- `img-cropping`: 图像区域裁剪(从当前屏幕截图裁剪指定区域)
-  - `inVars`: `[区域坐标, 保存路径]`(区域坐标:JSON字符串格式,保存路径相对于工作流目录的 history 文件夹)
-  - `outVars`: `[]`
-  - 功能:从主进程缓存获取最新截图,保存到 `history/ScreenShot.jpg`,然后根据区域坐标裁剪并保存到指定路径
+- **ai-generate**
+```json
+{ "type": "ai-generate", "prompt": "请总结:{{input}}", "inVars": ["{input}"], "outVars": ["{result}"] }
+```
+
+- **string-press**
+```json
+{ "type": "string-press", "inVars": ["确定"], "outVars": [] }
+```
+
+---
+
+
+
+

+ 0 - 0
doc/创建类的流程.md → doc/项目架构使用说明/创建类的流程.md


+ 16 - 0
doc/项目架构使用说明/将页面设置为子页面.md

@@ -0,0 +1,16 @@
+# 将页面设置为子页面(条件渲染)
+
+**步骤:**
+
+**1. 修改 `src/pages/Home.jsx`**:
+   - 添加:`import Devices from './Devices/Devices';`
+   - 在 `HomeLogic()` 中获取:`const { showDevices, setShowDevices } = HomeLogic();`
+   - 在 return 中添加:`{showDevices && <Devices />}` 和按钮控制显示/隐藏
+
+**2. 修改 `src/pages/Home.js`**:
+   - 添加:`import { useState } from 'react';`
+   - 在 `HomeLogic` 中添加:`const [showDevices, setShowDevices] = useState(false);`
+   - return 中暴露:`showDevices, setShowDevices`
+
+**3. 修改 `src/App.jsx`**:
+   - 删除 Devices 的 import 和组件使用