请确保你的计算机已经安装好了以下软件或工具。
git clone https://github.com/openblockcc/external-resources-v3.git external-resources-v3
cd external-resources-v3
npm ci
使用 powershell 或 CMD 运行 ./setup.sh
,或者直接双击脚本文件运行。
sudo ./setup.sh
由于类 Unix 系统的特殊性,执行完成后我们还需要重启系统或者注销用户重新登陆,设置的环境变量才会生效。
在脚本运行完成后,当前的资源路径就已经被设置到了系统的环境变量中了,可以被 Resource Server 扫描到了,我们可以重新打开一个新的终端来验证一下。
echo $env:OPENBLOCK_EXTERNAL_RESOURCES
echo $OPENBLOCK_EXTERNAL_RESOURCES
如果正常的话,将会输出当前资源工程的路径。
打开 ./extensions/apds9960/translations.js
文件,将 getInterfaceTranslations
函数中的所有语言的 apds9960.description
修改为一个测试数据。
function getInterfaceTranslations () {
return {
"en": {
"apds9960.description": "Test."
},
"ru": {
"apds9960.description": "Test."
},
"zh-cn": {
"apds9960.description": "Test."
},
"zh-tw": {
"apds9960.description": "Test."
}
}
;
}
而后使用命令行打开 OpenBlock,具体的命令需要根据实际情况调整路径。
/your/openblock/installation/path/OpenBlockDesktop.exe
/Application/OpenBlockDesktop.app/Content/MacOS/OpenBlockDesktop
/opt/OpenBlockDesktop/openblock-desktop
在打开的软件中选择 Arduino Uno 主板,切换到上传模式并打开插件选择界面,可以看到 APDS9960 的描述已经变成了我们修改的内容。
同时可以看到终端中显示了当前 Resource Server 使用的资源路径。(适用于v2.5.3 以上版本)
...
env OPENBLOCK_EXTERNAL_RESOURCES: "your/resource/path/OpenBlockExternalResources"
cached external resources path: "cache/path/external-resources"
builtin external resources path: "your/resource/path/OpenBlockExternalResources"
Openblock resource server start successfully, socket listen on: http://0.0.0.0:20112
...
到此我们的开发环境就搭建完成,可以进行接下来的开发了。