BT编程语言文档
bt_app 快速开始
纯 HTML 项目
在空目录创建
index.html:
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>Hello BT App</title>
</head>
<body>
<h1>Hello BT App</h1>
</body>
</html>
在该目录运行:
bt_app.exe run
也可以直接双击
bt_app.exe,前提是当前工作目录就是项目目录。
app.json 项目
创建
app.json:
{
"app": {
"name": "HelloApp",
"title": "Hello BT App",
"mode": "static",
"entry": "index.html",
"main": "main.bt",
"devtools": true,
"console": true
},
"window": {
"width": 900,
"height": 700,
"resizable": true
},
"resources": [
"index.html",
"main.bt",
"assets/**"
]
}
创建
main.bt:
fn hello(name) {
return {
error:false,
message:'ok',
data:'Hello ' + name
}
}
在页面中调用:
<button id="btn">调用 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>
打包
在项目目录运行:
bt_app.exe build
打包结果输出到:
dist/HelloApp.exe
注意事项
-
static 模式下 entry 必须是项目内相对路径。
-
server 和 remote 模式下 entry 必须是 http:// 或 https:// 地址。
-
app.main 省略、true 或 null 时会自动尝试执行 main.bt;写成 false 或空字符串表示不执行主脚本。
- 当前
app.icon 只支持项目内 .ico 文件。