ms-vite-plugin 1.5.12 → 1.5.14

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.
Files changed (61) hide show
  1. package/dist/build/luaBundle.js +2 -2
  2. package/dist/build/scriptProtect.js +2 -2
  3. package/docs/api/ai.md +16 -16
  4. package/docs/api/config.md +3 -3
  5. package/docs/api/dotocr.md +2 -2
  6. package/docs/api/file.md +18 -18
  7. package/docs/api/hid.md +2 -2
  8. package/docs/api/hotUpdate.md +2 -2
  9. package/docs/api/http.md +4 -4
  10. package/docs/api/image.md +15 -15
  11. package/docs/api/jbclear.md +12 -12
  12. package/docs/api/jbdevice.md +25 -25
  13. package/docs/api/jbdraw.md +139 -0
  14. package/docs/api/jbdylib.md +6 -6
  15. package/docs/api/jbpower.md +134 -0
  16. package/docs/api/jbshell.md +2 -2
  17. package/docs/api/jbsystem.md +6 -6
  18. package/docs/api/jbvpn.md +7 -7
  19. package/docs/api/mysql.md +4 -4
  20. package/docs/api/netCard.md +4 -73
  21. package/docs/api/node.md +5 -3
  22. package/docs/api/opencv.md +116 -116
  23. package/docs/api/plist.md +2 -2
  24. package/docs/api/sqlite.md +231 -0
  25. package/docs/api/system.md +1 -1
  26. package/docs/api/thread.md +2 -2
  27. package/docs/api/tomatoocr.md +2 -2
  28. package/docs/api/yolo.md +2 -2
  29. package/docs/api/yolocls.md +6 -6
  30. package/docs/api/zipFile.md +113 -0
  31. package/docs/apicn/ai.md +16 -16
  32. package/docs/apicn/config.md +2 -2
  33. package/docs/apicn/dotocr.md +2 -2
  34. package/docs/apicn/file.md +16 -16
  35. package/docs/apicn/hid.md +4 -4
  36. package/docs/apicn/hotUpdate.md +2 -2
  37. package/docs/apicn/http.md +4 -4
  38. package/docs/apicn/image.md +13 -13
  39. package/docs/apicn/mysql.md +4 -4
  40. package/docs/apicn/netCard.md +4 -73
  41. package/docs/apicn/node.md +5 -3
  42. package/docs/apicn/sqlite.md +197 -0
  43. package/docs/apicn/system.md +3 -3
  44. package/docs/apicn/thread.md +2 -2
  45. package/docs/apicn/yolo.md +2 -2
  46. package/docs/apicn/yolocls.md +6 -6
  47. package/docs/apicn/zipFile.md +113 -0
  48. package/docs/apilua/jbdraw.md +141 -0
  49. package/docs/apilua/jbpower.md +136 -0
  50. package/docs/apilua/netCard.md +3 -77
  51. package/docs/apilua/node.md +3 -1
  52. package/docs/apilua/sqlite.md +204 -0
  53. package/docs/apilua/zipFile.md +123 -0
  54. package/docs/apipython/jbdraw.md +147 -0
  55. package/docs/apipython/jbpower.md +133 -0
  56. package/docs/apipython/netCard.md +3 -74
  57. package/docs/apipython/node.md +3 -1
  58. package/docs/apipython/overview.md +1 -1
  59. package/docs/apipython/sqlite.md +181 -0
  60. package/docs/apipython/zipFile.md +117 -0
  61. package/package.json +1 -1
@@ -0,0 +1,204 @@
1
+ # SQLite 数据库模块 (SQLite)
2
+
3
+ 模块表是内置全局 `sqlite`,直接调用即可。不要 `require` 宿主模块。
4
+
5
+ SQLite 模块提供本地数据库文件的打开、查询、执行和事务。可以同时打开多个库,每个库用 `open` 返回的句柄操作。
6
+
7
+ ## 功能概览
8
+
9
+ - **多库句柄**: `open` 返回句柄,后续方法把句柄作为第一个参数
10
+ - **数据查询**: 执行 SELECT 查询
11
+ - **数据更新**: 执行 CREATE、INSERT、UPDATE、DELETE
12
+ - **事务支持**: `beginTransaction` / `commit` / `rollback`
13
+ - **参数绑定**: 使用 `?` 占位,防止 SQL 注入
14
+
15
+ ## 注意事项
16
+
17
+ 1. **文件路径**: 路径必须是绝对路径,与 `file` 模块相同。相对路径会打开失败。
18
+ 2. **内存库**: 路径传 `":memory:"` 打开内存数据库。
19
+ 3. **句柄**: 先 `open` 再查询;脚本结束会关闭本次运行打开的全部句柄,仍建议用完 `close`。
20
+ 4. **BLOB**: 第一版不把 BLOB 转成字符串,读到的该格为 `nil`。
21
+ 5. **锁定等待**: 数据库被占用时最多等待 5 秒。
22
+
23
+ ## 类型定义
24
+
25
+ ### SqliteResult
26
+
27
+ 查询 / 执行结果。
28
+
29
+ ```lua
30
+ ---@class SqliteResult
31
+ ---@field rows table[]
32
+ ---@field affectedRows number
33
+ ---@field insertId number
34
+ ---@field success boolean
35
+ ---@field error string
36
+ ```
37
+
38
+ **数据类型说明:**
39
+
40
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
41
+ | -------------- | ------ | -------- | ------ | ---------------------------- |
42
+ | `rows` | table[] | 否 | | 查询结果数据行 |
43
+ | `affectedRows` | number | 否 | | 受影响的行数 |
44
+ | `insertId` | number | 否 | | 本次连接最近一次插入的 rowid |
45
+ | `success` | boolean | 否 | | 是否成功 |
46
+ | `error` | string | 否 | | 错误信息 |
47
+
48
+ ## API 参考
49
+
50
+ ### 连接管理
51
+
52
+ #### open - 打开数据库
53
+
54
+ ```lua
55
+ ---@param path string
56
+ ---@return string|nil
57
+ function open(path) end
58
+ ```
59
+
60
+ **参数:**
61
+
62
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
63
+ | ------ | ------ | -------- | ------ | ------------------------- |
64
+ | `path` | string | 是 | | 绝对路径,或 `":memory:"` |
65
+
66
+ **返回值:**
67
+
68
+ | 类型 | 描述 |
69
+ | ------------- | -------------------------- |
70
+ | `string\|nil` | 成功返回句柄,失败返回 `nil` |
71
+
72
+ **示例:**
73
+
74
+ ```lua
75
+ local path = file.getInternalDir("documents") .. "/app.db"
76
+ local db = sqlite.open(path)
77
+ if not db then
78
+ print("打开失败")
79
+ end
80
+ ```
81
+
82
+ #### close - 关闭数据库
83
+
84
+ ```lua
85
+ ---@param handle string
86
+ function close(handle) end
87
+ ```
88
+
89
+ **示例:**
90
+
91
+ ```lua
92
+ sqlite.close(db)
93
+ ```
94
+
95
+ #### isOpen - 检查句柄是否仍打开
96
+
97
+ ```lua
98
+ ---@param handle string
99
+ ---@return boolean
100
+ function isOpen(handle) end
101
+ ```
102
+
103
+ **示例:**
104
+
105
+ ```lua
106
+ if sqlite.isOpen(db) then
107
+ print("数据库已打开")
108
+ end
109
+ ```
110
+
111
+ ### 数据操作
112
+
113
+ #### query - 执行查询
114
+
115
+ ```lua
116
+ ---@param handle string
117
+ ---@param sql string
118
+ ---@param params any[]|nil
119
+ ---@return SqliteResult
120
+ function query(handle, sql, params) end
121
+ ```
122
+
123
+ **示例:**
124
+
125
+ ```lua
126
+ local result = sqlite.query(db, "SELECT * FROM t WHERE id = ?", {1})
127
+ if result.success then
128
+ print("查询到 " .. tostring(#result.rows) .. " 条记录")
129
+ else
130
+ print("查询失败: " .. tostring(result.error))
131
+ end
132
+ ```
133
+
134
+ #### execute - 执行更新
135
+
136
+ ```lua
137
+ ---@param handle string
138
+ ---@param sql string
139
+ ---@param params any[]|nil
140
+ ---@return SqliteResult
141
+ function execute(handle, sql, params) end
142
+ ```
143
+
144
+ **示例:**
145
+
146
+ ```lua
147
+ sqlite.execute(db, [[
148
+ CREATE TABLE IF NOT EXISTS t (
149
+ id INTEGER PRIMARY KEY,
150
+ name TEXT
151
+ )
152
+ ]])
153
+ local insertResult = sqlite.execute(db, "INSERT INTO t(name) VALUES (?)", {"a"})
154
+ if insertResult.success then
155
+ print("插入 ID: " .. tostring(insertResult.insertId))
156
+ end
157
+ ```
158
+
159
+ ### 事务管理
160
+
161
+ #### beginTransaction / commit / rollback
162
+
163
+ ```lua
164
+ ---@param handle string
165
+ ---@return boolean
166
+ function beginTransaction(handle) end
167
+
168
+ ---@param handle string
169
+ ---@return boolean
170
+ function commit(handle) end
171
+
172
+ ---@param handle string
173
+ ---@return boolean
174
+ function rollback(handle) end
175
+ ```
176
+
177
+ **示例:**
178
+
179
+ ```lua
180
+ if sqlite.beginTransaction(db) then
181
+ sqlite.execute(db, "INSERT INTO t(name) VALUES (?)", {"a"})
182
+ sqlite.execute(db, "INSERT INTO t(name) VALUES (?)", {"b"})
183
+ if not sqlite.commit(db) then
184
+ sqlite.rollback(db)
185
+ end
186
+ end
187
+ ```
188
+
189
+ ## 完整使用示例
190
+
191
+ ```lua
192
+ local db = sqlite.open(file.getInternalDir("documents") .. "/app.db")
193
+ if not db then
194
+ print("打开失败")
195
+ else
196
+ sqlite.execute(db, "CREATE TABLE IF NOT EXISTS t (id INTEGER PRIMARY KEY, name TEXT)")
197
+ sqlite.execute(db, "INSERT INTO t(name) VALUES (?)", {"a"})
198
+ local r = sqlite.query(db, "SELECT * FROM t WHERE id = ?", {1})
199
+ if r.success then
200
+ print(ToJsonString(r.rows))
201
+ end
202
+ sqlite.close(db)
203
+ end
204
+ ```
@@ -0,0 +1,123 @@
1
+ # ZIP 模块 (zipFile)
2
+
3
+ 模块表是内置全局 `zipFile`,直接调用即可。不要 `require` 宿主模块。路径必须是绝对路径。`zip` 只接受目录,不接受文件。
4
+
5
+ ## API 参考
6
+
7
+ ### getFileList - 获取 ZIP 内部文件列表。
8
+
9
+ ```lua
10
+ ---@param path string
11
+ ---@return string[]
12
+ function getFileList(path) end
13
+ ```
14
+
15
+ **参数:**
16
+
17
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
18
+ | ------ | -------- | -------- | ------ | ---------------- |
19
+ | `path` | `string` | 是 | - | ZIP 文件绝对路径 |
20
+
21
+ **返回值:**
22
+
23
+ | 类型 | 描述 |
24
+ | ---------- | ------------------------------------------------------------ |
25
+ | `string[]` | 包内文件路径;不含目录项。不是合法 ZIP 时返回空表 |
26
+
27
+ **示例:**
28
+
29
+ ```lua
30
+ local path = file.getInternalDir("documents") .. "/a.zip"
31
+ local names = zipFile.getFileList(path)
32
+ ```
33
+
34
+ ### isZip - 检查是否为合法 ZIP。
35
+
36
+ ```lua
37
+ ---@param path string
38
+ ---@return boolean
39
+ function isZip(path) end
40
+ ```
41
+
42
+ **参数:**
43
+
44
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
45
+ | ------ | -------- | -------- | ------ | ------------ |
46
+ | `path` | `string` | 是 | - | 文件绝对路径 |
47
+
48
+ **返回值:**
49
+
50
+ | 类型 | 描述 |
51
+ | --------- | ------------------------- |
52
+ | `boolean` | 能作为 ZIP 打开为 `true` |
53
+
54
+ **示例:**
55
+
56
+ ```lua
57
+ local path = file.getInternalDir("documents") .. "/a.zip"
58
+ if zipFile.isZip(path) then
59
+ print("是 ZIP")
60
+ end
61
+ ```
62
+
63
+ ### unzip - 解压到指定目录。
64
+
65
+ 目标目录不存在会创建。包内路径必须落在目标目录内,否则失败。
66
+
67
+ ```lua
68
+ ---@param zipPath string
69
+ ---@param destDir string
70
+ ---@return boolean
71
+ function unzip(zipPath, destDir) end
72
+ ```
73
+
74
+ **参数:**
75
+
76
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
77
+ | --------- | -------- | -------- | ------ | -------------------- |
78
+ | `zipPath` | `string` | 是 | - | ZIP 文件绝对路径 |
79
+ | `destDir` | `string` | 是 | - | 解压目标目录绝对路径 |
80
+
81
+ **返回值:**
82
+
83
+ | 类型 | 描述 |
84
+ | --------- | ----------------- |
85
+ | `boolean` | 解压成功为 `true` |
86
+
87
+ **示例:**
88
+
89
+ ```lua
90
+ local dir = file.getInternalDir("documents")
91
+ zipFile.unzip(dir .. "/a.zip", dir .. "/out")
92
+ ```
93
+
94
+ ### zip - 压缩目录为 ZIP。
95
+
96
+ 包内根条目是该目录名。已有同名 ZIP 文件会先删再写。源路径必须是目录,不能是文件。输出 ZIP 不能落在源目录内。
97
+
98
+ ```lua
99
+ ---@param dirPath string
100
+ ---@param zipPath string
101
+ ---@return boolean
102
+ function zip(dirPath, zipPath) end
103
+ ```
104
+
105
+ **参数:**
106
+
107
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
108
+ | --------- | -------- | -------- | ------ | ----------------------------------- |
109
+ | `dirPath` | `string` | 是 | - | 要压缩的目录绝对路径 |
110
+ | `zipPath` | `string` | 是 | - | 输出 ZIP 绝对路径,不能落在源目录内 |
111
+
112
+ **返回值:**
113
+
114
+ | 类型 | 描述 |
115
+ | --------- | ----------------- |
116
+ | `boolean` | 压缩成功为 `true` |
117
+
118
+ **示例:**
119
+
120
+ ```lua
121
+ local dir = file.getInternalDir("documents")
122
+ zipFile.zip(dir .. "/out", dir .. "/out.zip")
123
+ ```
@@ -0,0 +1,147 @@
1
+ # 绘制模块 (JBDraw)
2
+
3
+ 仅越狱包可用。免越狱包没有 `jbdraw`。
4
+
5
+ 在屏幕上画矩形和文字。每画一次返回一个 id,可用 `clear` 去掉这一条,或 `clearAll` 全部去掉。坐标为像素坐标。
6
+
7
+ 颜色只接受 `#RRGGBB` 和 `#RRGGBBAA`。需要字加底时先画填充矩形,再画文字。
8
+
9
+ ## 类型
10
+
11
+ ```python
12
+ from typing import Optional, TypedDict
13
+
14
+ class JbDrawRectOptions(TypedDict, total=False):
15
+ color: str
16
+ lineWidth: float
17
+ fill: str
18
+
19
+ class JbDrawTextOptions(TypedDict, total=False):
20
+ color: str
21
+ fontSize: float
22
+ ```
23
+
24
+ | 字段 | 类型 | 描述 |
25
+ | ----------- | ----- | ------------------------------------------------------------ |
26
+ | `color` | str | `#RRGGBB` 或 `#RRGGBBAA`。矩形默认 `#FF0000`,文字默认 `#FFFFFF` |
27
+ | `lineWidth` | float | 边框宽度。省略为 `2`。`<= 0` 不画边框 |
28
+ | `fill` | str | 填充颜色,同 `color` 格式。省略不填充 |
29
+ | `fontSize` | float | 系统字号。省略为 `16`。`<= 0` 时画字失败 |
30
+
31
+ ## API 参考
32
+
33
+ ### rect - 在屏幕上画矩形。
34
+
35
+ 需要字加底时先画填充矩形,再 `text`。
36
+
37
+ ```python
38
+ def rect(
39
+ x: float,
40
+ y: float,
41
+ width: float,
42
+ height: float,
43
+ options: Optional[JbDrawRectOptions] = None,
44
+ ) -> int
45
+ ```
46
+
47
+ **参数:**
48
+
49
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
50
+ | --------- | ----------------- | -------- | ------ | ---------------------------------- |
51
+ | `x` | float | 是 | - | 左上角 x,像素坐标 |
52
+ | `y` | float | 是 | - | 左上角 y,像素坐标 |
53
+ | `width` | float | 是 | - | 宽度,必须大于 0 |
54
+ | `height` | float | 是 | - | 高度,必须大于 0 |
55
+ | `options` | JbDrawRectOptions | 否 | - | 颜色、边框、填充 |
56
+
57
+ **返回值:**
58
+
59
+ | 类型 | 描述 |
60
+ | ---- | ------------------------------ |
61
+ | `int` | 成功为 id(从 1 起);失败为 `0` |
62
+
63
+ **示例:**
64
+
65
+ ```python
66
+ from kuaijs import jbdraw
67
+
68
+ box = jbdraw.rect(20, 80, 200, 40, {"fill": "#000000AA", "lineWidth": 0})
69
+ frame = jbdraw.rect(20, 140, 120, 80, {"color": "#FF0000", "lineWidth": 2})
70
+ ```
71
+
72
+ ### text - 在屏幕上画文字。
73
+
74
+ 左上角对齐,没有背景。
75
+
76
+ ```python
77
+ def text(
78
+ x: float,
79
+ y: float,
80
+ text: str,
81
+ options: Optional[JbDrawTextOptions] = None,
82
+ ) -> int
83
+ ```
84
+
85
+ **参数:**
86
+
87
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
88
+ | --------- | ----------------- | -------- | ------ | ---------------------------------- |
89
+ | `x` | float | 是 | - | 文字左上角 x,像素坐标 |
90
+ | `y` | float | 是 | - | 文字左上角 y,像素坐标 |
91
+ | `text` | str | 是 | - | 要画的字符串 |
92
+ | `options` | JbDrawTextOptions | 否 | - | 颜色和字号 |
93
+
94
+ **返回值:**
95
+
96
+ | 类型 | 描述 |
97
+ | ---- | ------------------------------ |
98
+ | `int` | 成功为 id(从 1 起);失败为 `0` |
99
+
100
+ **示例:**
101
+
102
+ ```python
103
+ from kuaijs import jbdraw
104
+
105
+ box = jbdraw.rect(20, 80, 200, 40, {"fill": "#000000AA", "lineWidth": 0})
106
+ label = jbdraw.text(28, 88, "hello", {"color": "#FFFFFF", "fontSize": 18})
107
+ ```
108
+
109
+ ### clear - 去掉一个图形。
110
+
111
+ ```python
112
+ def clear(id: int) -> bool
113
+ ```
114
+
115
+ **参数:**
116
+
117
+ | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
118
+ | ------ | ---- | -------- | ------ | ------------------------ |
119
+ | `id` | int | 是 | - | `rect` / `text` 返回的 id |
120
+
121
+ **返回值:**
122
+
123
+ | 类型 | 描述 |
124
+ | ---- | ------------------- |
125
+ | `bool` | 找到并移除为 `True` |
126
+
127
+ **示例:**
128
+
129
+ ```python
130
+ from kuaijs import jbdraw
131
+
132
+ jbdraw.clear(label)
133
+ ```
134
+
135
+ ### clearAll - 去掉当前全部图形。
136
+
137
+ ```python
138
+ def clearAll() -> None
139
+ ```
140
+
141
+ **示例:**
142
+
143
+ ```python
144
+ from kuaijs import jbdraw
145
+
146
+ jbdraw.clearAll()
147
+ ```
@@ -0,0 +1,133 @@
1
+ # 电源模块 (JBPower)
2
+
3
+ 仅越狱包可用。免越狱包没有 `jbpower`。
4
+
5
+ `info` 读取电量百分比、电流、电压和充电状态。`stopCharging` 停止充电并保持,直到调用 `startCharging`。`setSmartCharging` 到上限停止充电,降到下限再充,中间保持。
6
+
7
+ 电流单位是毫安,正数表示正在进电。电压单位是毫伏。
8
+
9
+ ## API 参考
10
+
11
+ ### info - 读取当前电源信息。
12
+
13
+ ```python
14
+ def info() -> Optional[PowerInfo]
15
+ ```
16
+
17
+ **返回值:**
18
+
19
+ | 类型 | 描述 |
20
+ | --------------------- | -------------------- |
21
+ | `PowerInfo` | 读到电池时的电源信息 |
22
+ | `None` | 读不到电池 |
23
+
24
+ `PowerInfo` 字段:
25
+
26
+ | 字段 | 类型 | 描述 |
27
+ | -------------------- | ------ | ------------------------------------------------- |
28
+ | `percentage` | `int` | 电量百分比 |
29
+ | `amperage` | `int` | 电流,单位毫安,正数表示正在进电 |
30
+ | `voltage` | `int` | 电压,单位毫伏 |
31
+ | `charging` | `bool` | 系统是否认为正在充电 |
32
+ | `plugged` | `bool` | 电源状态是否为交流电 |
33
+ | `powerState` | `str` | `AC Power` 或 `Battery Power` |
34
+ | `rawExternal` | `bool` | 发布出去的外接位 |
35
+ | `showChargingUI` | `bool` | 主屏是否显示充电 |
36
+ | `appleRawExternal` | `bool` | 硬件是否还认这根线 |
37
+ | `chargeOverride` | `bool` | 系统自己的停充覆盖 |
38
+ | `adapterWatts` | `int` | 适配器功率,单位瓦,读不到时为 0 |
39
+
40
+ **示例:**
41
+
42
+ ```python
43
+ power = jbpower.info()
44
+ if power:
45
+ logd(power.percentage, power.amperage)
46
+ ```
47
+
48
+ ### stopCharging - 停止充电。
49
+
50
+ 停止后会保持,直到 `startCharging`。
51
+
52
+ ```python
53
+ def stopCharging() -> bool
54
+ ```
55
+
56
+ **返回值:**
57
+
58
+ | 类型 | 描述 |
59
+ | ------ | ----------------- |
60
+ | `bool` | 写入成功为 `True` |
61
+
62
+ **示例:**
63
+
64
+ ```python
65
+ jbpower.stopCharging()
66
+ ```
67
+
68
+ ### startCharging - 恢复充电。
69
+
70
+ ```python
71
+ def startCharging() -> bool
72
+ ```
73
+
74
+ **返回值:**
75
+
76
+ | 类型 | 描述 |
77
+ | ------ | ----------------- |
78
+ | `bool` | 写入成功为 `True` |
79
+
80
+ **示例:**
81
+
82
+ ```python
83
+ jbpower.startCharging()
84
+ ```
85
+
86
+ ### setSmartCharging - 打开智能充电。
87
+
88
+ 电量到 `max` 停止充电,降到 `min` 再充。窗口中间保持上次的决定,不会在停充和充电之间来回切。
89
+
90
+ 上限会收到 2 到 100,下限至少为 1,并且必须小于上限。
91
+
92
+ ```python
93
+ def setSmartCharging(min: int, max: int) -> bool
94
+ ```
95
+
96
+ **参数:**
97
+
98
+ | 参数 | 类型 | 描述 |
99
+ | ----- | ----- | ---------------- |
100
+ | `min` | `int` | 再充下限,百分比 |
101
+ | `max` | `int` | 停充上限,百分比 |
102
+
103
+ **返回值:**
104
+
105
+ | 类型 | 描述 |
106
+ | ------ | ----------------- |
107
+ | `bool` | 保存成功为 `True` |
108
+
109
+ **示例:**
110
+
111
+ ```python
112
+ jbpower.setSmartCharging(20, 80)
113
+ ```
114
+
115
+ ### clearSmartCharging - 关掉智能充电。
116
+
117
+ 如果当前正按窗口停充,会恢复充电。
118
+
119
+ ```python
120
+ def clearSmartCharging() -> bool
121
+ ```
122
+
123
+ **返回值:**
124
+
125
+ | 类型 | 描述 |
126
+ | ------ | ----------------- |
127
+ | `bool` | 保存成功为 `True` |
128
+
129
+ **示例:**
130
+
131
+ ```python
132
+ jbpower.clearSmartCharging()
133
+ ```
@@ -1,17 +1,16 @@
1
1
  # 卡密模块 (NetCard)
2
2
 
3
- 卡密模块提供了卡密验证、备注设置以及键值对存储功能,用于管理网络卡密相关的操作。
3
+ 卡密模块提供了卡密验证和备注设置功能,用于管理网络卡密相关的操作。
4
4
 
5
5
  ## 功能概览
6
6
 
7
7
  - **卡密验证**: 验证卡密的有效性
8
8
  - **备注管理**: 设置和管理卡密备注信息
9
- - **云变量存储**: 提供键值对形式的数据存储和读取功能
10
9
 
11
10
  ## 注意事项
12
11
 
13
12
  1. **卡密安全**: 卡密信息应当妥善保管,避免在日志中明文输出
14
- 2. **普通卡密模式**: 需要先调用 `netcard.verify(cardNo)` 验证卡密,验证通过后才能调用获取卡密信息、备注和云变量等接口
13
+ 2. **普通卡密模式**: 需要先调用 `netcard.verify(cardNo)` 验证卡密,验证通过后才能调用获取卡密信息和备注等接口
15
14
  3. **授权卡密模式**: App 打开加密 UI 或运行脚本前会完成授权和卡密验证,脚本中不需要重复让用户输入卡密,也不需要重复调用 `netcard.verify`
16
15
  4. **兼容旧脚本**: 授权卡密模式下调用 `netcard.verify` 会直接返回 `True`,用于兼容原来已经写了 `verify` 的脚本
17
16
 
@@ -74,7 +73,7 @@ def verify(cardNo: str) -> bool
74
73
 
75
74
  **说明:**
76
75
 
77
- 普通卡密模式下,该方法会请求普通卡密验证接口,验证成功后才能继续使用卡密信息、备注和云变量相关能力。
76
+ 普通卡密模式下,该方法会请求普通卡密验证接口,验证成功后才能继续使用卡密信息和备注相关能力。
78
77
 
79
78
  授权卡密模式下,App 层已经完成授权和卡密验证,脚本侧不需要重复调用该方法;如果旧脚本仍然调用,方法会直接返回 `True`。
80
79
 
@@ -186,73 +185,3 @@ if success:
186
185
  else:
187
186
  logger.error("备注设置失败")
188
187
  ```
189
-
190
- ### 云变量
191
-
192
- #### setValue - 设置键值对
193
-
194
- ```python
195
- def setValue(key: str, value: str) -> str
196
- ```
197
-
198
- **参数说明:**
199
-
200
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
201
- | ------- | ---- | -------- | ------ | ---------- |
202
- | `key` | str | 是 | | 存储的键名 |
203
- | `value` | str | 是 | | 存储的值 |
204
-
205
- **返回值:**
206
-
207
- | 类型 | 描述 |
208
- | ----- | --------------------------------------------- |
209
- | `str` | 成功时返回设置的 value 值,失败时返回空字符串 |
210
-
211
- **示例:**
212
-
213
- ```python
214
- from kuaijs import netcard, logger
215
-
216
- # 设置键值对
217
- key = "userConfig"
218
- value = "enableNotification"
219
- result = netcard.setValue(key, value)
220
-
221
- if result == value:
222
- logger.info(f"成功设置 {key}: {value}")
223
- else:
224
- logger.error("设置失败")
225
- ```
226
-
227
- #### getValue - 获取键值对
228
-
229
- ```python
230
- def getValue(key: str) -> str
231
- ```
232
-
233
- **参数说明:**
234
-
235
- | 参数名 | 类型 | 是否必填 | 默认值 | 描述 |
236
- | ------ | ---- | -------- | ------ | ------------ |
237
- | `key` | str | 是 | | 要获取的键名 |
238
-
239
- **返回值:**
240
-
241
- | 类型 | 描述 |
242
- | ----- | ------------------------------------------------ |
243
- | `str` | 成功时返回对应的值,失败或键不存在时返回空字符串 |
244
-
245
- **示例:**
246
-
247
- ```python
248
- from kuaijs import netcard, logger
249
-
250
- # 获取键值对
251
- key = "userConfig"
252
- value = netcard.getValue(key)
253
-
254
- if value:
255
- logger.info(f"获取到配置: {key} = {value}")
256
- else:
257
- logger.warn(f"配置 {key} 不存在或获取失败")
258
- ```