From 827e19b55968a51a262ae4fe458b9982152197d6 Mon Sep 17 00:00:00 2001 From: fofolee Date: Thu, 7 Apr 2022 16:08:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A3=B0=E6=98=8E=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/preload.js | 10 +- src/plugins/monaco/types/utools.api.d.ts | 270 +++++++++++------------ 2 files changed, 142 insertions(+), 138 deletions(-) diff --git a/public/preload.js b/public/preload.js index a1b4f82..d0d852e 100644 --- a/public/preload.js +++ b/public/preload.js @@ -3,7 +3,9 @@ const os = require('os'); const child_process = require("child_process") const iconv = require('iconv-lite') const electron = require('electron') -const { NodeVM } = require('./lib/vm2') +const { + NodeVM +} = require('./lib/vm2') const path = require("path") const util = require("util") const PinyinMatch = require('pinyin-match'); @@ -495,6 +497,8 @@ getuToolsLite = () => { delete utoolsLite.dbStorage delete utoolsLite.removeFeature delete utoolsLite.setFeature + delete utoolsLite.onDbPull + delete utoolsLite.getFeatures // 支付相关接口 delete utoolsLite.fetchUserServerTemporaryToken delete utoolsLite.getUserServerTemporaryToken @@ -502,7 +506,7 @@ getuToolsLite = () => { delete utoolsLite.fetchUserPayments return utoolsLite } -console.error + let getSandboxFuns = () => { var sandbox = { utools: getuToolsLite(), @@ -591,7 +595,7 @@ runCodeInVm = (cmd, cb, enterData = {}) => { }); let liteErr = e => { - return e.stack.replace(/([ ] +at.+)|(.+\.js:\d+)/g, '').trim() + return e?.stack.replace(/([ ] +at.+)|(.+\.js:\d+)/g, '').trim() } // 错误处理 diff --git a/src/plugins/monaco/types/utools.api.d.ts b/src/plugins/monaco/types/utools.api.d.ts index 43d4733..b8ea622 100644 --- a/src/plugins/monaco/types/utools.api.d.ts +++ b/src/plugins/monaco/types/utools.api.d.ts @@ -239,7 +239,7 @@ interface UToolsApi { /** * 插件从云端拉取到数据时触发 */ - onDbPull(callback: (docs: { _id: string, _rev: string }[]) => void): void; + // onDbPull(callback: (docs: { _id: string, _rev: string }[]) => void): void; /** * 隐藏主窗口 * @param isRestorePreWindow 是否焦点回归到前面的活动窗口,默认 true @@ -302,59 +302,59 @@ interface UToolsApi { /** * 获取用户服务端临时令牌 */ - fetchUserServerTemporaryToken(): Promise<{ token: string, expiredAt: number }>; + // fetchUserServerTemporaryToken(): Promise<{ token: string, expiredAt: number }>; /** * 打开支付 * @param callback 支付成功触发 */ - openPayment(options: { - /** - * 商品ID,在 “uTools 开发者工具” 插件中创建 - */ - goodsId: string, - /** - * 第三方服务生成的订单号(可选) - */ - outOrderId?: string, - /** - * 第三方服务附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用(可选) - */ - attach?: string - }, callback?: () => void): void; + // openPayment(options: { + // /** + // * 商品ID,在 “uTools 开发者工具” 插件中创建 + // */ + // goodsId: string, + // /** + // * 第三方服务生成的订单号(可选) + // */ + // outOrderId?: string, + // /** + // * 第三方服务附加数据,在查询API和支付通知中原样返回,可作为自定义参数使用(可选) + // */ + // attach?: string + // }, callback?: () => void): void; /** * 获取用户支付记录 */ - fetchUserPayments(): Promise<{ order_id: string, total_fee: number, body: string, attach: string, goods_id: string, out_order_id: string, paid_at: string }[]>; + // fetchUserPayments(): Promise<{ order_id: string, total_fee: number, body: string, attach: string, goods_id: string, out_order_id: string, paid_at: string }[]>; /** * 设置插件动态功能 */ - setFeature(feature: { - code: string, - explain: string, - platform: ('darwin' | 'win32' | 'linux') | (Array<'darwin' | 'win32' | 'linux'>), - icon?: string, - cmds: string | { - type: 'img' | 'files' | 'regex' | 'over' | 'window', - label: string - }[] - }): boolean; + // setFeature(feature: { + // code: string, + // explain: string, + // platform: ('darwin' | 'win32' | 'linux') | (Array<'darwin' | 'win32' | 'linux'>), + // icon?: string, + // cmds: string | { + // type: 'img' | 'files' | 'regex' | 'over' | 'window', + // label: string + // }[] + // }): boolean; /** * 移除插件动态功能 */ - removeFeature(code: string): boolean; + // removeFeature(code: string): boolean; /** * 获取插件所有动态功能 */ - getFeatures(): { - code: string, - explain: string, - platform: ('darwin' | 'win32' | 'linux') | (Array<'darwin' | 'win32' | 'linux'>), - icon?: string, - cmds: string | { - type: 'img' | 'files' | 'regex' | 'over' | 'window', - label: string - }[] - }[]; + // getFeatures(): { + // code: string, + // explain: string, + // platform: ('darwin' | 'win32' | 'linux') | (Array<'darwin' | 'win32' | 'linux'>), + // icon?: string, + // cmds: string | { + // type: 'img' | 'files' | 'regex' | 'over' | 'window', + // label: string + // }[] + // }[]; /** * 插件间跳转 */ @@ -544,104 +544,104 @@ interface UToolsApi { */ isLinux(): boolean; - db: { - /** - * 创建/更新文档 - */ - put(doc: DbDoc): DbReturn; - /** - * 获取文档 - */ - get(id: string): DbDoc | null; - /** - * 删除文档 - */ - remove(doc: string | DbDoc): DbReturn; - /** - * 批量操作文档(新增、修改、删除) - */ - bulkDocs(docs: DbDoc[]): DbReturn[]; - /** - * 获取所有文档 可根据文档id前缀查找 - */ - allDocs(key?: string): DbDoc[]; - /** - * 存储附件到新文档 - * @param docId 文档ID - * @param attachment 附件 buffer - * @param type 附件类型,示例:image/png, text/plain - */ - postAttachment(docId: string, attachment: Uint8Array, type: string): DbReturn; - /** - * 获取附件 - * @param docId 文档ID - */ - getAttachment(docId: string): Uint8Array | null; - /** - * 获取附件类型 - * @param docId 文档ID - */ - getAttachmentType(docId: string): string | null; - /** - * 异步 - */ - promises: { - /** - * 创建/更新文档 - */ - put(doc: DbDoc): Promise; - /** - * 获取文档 - */ - get(id: string): Promise; - /** - * 删除文档 - */ - remove(doc: string | DbDoc): Promise; - /** - * 批量操作文档(新增、修改、删除) - */ - bulkDocs(docs: DbDoc[]): Promise; - /** - * 获取所有文档 可根据文档id前缀查找 - */ - allDocs(key?: string): Promise; - /** - * 存储附件到新文档 - * @param docId 文档ID - * @param attachment 附件 buffer - * @param type 附件类型,示例:image/png, text/plain - */ - postAttachment(docId: string, attachment: Uint8Array, type: string): Promise; - /** - * 获取附件 - * @param docId 文档ID - */ - getAttachment(docId: string): Promise; - /** - * 获取附件类型 - * @param docId 文档ID - */ - getAttachmentType(docId: string): Promise; - } - }; + // db: { + // /** + // * 创建/更新文档 + // */ + // put(doc: DbDoc): DbReturn; + // /** + // * 获取文档 + // */ + // get(id: string): DbDoc | null; + // /** + // * 删除文档 + // */ + // remove(doc: string | DbDoc): DbReturn; + // /** + // * 批量操作文档(新增、修改、删除) + // */ + // bulkDocs(docs: DbDoc[]): DbReturn[]; + // /** + // * 获取所有文档 可根据文档id前缀查找 + // */ + // allDocs(key?: string): DbDoc[]; + // /** + // * 存储附件到新文档 + // * @param docId 文档ID + // * @param attachment 附件 buffer + // * @param type 附件类型,示例:image/png, text/plain + // */ + // postAttachment(docId: string, attachment: Uint8Array, type: string): DbReturn; + // /** + // * 获取附件 + // * @param docId 文档ID + // */ + // getAttachment(docId: string): Uint8Array | null; + // /** + // * 获取附件类型 + // * @param docId 文档ID + // */ + // getAttachmentType(docId: string): string | null; + // /** + // * 异步 + // */ + // promises: { + // /** + // * 创建/更新文档 + // */ + // put(doc: DbDoc): Promise; + // /** + // * 获取文档 + // */ + // get(id: string): Promise; + // /** + // * 删除文档 + // */ + // remove(doc: string | DbDoc): Promise; + // /** + // * 批量操作文档(新增、修改、删除) + // */ + // bulkDocs(docs: DbDoc[]): Promise; + // /** + // * 获取所有文档 可根据文档id前缀查找 + // */ + // allDocs(key?: string): Promise; + // /** + // * 存储附件到新文档 + // * @param docId 文档ID + // * @param attachment 附件 buffer + // * @param type 附件类型,示例:image/png, text/plain + // */ + // postAttachment(docId: string, attachment: Uint8Array, type: string): Promise; + // /** + // * 获取附件 + // * @param docId 文档ID + // */ + // getAttachment(docId: string): Promise; + // /** + // * 获取附件类型 + // * @param docId 文档ID + // */ + // getAttachmentType(docId: string): Promise; + // } + // }; - dbStorage: { - /** - * 键值对存储,如果键名存在,则更新其对应的值 - * @param key 键名(同时为文档ID) - * @param value 键值 - */ - setItem (key: string, value: any): void; - /** - * 获取键名对应的值 - */ - getItem (key: string): any; - /** - * 删除键值对(删除文档) - */ - removeItem (key: string): void; - }; + // dbStorage: { + // /** + // * 键值对存储,如果键名存在,则更新其对应的值 + // * @param key 键名(同时为文档ID) + // * @param value 键值 + // */ + // setItem (key: string, value: any): void; + // /** + // * 获取键名对应的值 + // */ + // getItem (key: string): any; + // /** + // * 删除键值对(删除文档) + // */ + // removeItem (key: string): void; + // }; ubrowser: UBrowser; }