Entry configuration
Entry configuration
Function
app.entry determines what page to load after the window starts. Its meaning is determined by app.mode.
static mode
static mode loads HTML files in the project:
{ "app": { "mode": "static", "entry": "index.html" } }
The relative path is based on the project root directory. By default, index.html will be loaded as the root path when running:
bt://app/
. In this way, front-end routing such as Vue Router createWebHistory() can recognize the initial path as /. Other entry files will be converted according to the actual path. For example, pages/start.html will be converted to:
bt://app/pages/start.html
The path must be a relative path within the project, not an absolute path, and cannot contain ... When the entry resource does not exist, the window will display a startup error page, prompting 入口资源不存在.
server mode
server mode fixedly executes server.bt in the root directory of the project, and the window loads the HTTP address specified by app.entry:
{ "app": { "mode": "server", "entry": "http://127.0.0.1:18280" } }
In server.bt, you need to start the Web service yourself, and ensure that the listening address is consistent with app.entry. Currently it is recommended to use net.listen({ type:'web' }).
net.listen({ type:'web' bind:'127.0.0.1:18280' sites:[ { domains:['127.0.0.1'] root:'www/' entry:'main.bt' } ] })
remote mode
remote mode directly loads the remote web address:
{ "app": { "mode": "remote", "entry": "https://example.com" } }
remote mode entry must start with http:// or https://.
Default
| mode | entry Default |
|---|---|
static | index.html |
server | http://127.0.0.1:18280 |
remote | https://example.com |
bt:// address
Developers generally do not need to hand-write bt:// in app.entry. static mode automatically converts relative entries to bt://app/....
In static mode, paths without extensions will fall back to the entry HTML when the resource does not exist to support SPA history routing refresh; scripts, styles and images with extensions will not fall back. The
page can be referenced inside:
<script src="bt://app/main.js"></script> <link rel="stylesheet" href="bt://app/style.css">
Troubleshooting
- The local entrance cannot be opened: check whether app.mode is static, whether the entry file exists, and whether the path does not contain ...
- The local service cannot be opened: Check whether
server.btexists, whether the port is occupied, and whether the listening address ofnet.listenis consistent withapp.entry. - The remote portal cannot be opened: Check whether the network, certificate, and URL can be opened in a normal browser.
- The entry path cannot access files outside the project; both the development directory and Bundle will verify safe relative paths.