diff --git a/FAQ.md b/FAQ.md index 9c7f6782..4dc49191 100644 --- a/FAQ.md +++ b/FAQ.md @@ -344,8 +344,8 @@ send(EVENT_NAMES.inited, { ``` -- `@name `:源的名字,建议不要过长,10个字符以内 -- `@description `:源的描述,建议不要过长,20个字符以内,可不填,不填时必须保留 @description +- `@name `:源的名字,建议不要过长,24个字符以内 +- `@description `:源的描述,建议不要过长,36个字符以内,可不填,不填时必须保留 @description - `@version`:源的版本号,可不填,不填时可以删除 @version - `@author `:脚本作者名字,可不填,不填时可以删除 @author - `@homepage `:脚本主页,可不填,不填时可以删除 @homepage @@ -354,6 +354,10 @@ send(EVENT_NAMES.inited, { 应用为脚本暴露的API对象。 +#### `window.lx.version` + +自定义源API版本,API变更时此版本号将会更改(新增于v1.14.0之后) + #### `window.lx.EVENT_NAMES` 常量事件名称对象,发送、注册事件时传入事件名时使用,可用值: @@ -409,6 +413,7 @@ const cancelHttp = window.lx.request(url, options, callback) 应用提供给脚本的工具方法: - `window.lx.utils.buffer.from`:对应Node.js的 `Buffer.from` +- `window.lx.utils.buffer.bufToString`:Buffer转字符串 `bufToString(buffer, format)`,`format`对应Node.js `Buffer.toString`的参数(v1.14.0之后新增) - `window.lx.utils.crypto.aesEncrypt`:AES加密 `aesEncrypt(buffer, mode, key, iv)` - `window.lx.utils.crypto.md5`:MD5加密 `md5(str)` - `window.lx.utils.crypto.randomBytes`:生成随机字符串 `randomBytes(size)` diff --git a/publish/changeLog.md b/publish/changeLog.md index 910772a1..e3967bd7 100644 --- a/publish/changeLog.md +++ b/publish/changeLog.md @@ -1,3 +1,7 @@ +### 新增 + +- 自定义源新增`version`字段,新增`utils.buffer.bufToString`方法 + ### 优化 - 优化列表同步代码逻辑 diff --git a/src/main/modules/userApi/renderer/preload.js b/src/main/modules/userApi/renderer/preload.js index 253914af..8e520e4c 100644 --- a/src/main/modules/userApi/renderer/preload.js +++ b/src/main/modules/userApi/renderer/preload.js @@ -185,7 +185,7 @@ contextBridge.exposeInMainWorld('lx', { utils: { crypto: { aesEncrypt(buffer, mode, key, iv) { - const cipher = createCipheriv('aes-128-' + mode, key, iv) + const cipher = createCipheriv(mode, key, iv) return Buffer.concat([cipher.update(buffer), cipher.final()]) }, rsaEncrypt(buffer, key) { @@ -203,8 +203,12 @@ contextBridge.exposeInMainWorld('lx', { from(...args) { return Buffer.from(...args) }, + bufToString(buf, format) { + return Buffer.from(buf, 'binary').toString(format) + }, }, }, + version: '1.1.0', // removeEvent(eventName, handler) { // if (!eventNames.includes(eventName)) return Promise.reject(new Error('The event is not supported: ' + eventName)) // let handlers