ms-types 0.10.8 → 0.10.9

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.
@@ -1,4 +1,5 @@
1
1
  ---@meta
2
+ --- 图片模块
2
3
  ---@class Image
3
4
  local _Image = {}
4
5
 
@@ -30,30 +31,51 @@ local _Image = {}
30
31
  ---@field orz integer|nil 查找方向 1-8,与 findColor 相同
31
32
 
32
33
  --- 截取屏幕;坐标缺省 0 表示全屏
33
- --- @param x integer|nil 左上角 x
34
- --- @param y integer|nil 左上角 y
35
- --- @param ex integer|nil 右下角 x
36
- --- @param ey integer|nil 右下角 y
37
- --- @return string|nil 图片ID
34
+ ---@param x integer|nil 截图区域左上角x坐标
35
+ ---@param y integer|nil 截图区域左上角y坐标
36
+ ---@param ex integer|nil 截图区域右下角x坐标
37
+ ---@param ey integer|nil 截图区域右下角y坐标
38
+ ---@return string|nil 截图的imageId ,如果截图失败则返回null
39
+ ---@example local imageId = image.captureScreen()
40
+ --- if imageId then
41
+ --- image.saveTo(imageId, "screen.jpg")
42
+ --- end
38
43
  function _Image.captureScreen(x, y, ex, ey) return '' end
39
44
 
40
45
  --- 读取图片
41
- --- @param path string 文件路径
42
- --- @return string 图片ID
46
+ ---@param path string 图片路径
47
+ ---@return string 图片id ,如果读取失败则返回null
48
+ ---@example local imageId = image.readImage("screen.jpg")
49
+ --- if imageId then
50
+ --- image.saveTo(imageId, "screen.jpg")
51
+ --- end
52
+ --- image.release(imageId)
43
53
  function _Image.readImage(path) return '' end
44
54
 
45
55
  --- 裁剪图片
46
- --- @param id string 图片ID
47
- --- @param x integer|nil
48
- --- @param y integer|nil
49
- --- @param ex integer|nil 右下角x
50
- --- @param ey integer|nil 右下角y
51
- --- @return string 新图片ID
56
+ ---@param id string 图片id
57
+ ---@param x integer|nil 坐标x
58
+ ---@param y integer|nil 坐标y
59
+ ---@param ex integer|nil 坐标ex
60
+ ---@param ey integer|nil 坐标ey
61
+ ---@return string 裁剪后的图片id
62
+ ---@example local imageId = image.readImage("screen.jpg")
63
+ --- if imageId then
64
+ --- local clipImageId = image.clip(imageId, 0, 0, 100, 100)
65
+ --- if clipImageId then
66
+ --- logi("裁剪成功")
67
+ --- end
68
+ --- end
69
+ --- image.release(imageId)
52
70
  function _Image.clip(id, x, y, ex, ey) return '' end
53
71
 
54
72
  --- 获取尺寸
55
- --- @param id string 图片ID
56
- --- @return Size 尺寸对象
73
+ ---@param id string 图片id
74
+ ---@return Size 图片大小 {width: number, height: number}
75
+ ---@example local size = image.getSize(imageId)
76
+ --- if size then
77
+ --- logi(size.width, size.height)
78
+ --- end
57
79
  function _Image.getSize(id)
58
80
  ---@type Size
59
81
  local ret
@@ -61,147 +83,249 @@ function _Image.getSize(id)
61
83
  end
62
84
 
63
85
  --- 转为Base64
64
- --- @param id string 图片ID
65
- --- @param format string 格式,如 'png'
66
- --- @param quality integer|nil 质量
67
- --- @return string Base64文本
86
+ ---@param id string 图片id
87
+ ---@param format string 格式
88
+ ---@param quality integer|nil 质量 1-100 数字越大质量越高
89
+ ---@return string base64字符串
90
+ ---@example local imageId = image.readImage("screen.jpg")
91
+ --- if imageId then
92
+ --- local base64 = image.toBase64Format(imageId, "jpg", 100)
93
+ --- logi(base64)
94
+ --- end
95
+ --- image.release(imageId)
68
96
  function _Image.toBase64Format(id, format, quality) return '' end
69
97
 
70
98
  --- Base64转图片
71
- --- @param s string Base64文本
72
- --- @return string 图片ID
99
+ ---@param s string base64字符串
100
+ ---@return string 图片id
101
+ ---@example local imageId = image.base64ToImage("data:image/jpg;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+P+/HgAFhAJ/wlseKgAAAABJRU5ErkJggg==")
102
+ --- if imageId then
103
+ --- logi("base64转图片成功")
104
+ --- end
105
+ --- image.release(imageId)
73
106
  function _Image.base64ToImage(s) return '' end
74
107
 
75
108
  --- 旋转图片
76
- --- @param id string 图片ID
77
- --- @param degree integer 角度(90 | -90 | 180)
78
- --- @return string|nil 新图片ID
109
+ ---@param id string 图片id
110
+ ---@param degree integer 旋转角度 只能是 90 -90 180
111
+ ---@return string|nil 旋转后的图片id ,如果旋转失败则返回null
112
+ ---@example local imageId = image.readImage("screen.jpg")
113
+ --- if imageId then
114
+ --- local newImageId = image.rotateImage(imageId, 90)
115
+ --- if newImageId then
116
+ --- image.saveTo(newImageId, "screen.jpg")
117
+ --- end
118
+ --- image.release(imageId)
119
+ --- end
79
120
  function _Image.rotateImage(id, degree) return '' end
80
121
 
81
122
  --- 图片是否已释放
82
- --- @param id string 图片ID
83
- --- @return boolean 已释放
123
+ ---@param id string 图片id
124
+ ---@return boolean true 已释放 false 未释放
125
+ ---@example local imageId = image.captureScreen()
126
+ --- if imageId then
127
+ --- image.saveTo(imageId, "screen.jpg")
128
+ --- image.isRelease(imageId) -- false
129
+ --- image.release(imageId)
130
+ --- image.isRelease(imageId) -- true
131
+ --- end
84
132
  function _Image.isRelease(id) return false end
85
133
 
86
134
  --- 释放图片
87
- --- @param id string 图片ID
135
+ ---@param id string 图片id
136
+ ---@example image.release(imageId)
88
137
  function _Image.release(id) end
89
138
 
90
139
  --- 保存图片到路径
91
- --- @param id string 图片ID
92
- --- @param path string 文件路径
93
- --- @return boolean 成功
140
+ ---@param id string 图片id 路径 http地址或者 screen 实时截屏
141
+ ---@param path string 保存路径
142
+ ---@return boolean 成功
143
+ ---@example image.saveTo(imageId, "screen.jpg")
94
144
  function _Image.saveTo(id, path) return true end
95
145
 
96
146
  --- 查找颜色
97
- --- @param id string 图片ID
98
- --- @param color string 颜色 "#RRGGBB",可带偏色
99
- --- @param threshold number 相似度 0.0-1.0
100
- --- @param x integer|nil 左上x
101
- --- @param y integer|nil 左上y
102
- --- @param ex integer|nil 右下x
103
- --- @param ey integer|nil 右下y
104
- --- @param limit integer 限制个数
105
- --- @param orz integer 方向 1-8
106
- --- @return Point[] 结果点列表
147
+ ---@param id string 图片id
148
+ ---@param color string 颜色 支持"主色-偏色"格式,如"#6DD1E6-#101010"
149
+ ---@param threshold number 阈值 0.0-1.0
150
+ ---@param x integer|nil 左上角x 全屏传0
151
+ ---@param y integer|nil 左上角y 全屏传0
152
+ ---@param ex integer|nil 右下角x 全屏传0
153
+ ---@param ey integer|nil 右下角y 全屏传0
154
+ ---@param limit integer 限制数量
155
+ ---@param orz integer 查找方向1-8
156
+ ---@return Point[] 颜色点数组
157
+ ---@example local imageId = image.readImage("screen.jpg")
158
+ --- if imageId then
159
+ --- local points = image.findColor(imageId, "#6DD1E6-#101010", 0.9, 0, 0, 100, 100, 1, 1)
160
+ --- if #points > 0 then
161
+ --- logi("找到颜色")
162
+ --- end
163
+ --- end
164
+ --- image.release(imageId)
107
165
  function _Image.findColor(id, color, threshold, x, y, ex, ey, limit, orz)
108
166
  return {}
109
167
  end
110
168
 
111
169
  --- 多点比色
112
- --- @param id string 图片ID
113
- --- @param points string 点配置 "x|y|主色-偏色,..."
114
- --- @param threshold number 相似度 0.0-1.0
115
- --- @return boolean 是否相同
170
+ ---@param id string 图片id
171
+ ---@param points string 颜色点
172
+ ---@param threshold number 阈值 0.0-1.0
173
+ ---@return boolean true 相同 false 不同
174
+ ---@example local imageId = image.readImage("screen.jpg")
175
+ --- if imageId then
176
+ --- local isSame = image.cmpColor(imageId, "1|2|#6DD1E6-#101010", 0.9)
177
+ --- if isSame then
178
+ --- logi("颜色相同")
179
+ --- end
180
+ --- end
116
181
  function _Image.cmpColor(id, points, threshold) return true end
117
182
 
118
183
  --- 查找图片
119
- --- @param id string 图片ID
120
- --- @param templateImageId string 模板图片ID
121
- --- @param x integer|nil 左上x
122
- --- @param y integer|nil 左上y
123
- --- @param ex integer|nil 右下x
124
- --- @param ey integer|nil 右下y
125
- --- @param threshold number 相似度 0.0-1.0
126
- --- @param limit integer|nil 限制个数
127
- --- @param method integer|nil 匹配方法 0|1|3|5|99,默认 5
128
- --- @param rgb boolean|nil 是否使用RGB
129
- --- @param options FindImageOptions|nil 选项。scaleFactors 仅 method=99;orz 为查找方向 1-8
130
- --- @return Rect[] 结果矩形列表
184
+ ---@param id string 图片ID
185
+ ---@param templateImageId string 模板图片id
186
+ ---@param x integer|nil 左上角x 全屏传0
187
+ ---@param y integer|nil 左上角y 全屏传0
188
+ ---@param ex integer|nil 右下角x 全屏传0
189
+ ---@param ey integer|nil 右下角y 全屏传0
190
+ ---@param threshold number 阈值 0.0-1.0
191
+ ---@param limit integer|nil 限制数量
192
+ ---@param method integer|nil 方法
193
+ ---@param rgb boolean|nil 是否使用RGB找图,默认false
194
+ ---@param options FindImageOptions|nil 选项
195
+ ---@return Rect[] 图片数组;method=99 时结果额外含 scaleX/scaleY
196
+ ---@example local points = image.findImage("screen", "template.jpg", 0, 0, 100, 100, 0.9, 1, 5, false)
197
+ --- if #points > 0 then
198
+ --- logi("找到图片")
199
+ --- end
131
200
  function _Image.findImage(id, templateImageId, x, y, ex, ey, threshold, limit,
132
201
  method, rgb, options) return {} end
133
202
 
134
203
  --- 按 kjst 模板找图
135
- --- @param id string 图片ID,通常为 screen
136
- --- @param kjstPath string res 下的 kjst 文件名
137
- --- @return Rect[] 结果矩形,坐标已换算到传入图(screen 即屏幕)像素,可直接 click;OCR 命中含 text
204
+ ---@param id string 图片id,通常为 `"screen"`
205
+ ---@param kjstPath string res 下的 kjst 文件名,不要带 `res/` 前缀
206
+ ---@return Rect[] 矩形数组,坐标已换算到传入图片(`screen` 即屏幕)像素,可直接 click;OCR 命中额外含 `text`
207
+ ---@example local hits = image.findImageEx("screen", "login.kjst")
208
+ --- if #hits > 0 then
209
+ --- logi(hits[0].x, hits[0].y)
210
+ --- end
138
211
  function _Image.findImageEx(id, kjstPath) return {} end
139
212
 
140
213
  --- 多点找色
141
- --- @param id string 图片ID
142
- --- @param firstColor string 首色 "#RRGGBB" 或 "#RRGGBB"
143
- --- @param threshold number 相似度 0.0-1.0
144
- --- @param points string 点配置 "x|y|主色-偏色,..."
145
- --- @param x integer 左上x
146
- --- @param y integer 左上y
147
- --- @param ex integer 右下x
148
- --- @param ey integer 右下y
149
- --- @param limit integer 限制个数
150
- --- @param orz integer 方向 1-8
151
- --- @return Point[] 结果点列表
214
+ ---@param id string 图片id
215
+ ---@param firstColor string 第一个颜色
216
+ ---@param threshold number 阈值 0.0-1.0
217
+ ---@param points string 颜色点
218
+ ---@param x integer 左上角x 全屏传0
219
+ ---@param y integer 左上角y 全屏传0
220
+ ---@param ex integer 右下角x 全屏传0
221
+ ---@param ey integer 右下角y 全屏传0
222
+ ---@param limit integer 限制数量
223
+ ---@param orz integer 查找方向1-8
224
+ ---@return Point[] 颜色点数组
225
+ ---@example local imageId = image.readImage("screen.jpg")
226
+ --- if imageId then
227
+ --- local points = image.findMultiColor(imageId, "#6DD1E6-#101010", 0.9, "1|2|#6DD1E6-#101010", 0, 0, 100, 100, 1, 1)
228
+ --- if #points > 0 then
229
+ --- logi("找到颜色")
230
+ --- end
231
+ --- end
232
+ --- image.release(imageId)
152
233
  function _Image.findMultiColor(id, firstColor, threshold, points, x, y, ex, ey,
153
234
  limit, orz) return {} end
154
235
 
155
236
  --- 统计颜色数量
156
- --- @param id string 图片ID
157
- --- @param colors string 颜色列表 "主色-偏色|主色-偏色|..."
158
- --- @param threshold number 相似度 0.0-1.0
159
- --- @param x integer 左上x
160
- --- @param y integer 左上y
161
- --- @param ex integer 右下x
162
- --- @param ey integer 右下y
163
- --- @return integer 命中像素数量
237
+ ---@param id string 图片id
238
+ ---@param colors string 颜色列表,支持 "主色-偏色|主色-偏色|...",如 "#0A0A0A-#101010|#FFFFFF-#101010"
239
+ ---@param threshold number 相似度阈值 0.0-1.0
240
+ ---@param x integer 区域左上角x(全图传0)
241
+ ---@param y integer 区域左上角y(全图传0)
242
+ ---@param ex integer 区域右下角x(全图传0)
243
+ ---@param ey integer 区域右下角y(全图传0)
244
+ ---@return integer 命中像素数量
245
+ ---@example local n = image.countColor("screen", "#0A0A0A-#101010|#FFFFFF-#101010", 0.92, 100, 200, 500, 700)
164
246
  function _Image.countColor(id, colors, threshold, x, y, ex, ey) return 0 end
165
247
 
166
248
  --- 像素值
167
- --- @param id string 图片ID
168
- --- @param x integer
169
- --- @param y integer
170
- --- @return integer ARGB值
249
+ ---@param id string 图片id
250
+ ---@param x integer 坐标x
251
+ ---@param y integer 坐标y
252
+ ---@return integer 颜色值
253
+ ---@example local imageId = image.readImage("screen.jpg")
254
+ --- if imageId then
255
+ --- local color = image.pixel(imageId, 0, 0)
256
+ --- logi(color)
257
+ --- end
258
+ --- image.release(imageId)
171
259
  function _Image.pixel(id, x, y) return 0 end
172
260
 
173
261
  --- 颜色转16进制字符串
174
- --- @param color integer ARGB整数
175
- --- @return string #RRGGBB
262
+ ---@param color integer 颜色值
263
+ ---@return string 16进制RGB字符串
264
+ ---@example local imageId = image.readImage("screen.jpg")
265
+ --- if imageId then
266
+ --- local color = image.pixel(imageId, 0, 0)
267
+ --- logi(image.argb(color))
268
+ --- end
269
+ --- image.release(imageId)
176
270
  function _Image.argb(color) return '' end
177
271
 
178
272
  --- 二值化
179
- --- @param id string 图片ID
180
- --- @param threshold number 阈值
181
- --- @return string 新图片ID
273
+ ---@param id string 图片id
274
+ ---@param threshold number 阈值 0.0-255.0
275
+ ---@return string 二值化后的图片id
276
+ ---@example local imageId = image.readImage("screen.jpg")
277
+ --- if imageId then
278
+ --- local binaryzationImageId = image.binaryzation(imageId, 128)
279
+ --- if binaryzationImageId then
280
+ --- logi("二值化成功")
281
+ --- end
282
+ --- end
283
+ --- image.release(imageId)
182
284
  function _Image.binaryzation(id, threshold) return '' end
183
285
 
184
286
  --- 灰度化
185
- --- @param id string 图片ID
186
- --- @return string 新图片ID
287
+ ---@param id string 图片id
288
+ ---@return string 灰度化后的图片id
289
+ ---@example local imageId = image.readImage("screen.jpg")
290
+ --- if imageId then
291
+ --- local grayImageId = image.gray(imageId)
292
+ --- if grayImageId then
293
+ --- logi("灰度化成功")
294
+ --- end
295
+ --- end
296
+ --- image.release(imageId)
187
297
  function _Image.gray(id) return '' end
188
298
 
189
299
  --- 扫描条码/二维码
190
- --- @param id string 图片ID
191
- --- @return string|nil 文本
300
+ ---@param id string 图片id
301
+ ---@return string|nil 条码内容
302
+ ---@example local imageId = image.readImage("screen.jpg")
303
+ --- if imageId then
304
+ --- local code = image.scanCode(imageId)
305
+ --- if code then
306
+ --- logi(code)
307
+ --- end
308
+ --- end
192
309
  function _Image.scanCode(id) return '' end
193
310
 
194
311
  --- 绘制矩形
195
- --- @param id string 图片ID
196
- --- @param x integer|nil 左上x
197
- --- @param y integer|nil 左上y
198
- --- @param ex integer|nil 右下x
199
- --- @param ey integer|nil 右下y
200
- --- @param color string|nil 颜色 #RRGGBB
201
- --- @param thickness integer|nil 线宽 -1填充
312
+ ---@param id string 图片id
313
+ ---@param x integer|nil 坐标x
314
+ ---@param y integer|nil 坐标y
315
+ ---@param ex integer|nil 坐标ex
316
+ ---@param ey integer|nil 坐标ey
317
+ ---@param color string|nil 颜色
318
+ ---@param thickness integer|nil 线宽
319
+ ---@return 无
320
+ ---@example local imageId = image.readImage("screen.jpg")
321
+ --- if imageId then
322
+ --- image.drawRect(imageId, 0, 0, 100, 100, "#ff0000", 1)
323
+ --- end
324
+ --- image.release(imageId)
202
325
  function _Image.drawRect(id, x, y, ex, ey, color, thickness) end
203
326
 
204
327
  --- 释放所有图片
328
+ ---@example image.releaseAll()
205
329
  function _Image.releaseAll() end
206
330
 
207
331
  ---@type Image
package/types/lua/ime.lua CHANGED
@@ -1,48 +1,72 @@
1
1
  ---@meta
2
+ --- 输入法模块
2
3
  ---@class Ime
3
4
  local _Ime = {}
4
5
 
5
6
  --- 输入法是否可用(键盘是否已弹出)
6
- --- @return boolean 可用
7
+ ---@return boolean 如果输入法键盘是否已弹出返回 true,否则返回 false
8
+ ---@example if ime.isOk() then
9
+ --- logi("输入法已启动")
10
+ --- end
7
11
  function _Ime.isOk() return false end
8
12
 
9
13
  --- 获取当前输入框文本
10
- --- @return string 文本
14
+ ---@return string 当前输入框的完整文本
15
+ ---@example local text = ime.getText()
16
+ --- logi(text)
11
17
  function _Ime.getText() return '' end
12
18
 
13
19
  --- 清空输入框文本
14
- --- @return boolean 成功
20
+ ---@return boolean 成功
21
+ ---@example ime.clearText()
15
22
  function _Ime.clearText() return true end
16
23
 
17
24
  --- 输入文本(content 为空时使用剪贴板)
18
- --- @param text string 文本
19
- --- @return string 实际输入的文本(失败为空字符串)
25
+ ---@param text string 要输入的文本
26
+ ---@return string 输入后的文本内容 失败返回空字符串
27
+ ---@example local text = ime.input("hello")
28
+ --- logi(text)
20
29
  function _Ime.input(text) return '' end
21
30
 
22
31
  --- 粘贴文本(content 为空时使用剪贴板)
23
- --- @param text string|nil 文本
24
- --- @return string 实际粘贴的文本(失败为空字符串)
32
+ ---@param text string|nil 要粘贴的文本
33
+ ---@return string 粘贴后的文本内容 失败返回空字符串
34
+ ---@example local text = ime.paste("hello")
35
+ --- logi(text)
25
36
  function _Ime.paste(text) return '' end
26
37
 
27
38
  --- 删除一个字符(返回剩余文本;空表示无数据)
28
- --- @return string 剩余文本
39
+ ---@return string 如果为空,代表输入框无数据,如果不为空,代表输入框剩余数据
40
+ ---@example local text = ime.pressDel()
41
+ --- logi(text)
29
42
  function _Ime.pressDel() return '' end
30
43
 
31
44
  --- 回车键
32
- --- @return boolean 成功
45
+ ---@return boolean 如果成功返回 true,否则返回 false
46
+ ---@example if ime.pressEnter() then
47
+ --- logi("回车键按下")
48
+ --- end
33
49
  function _Ime.pressEnter() return true end
34
50
 
35
51
  --- 隐藏键盘
36
- --- @return boolean 成功
52
+ ---@return boolean 如果成功返回 true,否则返回 false
53
+ ---@example if ime.dismiss() then
54
+ --- logi("键盘已隐藏")
55
+ --- end
37
56
  function _Ime.dismiss() return true end
38
57
 
39
58
  --- 获取剪贴板
40
- --- @return string 文本
59
+ ---@return string 剪贴板内容
60
+ ---@example local text = ime.getClipboard()
61
+ --- logi(text)
41
62
  function _Ime.getClipboard() return '' end
42
63
 
43
64
  --- 设置剪贴板(键盘显示时)
44
- --- @param text string 文本
45
- --- @return boolean 成功
65
+ ---@param text string 要设置的剪贴板内容 键盘显示时才能设置
66
+ ---@return boolean 如果成功返回 true,否则返回 false
67
+ ---@example if ime.setClipboard("hello") then
68
+ --- logi("剪贴板内容已设置")
69
+ --- end
46
70
  function _Ime.setClipboard(text) return true end
47
71
 
48
72
  ---@type Ime
@@ -1,44 +1,54 @@
1
1
  ---@meta
2
+ --- 日志模块
2
3
  ---@class Logger
3
4
  local _Logger = {}
4
5
 
5
6
  --- 设置日志级别(error|warn|info|debug|off)
6
- --- @param level string 级别
7
+ ---@param level string 日志等级
8
+ ---@example logger.setLoggerLevel("info")
7
9
  function _Logger.setLoggerLevel(level) end
8
10
 
9
11
  --- 设置是否输出到日志文件
10
- --- @param enabled boolean 是否启用文件输出
12
+ ---@param enabled boolean 是否输出到文件
13
+ ---@example logger.setLogToFile(true)
11
14
  function _Logger.setLogToFile(enabled) end
12
15
 
13
16
  --- 设置最大日志文件数量(默认 10)
14
- --- @param count integer 数量
17
+ ---@param count integer 最大日志文件数量
18
+ ---@example logger.setMaxLogFileCount(10)
15
19
  function _Logger.setMaxLogFileCount(count) end
16
20
 
17
21
  --- 设置最大日志文件大小(MB,默认 10)
18
- --- @param size integer 大小
22
+ ---@param size integer 最大日志文件大小(单位:MB)
23
+ ---@example logger.setMaxLogFileSize(10)
19
24
  function _Logger.setMaxLogFileSize(size) end
20
25
 
21
26
  --- 重置日志文件(创建新文件写入)
27
+ ---@example logger.resetLogFile()
22
28
  function _Logger.resetLogFile() end
23
29
 
24
30
  --- 输出调试日志(级别:debug)
25
- --- @param ... any 日志内容
26
- --- @return nil
31
+ ---@param ... any 日志内容
32
+ ---@return nil
33
+ ---@example logger.debug("调试日志")
27
34
  function _Logger.debug(...) end
28
35
 
29
36
  --- 输出信息日志(级别:info)
30
- --- @param ... any 日志内容
31
- --- @return nil
37
+ ---@param ... any 日志内容
38
+ ---@return nil
39
+ ---@example logger.info("信息日志")
32
40
  function _Logger.info(...) end
33
41
 
34
42
  --- 输出警告日志(级别:warn)
35
- --- @param ... any 日志内容
36
- --- @return nil
43
+ ---@param ... any 日志内容
44
+ ---@return nil
45
+ ---@example logger.warn("警告日志")
37
46
  function _Logger.warn(...) end
38
47
 
39
48
  --- 输出错误日志(级别:error)
40
- --- @param ... any 日志内容
41
- --- @return nil
49
+ ---@param ... any 日志内容
50
+ ---@return nil
51
+ ---@example logger.error("错误日志")
42
52
  function _Logger.error(...) end
43
53
 
44
54
  ---@type Logger
@@ -1,46 +1,86 @@
1
1
  ---@meta
2
+ --- 媒体模块
2
3
  ---@class Media
3
4
  local _Media = {}
4
5
 
5
6
  --- 播放MP3
6
- --- @param file string 文件路径
7
- --- @param loop boolean|nil 循环播放
8
- --- @return boolean 成功
7
+ ---@param file string 文件路径
8
+ ---@param loop boolean|nil 是否循环播放
9
+ ---@return boolean 是否播放成功
10
+ ---@example local played = media.playMp3("music.mp3", true)
11
+ --- if played then
12
+ --- logi("播放成功")
13
+ --- end
9
14
  function _Media.playMp3(file, loop) return true end
10
15
 
11
16
  --- 停止播放
12
- --- @return boolean 成功
17
+ ---@return boolean 是否停止成功
18
+ ---@example local stopped = media.stopMp3()
19
+ --- if stopped then
20
+ --- logi("停止成功")
21
+ --- end
13
22
  function _Media.stopMp3() return true end
14
23
 
15
24
  --- 播放一次并等待结束
16
- --- @param file string 文件路径
17
- --- @return boolean 是否正常播放到结尾
25
+ ---@param file string 文件路径
26
+ ---@return boolean 是否正常播放到结尾
27
+ ---@example local played = media.playMp3WaitEnd("music.mp3")
28
+ --- if played then
29
+ --- logi("播放成功")
30
+ --- end
18
31
  function _Media.playMp3WaitEnd(file) return true end
19
32
 
20
33
  --- 是否正在播放
21
- --- @return boolean 正在播放
34
+ ---@return boolean 是否正在播放
35
+ ---@example local playing = media.isMp3Playing()
36
+ --- if playing then
37
+ --- logi("正在播放")
38
+ --- end
22
39
  function _Media.isMp3Playing() return true end
23
40
 
24
41
  --- 保存图片到相册
25
- --- @param imageId string 图片ID
26
- --- @return boolean 成功
42
+ ---@param imageId string 图像ID
43
+ ---@return boolean 是否保存成功
44
+ ---@example local imageId = image.readImage("screen.png")
45
+ --- if imageId then
46
+ --- local saved = media.saveImageToAlbum(imageId)
47
+ --- if saved then
48
+ --- logi("保存成功")
49
+ --- end
50
+ --- end
27
51
  function _Media.saveImageToAlbum(imageId) return true end
28
52
 
29
53
  --- 保存视频到相册(路径)
30
- --- @param path string 文件路径
31
- --- @return boolean 成功
54
+ ---@param path string 视频文件的路径
55
+ ---@return boolean 是否保存成功
56
+ ---@example local saved = media.saveVideoToAlbumPath("video.mp4")
57
+ --- if saved then
58
+ --- logi("保存成功")
59
+ --- end
32
60
  function _Media.saveVideoToAlbumPath(path) return true end
33
61
 
34
62
  --- 清空相册中的图片
35
- --- @return boolean 成功
63
+ ---@return boolean 是否删除成功
64
+ ---@example local deleted = media.deleteAllPhotos()
65
+ --- if deleted then
66
+ --- logi("删除成功")
67
+ --- end
36
68
  function _Media.deleteAllPhotos() return true end
37
69
 
38
70
  --- 清空相册中的视频
39
- --- @return boolean 成功
71
+ ---@return boolean 是否删除成功
72
+ ---@example local deleted = media.deleteAllVideos()
73
+ --- if deleted then
74
+ --- logi("删除成功")
75
+ --- end
40
76
  function _Media.deleteAllVideos() return true end
41
77
 
42
78
  --- 清空相册中的截图
43
- --- @return boolean 成功
79
+ ---@return boolean 是否删除成功
80
+ ---@example local deleted = media.deleteAllScreenshots()
81
+ --- if deleted then
82
+ --- logi("删除成功")
83
+ --- end
44
84
  function _Media.deleteAllScreenshots() return true end
45
85
 
46
86
  ---@type Media