uTools
Dev Docs: https://www.u.tools/docs/developer/welcome.html
Questions
- How does uTools render UI?
- How does uTools allow plugins to access system API?
Manifest
main
is the entry point.features
is a list of featuresfeatures.code
id code to distinguish featuresfeatures.cmds
: command list to trigger the feature (中文会自动支持 拼音及拼音首字母,无须重复添加)
"platform": ["win32", "darwin", "linux"]
optional
Dev
The dev tools provided by uTools can load plugin for testing and bundle into .ups
file which can be installed and shared. Like Alfred's workflow file.
Example: https://github.com/uTools-Labs/utools-tutorials/tree/main/utools-helloworld-example
Doc: https://www.u.tools/docs/developer/debug.html
Set main
to a local url for development to achieve hot reload.
preload.js
https://www.u.tools/docs/developer/preload.html
当你在
plugin.json
中配置了preload
属性,将载入对应的预加载脚本。在传统的 web 开发中,所有的 javascript 脚本都在浏览器沙盒中运行,权限被严格限制,所能实现的功能非常有限。
通过
preload.js
能够帮你突破沙盒限制,进入一个崭新的 JavaScript 世界。
preload.js
is used to preload script and bypass sandbox limitation.
preload.js
can access nodejs
, electron
, uTools
API. APIs can be plugged into window
object so that other JS code can access these APIs.
window.services.readFile
get's access to read files beyond the constraint by sandbox.
Use Third Party Packages
通过源码方式使用第三方库
Through source code
Download the library into /public
uTools API
This is a wrapper for some common functions.
在插件应用初始化完成时,uTools 会自动在你的 window 对象上挂载 utools 对象。
uTools DB API
Data persistance.
uTools Browser API
uTools browser 简称 ubrowser,是根据 uTools 的特性,量身打造的一个可编程浏览器。利用 ubrowser 可以轻而易举连接一切互联网服务,且与 uTools 完美结合。
ubrowser 拥有优雅的链式调用接口,可以用口语化的数行代码,实现一系列匪夷所思的操作。例如:
-
RPA 自动化脚本
-
网页魔改
-
网页抓取
This is interesting. This should be very simple. The browser window is loaded in a electron window, the API is just a wrapper around DOM APIs.
There is also setCookies(cookies)
and removeCookies(name)
API.
evaluate(func, ...params)
allows developers to eval JS function.
uTools Server API
通过 uTools 的服务端 API,可以将你的应用和 uTools 用户关联,实现帐号互通、接收支付通知、查询用户支付记录等,为保护密钥安全,请仅在服务端调用接口。
APIs for account and payment. Regular API wrapper for web requests, skip.
注意事项
- uTools 插件应用中不受跨域影响,可以访问任意网址。
- 无需网页考虑兼容性问题,基于(Chromium 91 和 Node 14)
- 在插件应用开发模式中,可以使用 http 协议加载远程资源( js、css )。当打包成 uTools 插件应用后,所有的静态资源都应该在包内,否则会加载失败。
- 在打包目录中,请勿包含
.git
.js.map
.css.map
文件。
App Storage
On Mac, the app data is stored in /Users/<user>/Library/Application Support/uTools
.
Clipboard data stored in clipboard-data/1715136702505/data
. The number is the timestamp.
In the data
file, there is encoded (and potentially encrypted clipboard data).
Here is the tree structure with 2 layers of folders.
WASM is used, node addons are used. The app is built on Electron.
How is this guide?