bt_app Quick Start
bt_app Quick Start
Pure HTML project
Create index.html in an empty directory:
<!doctype html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> </head> <body> <h1>Hello BT App</h1> </body> </html>
Run in this directory:
./bt_app.exe run
When running for the first time, if there is no app.json in the directory, bt_app will automatically generate the default app.json and add it if it is missing Creates an empty main.bt when using main.bt. Configurations such as window title, size, entry, and resources are subject to app.json.
You can also double-click bt_app.exe directly, provided that the current working directory is the project directory.
app.json project
creates app.json:
{ "app": { "id": "org.example.hello_app", "name": "HelloApp", "title": "Hello BT App", "mode": "static", "entry": "index.html", "main": "main.bt" }, "window": { "width": 900, "height": 700, "resizable": true }, "dev": { "watch": true, "delay": 500, "devtools": true, "console": true }, "resources": [ "index.html", "main.bt", "assets/**" ], "exclude": [] }
creates main.bt:
fn hello(args) { return { error:false, message:'ok', data:'Hello ' + args.name } }
calls in the page:
<button id="btn">Call BT</button> <pre id="out"></pre> <script> document.getElementById('btn').onclick = async () => { const result = await window.bt.call('hello', { name: 'BT' }); document.getElementById('out').textContent = JSON.stringify(result, null, 2); }; </script>
Packages
runs in the project directory:
./bt_app.exe build
packaging results are output to:
dist/HelloApp.exe
if the user machine is installed bt_app, you can also generate only BTR software without runtime:
./bt_app.exe pack ./bt_app.exe run ./dist/HelloApp.btr
Windows can execute bt_app.exe associate once to establish the .btr file association of the current user, and then double-click BTR directly. Adding PATH only facilitates command line search and will not automatically establish file associations.
Notes
- In
staticmode,entrymust be a relative path within the project.
server and remote modes entry must be the http:// or https:// address.
- When
app.main,trueornullis omitted, it will automatically try to executemain.bt; writingfalseor an empty string means not to execute the main script. - Currently
app.icononly supports.icofiles within the project.
app.id; do not modify it for name changes after release.
-
index.htmlno longer provides application configuration; please writeresourcesfor styles, scripts and images that need to be packaged. - When the development directory is running, the page will be automatically refreshed after the files in
resources - excludeare saved; you can also pressF5,Ctrl+RorCmd+Rto refresh manually.