ms-vite-plugin 1.4.57 → 1.4.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/docs/AGENTS.md CHANGED
@@ -13,7 +13,7 @@
13
13
  - Lua 项目使用 Lua 文档与写法。
14
14
  - 不要混用 JavaScript、Python 与 Lua API。
15
15
  - Lua 只提供英文方法,没有中文别名。
16
- - Lua 模块通过 `require("device")` 加载;`Sleep`、`StartThread` 等是裸全局。
16
+ - Lua 模块通过 `require("device")` 加载;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
17
17
  - 不要把快点JS Python 脚本当成普通 CPython 脚本。
18
18
  - 不要对快点JS Python 脚本运行 `python -m py_compile`、`py_compile` 或类似 CPython 编译校验。
19
19
  - 不要创建、保留或同步 `__pycache__`、`.pyc` 作为项目改动。
package/docs/SKILL.md CHANGED
@@ -20,7 +20,7 @@ description: 快点JS专用开发助手。用于快点JS项目开发、本地 AP
20
20
  - Lua 项目使用 Lua 文档与写法。
21
21
  - 不要混用 JavaScript、Python 与 Lua API。
22
22
  - Lua 只提供英文方法,没有中文别名。
23
- - Lua 模块通过 `require("device")` 加载;`Sleep`、`StartThread` 等是裸全局。
23
+ - Lua 模块通过 `require("device")` 加载;`Sleep`、`StartThread`、`logd` / `logi` / `logw` / `loge` 等是裸全局。
24
24
  - Lua 用户模块请用 `require("foo")` / `require("lib.bar")`。Release 打包默认会把 `scripts` 下除 `main.lua` 外的用户 `.lua` 合并进单个 `main.lua`;不要用 `dofile` / `loadfile` 按路径加载这些文件。
25
25
  - 文档未确认的能力必须明确说明无法确认,并给出保守方案。
26
26
  - 快点JS Python 脚本不使用 CPython 编译校验;不要运行 `python -m py_compile`、`py_compile` 或类似命令。
package/docs/api/media.md CHANGED
@@ -245,3 +245,25 @@ if (played) {
245
245
  logi("播放失败或被系统音频中断");
246
246
  }
247
247
  ```
248
+
249
+ #### isMp3Playing - 当前是否正在播放 MP3。
250
+
251
+ ```typescript
252
+ function isMp3Playing(): boolean;
253
+ ```
254
+
255
+ **返回值:**
256
+
257
+ | 类型 | 描述 |
258
+ | --------- | -------------------------------- |
259
+ | `boolean` | 正在播放返回 `true`,否则 `false` |
260
+
261
+ **示例:**
262
+
263
+ ```javascript
264
+ if (media.isMp3Playing()) {
265
+ logi("正在播放");
266
+ } else {
267
+ logi("未播放");
268
+ }
269
+ ```
@@ -249,3 +249,25 @@ if (是否播放成功) {
249
249
  $打印错误日志("播放失败或被系统音频中断");
250
250
  }
251
251
  ```
252
+
253
+ #### 查询MP3音乐是否正在播放 - 当前是否正在播放 MP3。
254
+
255
+ ```typescript
256
+ function 查询MP3音乐是否正在播放(): 布尔值;
257
+ ```
258
+
259
+ **返回值:**
260
+
261
+ | 类型 | 描述 |
262
+ | -------- | ---------------------------------- |
263
+ | `布尔值` | 正在播放返回 `true`,否则 `false` |
264
+
265
+ **示例:**
266
+
267
+ ```javascript
268
+ if ($媒体.查询MP3音乐是否正在播放()) {
269
+ $打印信息日志("正在播放");
270
+ } else {
271
+ $打印信息日志("未播放");
272
+ }
273
+ ```
@@ -59,9 +59,10 @@ AppleOCR 模块基于 Apple Vision 框架,提供原生的光学字符识别(
59
59
 
60
60
  ### 文字识别
61
61
 
62
- #### recognize - 执行 OCR 识别。
62
+ #### recognizeAbs - 执行 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标。
63
63
 
64
- 执行 OCR 识别。传入裁剪区域时,返回坐标相对于裁剪区域。全屏识别时 `x/y/ex/ey` 传 `0`。
64
+ 执行 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标。
65
+ 传入裁剪区域时,返回坐标会映射回原图或全屏坐标,可直接用于点击。
65
66
 
66
67
  ```lua
67
68
  ---@param input string
@@ -71,7 +72,7 @@ AppleOCR 模块基于 Apple Vision 框架,提供原生的光学字符识别(
71
72
  ---@param ey number?
72
73
  ---@param languages string[]?
73
74
  ---@return OCRResult[]
74
- function recognize(input, x, y, ex, ey, languages) end
75
+ function recognizeAbs(input, x, y, ex, ey, languages) end
75
76
  ```
76
77
 
77
78
  **参数:**
@@ -87,38 +88,9 @@ function recognize(input, x, y, ex, ey, languages) end
87
88
 
88
89
  **返回值:**
89
90
 
90
- | 类型 | 描述 |
91
- | ------------- | ---------------------------------------------- |
92
- | `OCRResult[]` | 识别结果数组,坐标相对于裁剪区域 |
93
-
94
- **示例:**
95
-
96
- ```lua
97
- local appleocr = require("appleocr")
98
- local action = require("action")
99
-
100
- local results = appleocr.recognize("screen", 100, 100, 500, 300)
101
- if #results > 0 then
102
- action.click(results[1].centerX, results[1].centerY)
103
- end
104
- ```
105
-
106
- #### recognizeAbs - 执行 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标。
107
-
108
- 传入裁剪区域时,返回坐标会映射回原图或全屏坐标,可直接用于点击。
109
-
110
- ```lua
111
- ---@param input string
112
- ---@param x number?
113
- ---@param y number?
114
- ---@param ex number?
115
- ---@param ey number?
116
- ---@param languages string[]?
117
- ---@return OCRResult[]
118
- function recognizeAbs(input, x, y, ex, ey, languages) end
119
- ```
120
-
121
- **参数:** 与 `recognize` 相同;返回坐标为原图或全屏绝对坐标。
91
+ | 类型 | 描述 |
92
+ | ------------- | -------------------------------------- |
93
+ | `OCRResult[]` | 识别结果数组,坐标为原图或全屏绝对坐标 |
122
94
 
123
95
  **示例:**
124
96
 
@@ -133,9 +105,10 @@ end
133
105
 
134
106
  ### 数字识别
135
107
 
136
- #### recognizeNumbers - 执行数字 OCR 识别。
108
+ #### recognizeNumbersAbs - 执行数字 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标。
137
109
 
138
- 执行数字 OCR 识别。传入裁剪区域时,返回坐标相对于裁剪区域。
110
+ 执行数字 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标。
111
+ 传入裁剪区域时,返回坐标会映射回原图或全屏坐标,可直接用于点击。
139
112
 
140
113
  **支持字符**: 0-9 数字、逗号(,)、小数点(.)、加号(+)、减号(-)
141
114
 
@@ -146,69 +119,46 @@ end
146
119
  ---@param ex number?
147
120
  ---@param ey number?
148
121
  ---@return OCRResult[]
149
- function recognizeNumbers(input, x, y, ex, ey) end
122
+ function recognizeNumbersAbs(input, x, y, ex, ey) end
150
123
  ```
151
124
 
152
125
  **参数:**
153
126
 
154
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
155
- | ------- | ------ | -------- | ------ | --------------------------------------------------- |
127
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
128
+ | ------- | ------ | -------- | ------ | ----------------------------------------------------------- |
156
129
  | `input` | string | 是 | | 输入源,支持 `"screen"`、图片文件路径、URL 字符串或 imageId |
157
- | `x` | number | 否 | 0 | 裁剪区域左上角 x 坐标;全屏识别传 0 |
158
- | `y` | number | 否 | 0 | 裁剪区域左上角 y 坐标;全屏识别传 0 |
159
- | `ex` | number | 否 | 0 | 裁剪区域右下角 x 坐标;全屏识别传 0 |
160
- | `ey` | number | 否 | 0 | 裁剪区域右下角 y 坐标;全屏识别传 0 |
130
+ | `x` | number | 否 | 0 | 裁剪区域左上角 x 坐标;全屏识别传 0 |
131
+ | `y` | number | 否 | 0 | 裁剪区域左上角 y 坐标;全屏识别传 0 |
132
+ | `ex` | number | 否 | 0 | 裁剪区域右下角 x 坐标;全屏识别传 0 |
133
+ | `ey` | number | 否 | 0 | 裁剪区域右下角 y 坐标;全屏识别传 0 |
161
134
 
162
135
  **返回值:**
163
136
 
164
137
  | 类型 | 描述 |
165
138
  | ------------- | ---------------------------------------------- |
166
- | `OCRResult[]` | 数字识别结果数组,坐标相对于裁剪区域 |
139
+ | `OCRResult[]` | 数字识别结果数组,坐标为原图或全屏绝对坐标 |
167
140
 
168
141
  **示例:**
169
142
 
170
143
  ```lua
171
144
  local appleocr = require("appleocr")
172
145
  local action = require("action")
173
-
174
- local numberResults = appleocr.recognizeNumbers("screen", 100, 100, 500, 300)
175
- if #numberResults > 0 then
176
- action.click(numberResults[1].centerX, numberResults[1].centerY)
177
- end
178
- ```
179
-
180
- #### recognizeNumbersAbs - 执行数字 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标。
181
-
182
- **支持字符**: 0-9 数字、逗号(,)、小数点(.)、加号(+)、减号(-)
183
-
184
- ```lua
185
- ---@param input string
186
- ---@param x number?
187
- ---@param y number?
188
- ---@param ex number?
189
- ---@param ey number?
190
- ---@return OCRResult[]
191
- function recognizeNumbersAbs(input, x, y, ex, ey) end
192
- ```
193
-
194
- **参数:** 与 `recognizeNumbers` 相同;返回坐标为原图或全屏绝对坐标。
195
-
196
- **示例:**
197
-
198
- ```lua
199
- local appleocr = require("appleocr")
200
146
  local absNumberResults = appleocr.recognizeNumbersAbs("screen", 100, 100, 500, 300)
147
+ if #absNumberResults > 0 then
148
+ action.click(absNumberResults[1].centerX, absNumberResults[1].centerY)
149
+ end
201
150
  ```
202
151
 
203
152
  ### 文本查找
204
153
 
205
- #### findText - 查找目标子串。
154
+ #### findTextAbs - 查找目标子串,并将子串结果坐标映射为原图/全屏绝对坐标。
206
155
 
207
- 在整段识别文本中查找指定子串。传入裁剪区域时,返回坐标相对于裁剪区域。
156
+ 查找目标子串,并将子串结果坐标映射为原图/全屏绝对坐标。
157
+ 传入裁剪区域时,返回坐标会映射回原图或全屏坐标,可直接用于点击。`texts` 也可以是逗号分隔字符串。
208
158
 
209
159
  ```lua
210
160
  ---@param input string
211
- ---@param texts string[]
161
+ ---@param texts string[]|string
212
162
  ---@param x number?
213
163
  ---@param y number?
214
164
  ---@param ex number?
@@ -216,58 +166,27 @@ local absNumberResults = appleocr.recognizeNumbersAbs("screen", 100, 100, 500, 3
216
166
  ---@param languages string[]?
217
167
  ---@param exactMatch boolean?
218
168
  ---@return OCRResult[]
219
- function findText(input, texts, x, y, ex, ey, languages, exactMatch) end
169
+ function findTextAbs(input, texts, x, y, ex, ey, languages, exactMatch) end
220
170
  ```
221
171
 
222
172
  **参数:**
223
173
 
224
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
225
- | ------------ | -------- | -------- | ----------------------- | ----------------------------------------------------------------------------------------------------- |
226
- | `input` | string | 是 | | 输入源,支持 `"screen"`、图片文件路径、URL 字符串或 imageId |
227
- | `texts` | string[] | 是 | | 要查找的目标文本数组,可匹配识别结果中的子串 |
228
- | `x` | number | 否 | 0 | 裁剪区域左上角 x 坐标;全屏识别传 0 |
229
- | `y` | number | 否 | 0 | 裁剪区域左上角 y 坐标;全屏识别传 0 |
230
- | `ex` | number | 否 | 0 | 裁剪区域右下角 x 坐标;全屏识别传 0 |
231
- | `ey` | number | 否 | 0 | 裁剪区域右下角 y 坐标;全屏识别传 0 |
232
- | `languages` | string[] | 否 | `{"zh-Hans", "en-US"}` | 识别语言数组 |
233
- | `exactMatch` | boolean | 否 | false | 是否完整匹配;`false` 表示包含匹配,`true` 要求整条 OCR 识别结果文本等于目标文本 |
174
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
175
+ | ------------ | ------------------ | -------- | ----------------------- | ----------------------------------------------------------------------------------------------------- |
176
+ | `input` | string | 是 | | 输入源,支持 `"screen"`、图片文件路径、URL 字符串或 imageId |
177
+ | `texts` | string[] \| string | 是 | | 要查找的目标文本数组,可匹配识别结果中的子串;也可以是逗号分隔字符串 |
178
+ | `x` | number | 否 | 0 | 裁剪区域左上角 x 坐标;全屏识别传 0 |
179
+ | `y` | number | 否 | 0 | 裁剪区域左上角 y 坐标;全屏识别传 0 |
180
+ | `ex` | number | 否 | 0 | 裁剪区域右下角 x 坐标;全屏识别传 0 |
181
+ | `ey` | number | 否 | 0 | 裁剪区域右下角 y 坐标;全屏识别传 0 |
182
+ | `languages` | string[] | 否 | `{"zh-Hans", "en-US"}` | 识别语言数组 |
183
+ | `exactMatch` | boolean | 否 | false | 是否完整匹配;`false` 表示包含匹配,`true` 要求整条 OCR 识别结果文本等于目标文本 |
234
184
 
235
185
  **返回值:**
236
186
 
237
- | 类型 | 描述 |
238
- | ------------- | ---------------------------------------------- |
239
- | `OCRResult[]` | 命中子串的识别结果数组,坐标相对于裁剪区域 |
240
-
241
- **示例:**
242
-
243
- ```lua
244
- local appleocr = require("appleocr")
245
- local action = require("action")
246
-
247
- local hits = appleocr.findText("screen", { "开始" }, 100, 100, 500, 400)
248
- if #hits > 0 then
249
- action.click(hits[1].centerX, hits[1].centerY)
250
- end
251
- ```
252
-
253
- #### findTextAbs - 查找目标子串,并将子串结果坐标映射为原图/全屏绝对坐标。
254
-
255
- 传入裁剪区域时,返回坐标会映射回原图或全屏坐标,可直接用于点击。`texts` 也可以是逗号分隔字符串。
256
-
257
- ```lua
258
- ---@param input string
259
- ---@param texts string[]|string
260
- ---@param x number?
261
- ---@param y number?
262
- ---@param ex number?
263
- ---@param ey number?
264
- ---@param languages string[]?
265
- ---@param exactMatch boolean?
266
- ---@return OCRResult[]
267
- function findTextAbs(input, texts, x, y, ex, ey, languages, exactMatch) end
268
- ```
269
-
270
- **参数:** 与 `findText` 相同;返回坐标为原图或全屏绝对坐标。
187
+ | 类型 | 描述 |
188
+ | ------------- | -------------------------------------------------- |
189
+ | `OCRResult[]` | 命中子串的识别结果数组,坐标为原图或全屏绝对坐标 |
271
190
 
272
191
  **示例:**
273
192
 
@@ -18,6 +18,7 @@
18
18
  - **时间工具**: 获取时间戳
19
19
  - **应用控制**: 切换应用到前台
20
20
  - **Agent 设置**: 读取和设置 Agent 触控模式
21
+ - **日志输出**: 全局 `logd` / `logi` / `logw` / `loge`,等同 `logger` 对应方法
21
22
 
22
23
  ## 全局常量
23
24
 
@@ -652,3 +653,97 @@ function ToJsonString(data) end
652
653
  print(ToJsonString({ a = 1, b = 2 }))
653
654
  ```
654
655
 
656
+ ## 全局日志函数
657
+
658
+ 全局日志函数是 `logger` 模块对应方法的便捷别名,可以直接调用而无需 `require("logger")`。可变参会按空格拼接为一行。级别和是否写文件仍由 `logger.setLoggerLevel` / `logger.setLogToFile` 控制。
659
+
660
+ `print` 仍可用,默认走信息级别;需要调试 / 警告 / 错误级别时用下面这些函数。
661
+
662
+ ### logd
663
+
664
+ 输出调试级别的日志,等同于 `logger.debug(...)`。
665
+
666
+ ```lua
667
+ ---@param ... any
668
+ function logd(...) end
669
+ ```
670
+
671
+ **参数:**
672
+
673
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
674
+ | ------ | ---- | -------- | ------ | ---------------- |
675
+ | `...` | any | 是 | - | 要输出的日志内容 |
676
+
677
+ **示例:**
678
+
679
+ ```lua
680
+ logd("程序开始执行")
681
+ logd("当前用户:", username)
682
+ ```
683
+
684
+ ### logi
685
+
686
+ 输出信息级别的日志,等同于 `logger.info(...)`。
687
+
688
+ ```lua
689
+ ---@param ... any
690
+ function logi(...) end
691
+ ```
692
+
693
+ **参数:**
694
+
695
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
696
+ | ------ | ---- | -------- | ------ | ---------------- |
697
+ | `...` | any | 是 | - | 要输出的日志内容 |
698
+
699
+ **示例:**
700
+
701
+ ```lua
702
+ logi("应用程序启动成功")
703
+ logi("处理了", count, "条记录")
704
+ ```
705
+
706
+ ### logw
707
+
708
+ 输出警告级别的日志,等同于 `logger.warn(...)`。
709
+
710
+ ```lua
711
+ ---@param ... any
712
+ function logw(...) end
713
+ ```
714
+
715
+ **参数:**
716
+
717
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
718
+ | ------ | ---- | -------- | ------ | ---------------- |
719
+ | `...` | any | 是 | - | 要输出的日志内容 |
720
+
721
+ **示例:**
722
+
723
+ ```lua
724
+ logw("电池电量低于 20%")
725
+ logw("网络连接不稳定")
726
+ ```
727
+
728
+ ### loge
729
+
730
+ 输出错误级别的日志,等同于 `logger.error(...)`。
731
+
732
+ ```lua
733
+ ---@param ... any
734
+ function loge(...) end
735
+ ```
736
+
737
+ **参数:**
738
+
739
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
740
+ | ------ | ---- | -------- | ------ | ---------------- |
741
+ | `...` | any | 是 | - | 要输出的日志内容 |
742
+
743
+ **示例:**
744
+
745
+ ```lua
746
+ loge("网络请求失败")
747
+ loge("文件读取错误")
748
+ ```
749
+
@@ -18,8 +18,6 @@
18
18
 
19
19
  ### captureScreen - 截取屏幕。
20
20
 
21
- 坐标缺省 `0` 表示全屏。四个坐标都传 `0` 时与 `captureFullScreen` 相同。
22
-
23
21
  ```lua
24
22
  ---@param x number?
25
23
  ---@param y number?
@@ -66,77 +64,6 @@ if rectId then
66
64
  end
67
65
  ```
68
66
 
69
- ### captureFullScreen - 截取全屏。
70
-
71
- ```lua
72
- ---@return string|nil
73
- function captureFullScreen() end
74
- ```
75
-
76
- **返回值:**
77
-
78
- | 类型 | 描述 |
79
- | --------------- | -------------------------------- |
80
- | `string \| nil` | 截图的图片 ID,失败时返回 `nil` |
81
-
82
- **示例:**
83
-
84
- ```lua
85
- local image = require("image")
86
- local file = require("file")
87
- local imageId = image.captureFullScreen()
88
- local dir = file.getInternalDir("documents")
89
- if imageId then
90
- print("截图成功")
91
- image.saveTo(imageId, dir .. "/screenshot.jpg")
92
- image.release(imageId)
93
- else
94
- print("截图失败")
95
- end
96
- ```
97
-
98
- ### captureRect - 截取指定区域。
99
-
100
- ```lua
101
- ---@param x number?
102
- ---@param y number?
103
- ---@param ex number?
104
- ---@param ey number?
105
- ---@return string|nil
106
- function captureRect(x, y, ex, ey) end
107
- ```
108
-
109
- **参数:**
110
-
111
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
112
- | ------ | ------ | -------- | ------ | ----------------- |
113
- | `x` | number | 否 | 0 | 区域左上角 X 坐标 |
114
- | `y` | number | 否 | 0 | 区域左上角 Y 坐标 |
115
- | `ex` | number | 否 | 0 | 区域右下角 X 坐标 |
116
- | `ey` | number | 否 | 0 | 区域右下角 Y 坐标 |
117
-
118
- **返回值:**
119
-
120
- | 类型 | 描述 |
121
- | --------------- | -------------------------------- |
122
- | `string \| nil` | 截图的图片 ID,失败时返回 `nil` |
123
-
124
- **示例:**
125
-
126
- ```lua
127
- local image = require("image")
128
- local file = require("file")
129
- local imageId = image.captureRect(100, 100, 200, 200)
130
- local dir = file.getInternalDir("documents")
131
- if imageId then
132
- print("截图成功")
133
- image.saveTo(imageId, dir .. "/screenshot.jpg")
134
- image.release(imageId)
135
- else
136
- print("截图失败")
137
- end
138
- ```
139
-
140
67
  ### readImage - 从文件路径或imageId读取图片。
141
68
 
142
69
  ```lua
@@ -197,7 +124,7 @@ function saveTo(imageId, filePath) end
197
124
 
198
125
  ```lua
199
126
  local image = require("image")
200
- local imageId = image.captureFullScreen()
127
+ local imageId = image.captureScreen()
201
128
  -- 获取手机文档目录
202
129
  local dir = file.getInternalDir("documents")
203
130
  if imageId then
@@ -251,7 +178,7 @@ function isRelease(imageId) end
251
178
 
252
179
  ```lua
253
180
  local image = require("image")
254
- local imageId = image.captureFullScreen()
181
+ local imageId = image.captureScreen()
255
182
  if imageId then
256
183
  print("释放前: " .. tostring(image.isRelease(imageId))); -- false
257
184
  image.release(imageId)
@@ -285,7 +212,7 @@ function getSize(imageId) end
285
212
 
286
213
  ```lua
287
214
  local image = require("image")
288
- local imageId = image.captureFullScreen()
215
+ local imageId = image.captureScreen()
289
216
  if imageId then
290
217
  local size = image.getSize(imageId)
291
218
  if size then
@@ -323,7 +250,7 @@ function pixel(imageId, x, y) end
323
250
 
324
251
  ```lua
325
252
  local image = require("image")
326
- local imageId = image.captureFullScreen()
253
+ local imageId = image.captureScreen()
327
254
  if imageId then
328
255
  local color = image.pixel(imageId, 100, 100)
329
256
  local colorHex = image.argb(color)
@@ -392,7 +319,7 @@ function findColor(imageId, color, threshold, x, y, ex, ey, limit, orz) end
392
319
 
393
320
  ```lua
394
321
  local image = require("image")
395
- local imageId = image.captureFullScreen()
322
+ local imageId = image.captureScreen()
396
323
  if imageId then
397
324
  -- 查找蓝色按钮
398
325
  local points = image.findColor(
@@ -457,7 +384,7 @@ function findMultiColor(imageId, firstColor, threshold, points, x, y, ex, ey, li
457
384
 
458
385
  ```lua
459
386
  local image = require("image")
460
- local imageId = image.captureFullScreen()
387
+ local imageId = image.captureScreen()
461
388
  if imageId then
462
389
  -- 查找特定的颜色组合(如按钮的特征颜色)
463
390
  local points = image.findMultiColor(
@@ -518,7 +445,7 @@ function countColor(imageId, colors, threshold, x, y, ex, ey) end
518
445
 
519
446
  ```lua
520
447
  local image = require("image")
521
- local imageId = image.captureFullScreen()
448
+ local imageId = image.captureScreen()
522
449
  if imageId then
523
450
  local count = image.countColor(
524
451
  imageId,
@@ -563,7 +490,7 @@ function cmpColor(imageId, points, threshold) end
563
490
 
564
491
  ```lua
565
492
  local image = require("image")
566
- local imageId = image.captureFullScreen()
493
+ local imageId = image.captureScreen()
567
494
  if imageId then
568
495
  -- 检查特定区域是否为预期颜色
569
496
  local isMatch = image.cmpColor(
@@ -919,7 +846,7 @@ function clip(imageId, x, y, ex, ey) end
919
846
 
920
847
  ```lua
921
848
  local image = require("image")
922
- local imageId = image.captureFullScreen()
849
+ local imageId = image.captureScreen()
923
850
  -- 获取手机文档目录
924
851
  local dir = file.getInternalDir("documents")
925
852
  if imageId then
@@ -999,7 +926,7 @@ function gray(imageId) end
999
926
 
1000
927
  ```lua
1001
928
  local image = require("image")
1002
- local imageId = image.captureFullScreen()
929
+ local imageId = image.captureScreen()
1003
930
  -- 获取手机文档目录
1004
931
  local dir = file.getInternalDir("documents")
1005
932
  if imageId then
@@ -1036,7 +963,7 @@ function binaryzation(imageId, threshold) end
1036
963
 
1037
964
  ```lua
1038
965
  local image = require("image")
1039
- local imageId = image.captureFullScreen()
966
+ local imageId = image.captureScreen()
1040
967
  -- 获取手机文档目录
1041
968
  local dir = file.getInternalDir("documents")
1042
969
  if imageId then
@@ -1077,7 +1004,7 @@ local image = require("image")
1077
1004
  -- 获取手机文档目录
1078
1005
  local dir = file.getInternalDir("documents")
1079
1006
 
1080
- local imageId = image.captureFullScreen()
1007
+ local imageId = image.captureScreen()
1081
1008
  if imageId then
1082
1009
  image.drawRect(imageId, 100, 100, 200, 100, "#FF0000", 2)
1083
1010
  image.saveTo(imageId, tostring(dir) .. "/test.jpg")
@@ -1109,7 +1036,7 @@ function scanCode(imageId) end
1109
1036
 
1110
1037
  ```lua
1111
1038
  local image = require("image")
1112
- local imageId = image.captureFullScreen()
1039
+ local imageId = image.captureScreen()
1113
1040
  if imageId then
1114
1041
  local result = image.scanCode(imageId)
1115
1042
  if result then
@@ -1186,7 +1113,7 @@ function toBase64Format(imageId, format, q) end
1186
1113
 
1187
1114
  ```lua
1188
1115
  local image = require("image")
1189
- local imageId = image.captureFullScreen()
1116
+ local imageId = image.captureScreen()
1190
1117
  if imageId then
1191
1118
  local base64 = image.toBase64Format(imageId, "jpg", 90)
1192
1119
  print("Base64 数据: " .. tostring(base64.substring(0, 100)) .. "...")
@@ -14,6 +14,8 @@
14
14
 
15
15
  - **关闭存储日志** 可使用 `setLogToFile(false)` 关闭将日志输出到文件的功能。
16
16
 
17
+ - **全局别名** `logd` / `logi` / `logw` / `loge` 是裸全局,分别等同 `logger.debug` / `logger.info` / `logger.warn` / `logger.error`,无需 `require("logger")`。
18
+
17
19
  ## 日志级别
18
20
 
19
21
  日志模块支持以下级别(按严重程度排序):
@@ -148,7 +148,7 @@ local image = require("image")
148
148
  local a = cv.imread("template.png")
149
149
  local dir = file.getInternalDir("documents")
150
150
  local b = cv.imread(dir .. "/shot.jpg")
151
- local imageId = image.captureFullScreen()
151
+ local imageId = image.captureScreen()
152
152
  local c = cv.imread(imageId)
153
153
  image.release(imageId)
154
154
  cv.release(a)
@@ -261,7 +261,7 @@ function fromImageId(imageId) end
261
261
 
262
262
  ```lua
263
263
  local cv = require("cv")
264
- local imageId = image.captureFullScreen()
264
+ local imageId = image.captureScreen()
265
265
  local mat = cv.fromImageId(imageId)
266
266
  image.release(imageId)
267
267
  local outId = cv.toImageId(mat)
@@ -501,7 +501,7 @@ local half = cv.resize(src, { fx = 0.5, fy = 0.5, interpolation = cv.INTER_AREA
501
501
  function crop(mat, options) end
502
502
  ```
503
503
 
504
- 参数与 `cv.capture` / `image.captureFullScreen` 一致,使用左上角与右下角。
504
+ 参数与 `cv.capture` / `image.captureScreen` 一致,使用左上角与右下角。
505
505
 
506
506
  参数为 `{ x, y, ex, ey }`。
507
507
 
@@ -4,8 +4,9 @@ PaddleOCR 模块基于百度飞桨 PaddleOCR 技术,提供强大的光学字
4
4
 
5
5
  ## 功能概览
6
6
 
7
- - **自动加载**: 识别方法会自动加载所需模型,无需先手动加载
8
- - **PP-OCRv5**: 可通过 `loadV5` 手动加载 PP-OCRv5 模型
7
+ - **自动加载**: 识别和查找方法会自动加载所需模型,无需先手动加载
8
+ - **模型选择**: 同一时间只保留一个 active 模型,默认 `ppocr-v6-small`,可通过模型 ID 手动加载 `ppocr-v6-tiny` `ppocr-v5`
9
+ - **长边设置**: 可单独调整检测阶段最大边长,不需要重新加载已加载模型
9
10
  - **多源识别**: 支持屏幕截图、图片文件、URL 等多种输入源
10
11
  - **区域识别**: 支持指定区域的精确文字识别
11
12
  - **结构化结果**: 提供详细的文本位置、置信度和方向信息
@@ -49,40 +50,6 @@ PaddleOCR 模块基于百度飞桨 PaddleOCR 技术,提供强大的光学字
49
50
 
50
51
  ### 模型管理
51
52
 
52
- #### loadV5 - 手动加载 PP-OCRv5 模型。
53
-
54
- 识别方法默认自动加载模型。只有需要切换到 PP-OCRv5 或指定 GPU 参数时才调用 `loadV5`。PaddleOCR 同一时间只保留一个 active 模型,`loadV5` 加载成功后会替换已加载模型。
55
-
56
- ```lua
57
- ---@param maxSideLen number?
58
- ---@param useGpu boolean?
59
- ---@return boolean
60
- function loadV5(maxSideLen, useGpu) end
61
- ```
62
-
63
- **参数:**
64
-
65
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
66
- | ------------ | ------- | -------- | ------ | ---------------------------- |
67
- | `maxSideLen` | number | 否 | 640 | 检测阶段输入最大边长 |
68
- | `useGpu` | boolean | 否 | false | 是否启用 GPU 加速 |
69
-
70
- **返回值:**
71
-
72
- | 类型 | 描述 |
73
- | ------- | ----------------------------------------------------------- |
74
- | boolean | 加载成功或模型已加载返回 `true`,失败返回 `false` |
75
-
76
- **示例:**
77
-
78
- ```lua
79
- local paddleocr = require("paddleocr")
80
-
81
- -- 手动加载 PP-OCRv5 模型
82
- local loaded = paddleocr.loadV5(640, false)
83
- print("PP-OCRv5 加载结果: " .. tostring(loaded))
84
- ```
85
-
86
53
  #### loadModel - 按模型 ID 手动加载内置 PaddleOCR 模型。
87
54
 
88
55
  识别和查找方法默认自动加载 `ppocr-v6-small`。只有需要切换模型或指定 GPU 参数时才调用 `loadModel`。同一时间只保留一个 active 模型;检测长边请使用 `setMaxSideLen`。
@@ -147,50 +114,6 @@ paddleocr.setMaxSideLen(960)
147
114
 
148
115
  ### 文字识别
149
116
 
150
- #### recognize - 执行 OCR 识别。
151
-
152
- 传入裁剪区域时,返回坐标相对于裁剪区域。全屏识别时 `x/y/ex/ey` 传 `0`。
153
-
154
- ```lua
155
- ---@param input string
156
- ---@param x number?
157
- ---@param y number?
158
- ---@param ex number?
159
- ---@param ey number?
160
- ---@param confidenceThreshold number?
161
- ---@return OCRResult[]
162
- function recognize(input, x, y, ex, ey, confidenceThreshold) end
163
- ```
164
-
165
- **参数:**
166
-
167
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
168
- | --------------------- | ------ | -------- | ------ | ----------------------------------------------------------- |
169
- | `input` | string | 是 | | 输入源,支持 imageId、URL 字符串、文件路径或 `"screen"` |
170
- | `x` | number | 否 | 0 | 裁剪区域左上角 x 坐标;全屏识别传 0 |
171
- | `y` | number | 否 | 0 | 裁剪区域左上角 y 坐标;全屏识别传 0 |
172
- | `ex` | number | 否 | 0 | 裁剪区域右下角 x 坐标;全屏识别传 0 |
173
- | `ey` | number | 否 | 0 | 裁剪区域右下角 y 坐标;全屏识别传 0 |
174
- | `confidenceThreshold` | number | 否 | 0.6 | 置信度阈值,低于该值的识别结果会被过滤 |
175
-
176
- **返回值:**
177
-
178
- | 类型 | 描述 |
179
- | ------------- | ---------------------------------- |
180
- | `OCRResult[]` | 识别结果数组,坐标相对于裁剪区域 |
181
-
182
- **示例:**
183
-
184
- ```lua
185
- local paddleocr = require("paddleocr")
186
- local action = require("action")
187
-
188
- local results = paddleocr.recognize("screen", 100, 100, 500, 300)
189
- if #results > 0 then
190
- action.click(results[1].centerX, results[1].centerY)
191
- end
192
- ```
193
-
194
117
  #### recognizeAbs - 执行 OCR 识别,并将结果坐标映射为原图/全屏绝对坐标。
195
118
 
196
119
  传入裁剪区域时,返回坐标会映射回原图或全屏坐标,可直接用于点击。
@@ -234,9 +157,9 @@ if #absResults > 0 then
234
157
  end
235
158
  ```
236
159
 
237
- #### findText - 查找目标文本。
160
+ #### findTextAbs - 查找目标文本,并将结果坐标映射为原图/全屏绝对坐标。
238
161
 
239
- 传入裁剪区域时,返回坐标相对于裁剪区域。`targets` 可以是字符串数组或逗号分隔字符串。
162
+ 传入裁剪区域时,返回坐标会映射回原图或全屏坐标,可直接用于点击。`targets` 也可以是逗号分隔字符串。
240
163
 
241
164
  ```lua
242
165
  ---@param input string
@@ -248,51 +171,27 @@ end
248
171
  ---@param confidenceThreshold number?
249
172
  ---@param exactMatch boolean?
250
173
  ---@return OCRResult[]
251
- function findText(input, targets, x, y, ex, ey, confidenceThreshold, exactMatch) end
174
+ function findTextAbs(input, targets, x, y, ex, ey, confidenceThreshold, exactMatch) end
252
175
  ```
253
176
 
254
177
  **参数:**
255
178
 
256
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
257
- | --------------------- | ----------------- | -------- | ------ | ------------------------------------------------------------------------ |
258
- | `input` | string | 是 | | 输入源,支持 imageId、URL 字符串、文件路径或 `"screen"` |
179
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
180
+ | --------------------- | ------------------ | -------- | ------ | ------------------------------------------------------------------------ |
181
+ | `input` | string | 是 | | 输入源,支持 imageId、URL 字符串、文件路径或 `"screen"` |
259
182
  | `targets` | string[] \| string | 是 | | 目标文本数组或逗号分隔字符串 |
260
- | `x` | number | 否 | 0 | 裁剪区域左上角 x 坐标;全屏识别传 0 |
261
- | `y` | number | 否 | 0 | 裁剪区域左上角 y 坐标;全屏识别传 0 |
262
- | `ex` | number | 否 | 0 | 裁剪区域右下角 x 坐标;全屏识别传 0 |
263
- | `ey` | number | 否 | 0 | 裁剪区域右下角 y 坐标;全屏识别传 0 |
264
- | `confidenceThreshold` | number | 否 | 0.6 | 置信度阈值,低于该值的识别结果会被过滤 |
265
- | `exactMatch` | boolean | 否 | false | 是否完整匹配;`false` 表示包含匹配,`true` 要求整条 OCR 文本等于目标文本 |
183
+ | `x` | number | 否 | 0 | 裁剪区域左上角 x 坐标;全屏识别传 0 |
184
+ | `y` | number | 否 | 0 | 裁剪区域左上角 y 坐标;全屏识别传 0 |
185
+ | `ex` | number | 否 | 0 | 裁剪区域右下角 x 坐标;全屏识别传 0 |
186
+ | `ey` | number | 否 | 0 | 裁剪区域右下角 y 坐标;全屏识别传 0 |
187
+ | `confidenceThreshold` | number | 否 | 0.6 | 置信度阈值,低于该值的识别结果会被过滤 |
188
+ | `exactMatch` | boolean | 否 | false | 是否完整匹配;`false` 表示包含匹配,`true` 要求整条 OCR 文本等于目标文本 |
266
189
 
267
190
  **返回值:**
268
191
 
269
- | 类型 | 描述 |
270
- | ------------- | ------------------------------------ |
271
- | `OCRResult[]` | 匹配到的结果数组,坐标相对于裁剪区域 |
272
-
273
- **示例:**
274
-
275
- ```lua
276
- local paddleocr = require("paddleocr")
277
- local hits = paddleocr.findText("screen", { "确定" }, 100, 100, 500, 400, 0.6, false)
278
- ```
279
-
280
- #### findTextAbs - 查找目标文本,并将结果坐标映射为原图/全屏绝对坐标。
281
-
282
- ```lua
283
- ---@param input string
284
- ---@param targets string[]|string
285
- ---@param x number?
286
- ---@param y number?
287
- ---@param ex number?
288
- ---@param ey number?
289
- ---@param confidenceThreshold number?
290
- ---@param exactMatch boolean?
291
- ---@return OCRResult[]
292
- function findTextAbs(input, targets, x, y, ex, ey, confidenceThreshold, exactMatch) end
293
- ```
294
-
295
- **参数:** 与 `findText` 相同;返回坐标为原图或全屏绝对坐标。
192
+ | 类型 | 描述 |
193
+ | ------------- | ---------------------------------------------- |
194
+ | `OCRResult[]` | 匹配到的子串结果数组,坐标为原图或全屏绝对坐标 |
296
195
 
297
196
  **示例:**
298
197
 
@@ -149,23 +149,6 @@ else
149
149
  end
150
150
  ```
151
151
 
152
- #### foregroundAppInfos - 获取前台运行的应用列表。
153
-
154
- ```lua
155
- ---@return table[]
156
- function foregroundAppInfos() end
157
- ```
158
-
159
- **示例:**
160
-
161
- ```lua
162
- local system = require("system")
163
- local apps = system.foregroundAppInfos()
164
- if #apps > 0 then
165
- print(apps[1].name, apps[1].bundleId)
166
- end
167
- ```
168
-
169
152
  #### backgroundAppInfos - 获取后台运行的应用列表。
170
153
 
171
154
  ```lua
package/docs/apilua/ui.md CHANGED
@@ -85,19 +85,6 @@ local ui = require("ui")
85
85
  ui.show()
86
86
  ```
87
87
 
88
- ### hide - 隐藏 WebView。
89
-
90
- ```lua
91
- function hide() end
92
- ```
93
-
94
- **示例:**
95
-
96
- ```lua
97
- local ui = require("ui")
98
- ui.hide()
99
- ```
100
-
101
88
  ### eval - 在 WebView 中执行 JavaScript 代码。
102
89
 
103
90
  ```lua
@@ -8,7 +8,7 @@ YOLO 模块基于 YOLOV8/YOLO11/YOLO26 算法和 NCNN 框架,提供高性能
8
8
 
9
9
  ## 功能概览
10
10
 
11
- - **模型管理**: YOLO 模型加载和资源管理
11
+ - **模型管理**: YOLOV8/YOLOV11/YOLOV26 模型加载和资源管理
12
12
  - **目标检测**: 实时物体检测和位置识别
13
13
  - **多源输入**: 支持屏幕截图、图片文件、URL 等多种输入源
14
14
  - **结果处理**: 完整的检测结果信息和坐标数据
@@ -79,7 +79,7 @@ function load(paramPath, binPath, nc, version, useGpu) end
79
79
  | `paramPath` | string | 是 | | NCNN 模型的 param 文件绝对路径 |
80
80
  | `binPath` | string | 是 | | NCNN 模型的 bin 文件绝对路径 |
81
81
  | `nc` | number | 否 | 0 | 模型的标签数量;传 `0` 或省略时根据模型输出自动推断,显式传入但不匹配时检测返回空数组 |
82
- | `version` | number | 否 | 0 | 模型版本;传 `0` 或省略时按 v11 处理,显式传入支持 8/11/26 |
82
+ | `version` | number | 否 | 11 | YOLO 模型版本号(仅支持 8/11/26|
83
83
  | `useGpu` | boolean | 否 | false | 是否启用 GPU 加速 |
84
84
 
85
85
  **返回值:**
@@ -101,79 +101,45 @@ local modelId = yolo.load(
101
101
  )
102
102
  ```
103
103
 
104
- #### loadV11 - 加载 YOLO 模型。
105
-
106
- 加载模型是使用目标检测功能的前提。兼容 YOLOV8 / YOLO11 的 NCNN 模型。
107
-
108
- ```lua
109
- ---@param paramPath string
110
- ---@param binPath string
111
- ---@param nc number?
112
- ---@param useGpu boolean?
113
- ---@return string|nil
114
- function loadV11(paramPath, binPath, nc, useGpu) end
115
- ```
116
-
117
- **参数:**
118
-
119
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
120
- | ----------- | ------- | -------- | ------ | --------------------------------------------------------------------------- |
121
- | `paramPath` | string | 是 | | NCNN 模型的 param 文件绝对路径 |
122
- | `binPath` | string | 是 | | NCNN 模型的 bin 文件绝对路径 |
123
- | `nc` | number | 否 | 0 | 模型的标签数量;传 `0` 或省略时根据模型输出自动推断,显式传入但不匹配时检测返回空数组 |
124
- | `useGpu` | boolean | 否 | false | 是否启用 GPU 加速 |
125
-
126
- **返回值:**
127
-
128
- | 类型 | 描述 |
129
- | --------------- | ----------------------------------------- |
130
- | `string \| nil` | 加载成功返回模型 ID 字符串,失败返回 nil |
131
-
132
- **示例:**
133
-
134
- ```lua
135
- local yolo = require("yolo")
136
-
137
- -- 加载 YOLO 模型
138
- local modelId = yolo.loadV11(
139
- "yolo11n_ncnn_model/model.ncnn.param",
140
- "yolo11n_ncnn_model/model.ncnn.bin",
141
- 0,
142
- false
143
- )
144
- ```
145
-
146
104
  ### 目标检测
147
105
 
148
- #### detect - 对输入图像执行目标检测。
106
+ #### detectAbs - 对指定区域执行目标检测,并将结果坐标映射为原图/全屏绝对坐标。
149
107
 
150
- 执行目标检测,识别图像中的物体并返回检测结果。
108
+ 执行目标检测,识别图像中的物体并返回检测结果。传入裁剪区域时,结果坐标会映射回原图或全屏坐标,可直接用于点击;全屏检测时 `x/y/ex/ey` 传 `0`。
151
109
 
152
110
  ```lua
153
111
  ---@param modelId string
154
112
  ---@param img string
113
+ ---@param x number?
114
+ ---@param y number?
115
+ ---@param ex number?
116
+ ---@param ey number?
155
117
  ---@param targetSize number?
156
118
  ---@param threshold number?
157
119
  ---@param nmsThreshold number?
158
120
  ---@return YoloResult[]
159
- function detect(modelId, img, targetSize, threshold, nmsThreshold) end
121
+ function detectAbs(modelId, img, x, y, ex, ey, targetSize, threshold, nmsThreshold) end
160
122
  ```
161
123
 
162
124
  **参数:**
163
125
 
164
126
  | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
165
127
  | -------------- | ------ | -------- | ------ | ------------------------------------------------------------------ |
166
- | `modelId` | string | 是 | | 模型 ID,通过 `loadV11` 获取 |
128
+ | `modelId` | string | 是 | | 模型 ID,通过 `load` 获取 |
167
129
  | `img` | string | 是 | | 图像输入源,支持 `"screen"`、图片文件路径、HTTP 图片地址或 imageId |
130
+ | `x` | number | 否 | 0 | 裁剪区域左上角 x 坐标;全屏检测传 0 |
131
+ | `y` | number | 否 | 0 | 裁剪区域左上角 y 坐标;全屏检测传 0 |
132
+ | `ex` | number | 否 | 0 | 裁剪区域右下角 x 坐标;全屏检测传 0 |
133
+ | `ey` | number | 否 | 0 | 裁剪区域右下角 y 坐标;全屏检测传 0 |
168
134
  | `targetSize` | number | 否 | 640 | 模型推理输入边长,通常为 640(与模型训练时一致) |
169
135
  | `threshold` | number | 否 | 0.4 | 置信度阈值,低于此值的检测结果会被过滤 |
170
136
  | `nmsThreshold` | number | 否 | 0.5 | 非极大值抑制阈值,用于去除重叠检测框 |
171
137
 
172
138
  **返回值:**
173
139
 
174
- | 类型 | 描述 |
175
- | -------------- | -------------- |
176
- | `YoloResult[]` | 检测结果数组 |
140
+ | 类型 | 描述 |
141
+ | -------------- | -------------------------------------- |
142
+ | `YoloResult[]` | 检测结果数组,坐标为原图或全屏绝对坐标 |
177
143
 
178
144
  **示例:**
179
145
 
@@ -181,10 +147,11 @@ function detect(modelId, img, targetSize, threshold, nmsThreshold) end
181
147
  local yolo = require("yolo")
182
148
 
183
149
  -- 首先加载模型
184
- local modelId = yolo.loadV11(
150
+ local modelId = yolo.load(
185
151
  "/yolo11n_ncnn_model/model.ncnn.param",
186
152
  "/yolo11n_ncnn_model/model.ncnn.bin",
187
153
  0,
154
+ 11,
188
155
  false
189
156
  )
190
157
 
@@ -194,7 +161,7 @@ if not modelId then
194
161
  end
195
162
 
196
163
  -- 检测当前屏幕
197
- local screenResults = yolo.detect(modelId, "screen", 640, 0.4, 0.5)
164
+ local screenResults = yolo.detectAbs(modelId, "screen", 0, 0, 0, 0, 640, 0.4, 0.5)
198
165
  print("屏幕检测到 " .. tostring(#screenResults) .. " 个物体")
199
166
 
200
167
  for index, result in ipairs(screenResults) do
@@ -206,80 +173,21 @@ for index, result in ipairs(screenResults) do
206
173
  print(" 尺寸: " .. tostring(result.width) .. " x " .. tostring(result.height))
207
174
  end
208
175
 
209
- -- 检测图片文件
210
- local imageResults = yolo.detect(modelId, "/path/to/test_image.jpg", 640, 0.3, 0.5)
176
+ -- 检测图片文件的指定区域
177
+ local imageResults = yolo.detectAbs(modelId, "/path/to/test_image.jpg", 100, 100, 500, 400, 640, 0.3, 0.5)
211
178
  if #imageResults > 0 then
212
179
  print("图片中检测到 " .. tostring(#imageResults) .. " 个物体")
213
- for _, result in ipairs(imageResults) do
214
- print("检测到类别 " .. tostring(result.classId) .. ",置信度: " .. tostring(result.confidence))
215
- end
216
180
  else
217
181
  print("图片中未检测到任何物体")
218
182
  end
219
183
 
220
184
  -- 检测网络图片
221
- local urlResults = yolo.detect(modelId, "https://example.com/test_image.jpg", 640, 0.5, 0.4)
185
+ local urlResults = yolo.detectAbs(modelId, "https://example.com/test_image.jpg", 0, 0, 0, 0, 640, 0.5, 0.4)
222
186
  print("网络图片检测结果: " .. tostring(#urlResults) .. " 个物体")
223
187
 
224
188
  yolo.free(modelId)
225
189
  ```
226
190
 
227
- #### detectAbs - 对指定区域执行目标检测,并将结果坐标映射为原图/全屏绝对坐标。
228
-
229
- 传入裁剪区域时,结果坐标会映射回原图或全屏坐标,可直接用于点击;全屏检测时 `x/y/ex/ey` 传 `0`。
230
-
231
- ```lua
232
- ---@param modelId string
233
- ---@param img string
234
- ---@param x number
235
- ---@param y number
236
- ---@param ex number
237
- ---@param ey number
238
- ---@param targetSize number?
239
- ---@param threshold number?
240
- ---@param nmsThreshold number?
241
- ---@return YoloResult[]
242
- function detectAbs(modelId, img, x, y, ex, ey, targetSize, threshold, nmsThreshold) end
243
- ```
244
-
245
- **参数:**
246
-
247
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
248
- | -------------- | ------ | -------- | ------ | ------------------------------------------------------------------ |
249
- | `modelId` | string | 是 | | 模型 ID,通过 `load` 或 `loadV11` 获取 |
250
- | `img` | string | 是 | | 图像输入源,支持 `"screen"`、图片文件路径、HTTP 图片地址或 imageId |
251
- | `x` | number | 是 | | 裁剪区域左上角 x 坐标;全屏检测传 0 |
252
- | `y` | number | 是 | | 裁剪区域左上角 y 坐标;全屏检测传 0 |
253
- | `ex` | number | 是 | | 裁剪区域右下角 x 坐标;全屏检测传 0 |
254
- | `ey` | number | 是 | | 裁剪区域右下角 y 坐标;全屏检测传 0 |
255
- | `targetSize` | number | 否 | 640 | 模型推理输入边长,通常为 640(与模型训练时一致) |
256
- | `threshold` | number | 否 | 0.4 | 置信度阈值,低于此值的检测结果会被过滤 |
257
- | `nmsThreshold` | number | 否 | 0.5 | 非极大值抑制阈值,用于去除重叠检测框 |
258
-
259
- **返回值:**
260
-
261
- | 类型 | 描述 |
262
- | -------------- | -------------------------------------- |
263
- | `YoloResult[]` | 检测结果数组,坐标为原图或全屏绝对坐标 |
264
-
265
- **示例:**
266
-
267
- ```lua
268
- local yolo = require("yolo")
269
- local modelId = yolo.load(
270
- "/yolo11n_ncnn_model/model.ncnn.param",
271
- "/yolo11n_ncnn_model/model.ncnn.bin",
272
- 0,
273
- 11,
274
- false
275
- )
276
- local results = yolo.detectAbs(modelId, "screen", 0, 0, 0, 0, 640, 0.4, 0.5)
277
- if #results > 0 then
278
- print(results[1].classId, results[1].centerX, results[1].centerY)
279
- end
280
- yolo.free(modelId)
281
- ```
282
-
283
191
  ### 资源管理
284
192
 
285
193
  #### free - 释放指定模型的资源。
@@ -218,3 +218,23 @@ print("开始播放音频...")
218
218
  played = media.playMp3WaitEnd("/var/mobile/Media/notification.mp3")
219
219
  print("音频播放完成" if played else "播放失败或被系统音频中断")
220
220
  ```
221
+
222
+ #### isMp3Playing - 当前是否正在播放 MP3。
223
+
224
+ ```python
225
+ def isMp3Playing() -> bool
226
+ ```
227
+
228
+ **返回值:**
229
+
230
+ | 类型 | 描述 |
231
+ | ------ | -------------------------------- |
232
+ | `bool` | 正在播放返回 `True`,否则 `False` |
233
+
234
+ **示例:**
235
+
236
+ ```python
237
+ from kuaijs import media
238
+
239
+ print("正在播放" if media.isMp3Playing() else "未播放")
240
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "1.4.57",
3
+ "version": "1.4.59",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {