# bt-app 快速开始 ## 纯 HTML 项目 在空目录创建 `index.html`: ```html

Hello BT App

``` 在该目录运行: ```bash ./bt-app.exe run ``` 首次运行时,如果目录中没有 `app.json`,bt-app 会自动生成默认 `app.json`,并在缺少 `main.bt` 时创建空的 `main.bt`。窗口标题、尺寸、入口、资源等配置都以 `app.json` 为准。 也可以直接双击 `bt-app.exe`,前提是当前工作目录就是项目目录。 ## app.json 项目 创建 `app.json`: ```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": [] } ``` 创建 `main.bt`: ```bt fn hello(args) { return { error:false, message:'ok', data:'Hello ' + args.name } } ``` 在页面中调用: ```html


```

## 打包
在项目目录运行:

```bash
./bt-app.exe build
```

打包结果输出到:

```text
dist/HelloApp.exe
```

如果用户机器已安装 bt-app,也可以只生成不包含运行时的 BTR 软件:

```bash
./bt-app.exe pack
./bt-app.exe run ./dist/HelloApp.btr
```

Windows 可执行一次 `bt-app.exe associate` 建立当前用户的 `.btr` 文件关联,之后直接双击 BTR。加入 `PATH` 只方便命令行查找,不会自动建立文件关联。

## 注意事项
- `static` 模式下 `entry` 必须是项目内相对路径。
- `server` 和 `remote` 模式下 `entry` 必须是 `http://` 或 `https://` 地址。
- `app.main` 省略、`true` 或 `null` 时会自动尝试执行 `main.bt`;写成 `false` 或空字符串表示不执行主脚本。
- 当前 `app.icon` 只支持项目内 `.ico` 文件。
- 建议显式配置稳定的 `app.id`;发布后不要因改名而修改它。
- `index.html` 不再提供应用配置;需要打包的样式、脚本和图片请写入 `resources`。
- 开发目录运行时,`resources - exclude` 中的文件保存后会自动刷新页面;也可以按 `F5`、`Ctrl+R` 或 `Cmd+R` 手动刷新。