docs: Use file: instead of asar:
This commit is contained in:
parent
24b5faf8df
commit
37d278de34
1 changed files with 4 additions and 8 deletions
|
@ -69,30 +69,26 @@ require('/path/to/example.asar/dir/module.js');
|
||||||
|
|
||||||
### Web API
|
### Web API
|
||||||
|
|
||||||
In a web page, files in archive can be requested by using the `asar:` protocol.
|
In a web page, files in archive can be requested with the `file:` protocol. Like
|
||||||
Like the Node API, `asar` archives are treated as directories.
|
the Node API, `asar` archives are treated as directories.
|
||||||
|
|
||||||
For example, to get a file with `$.get`:
|
For example, to get a file with `$.get`:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script>
|
<script>
|
||||||
var $ = require('./jquery.min.js');
|
var $ = require('./jquery.min.js');
|
||||||
$.get('asar:/path/to/example.asar/file.txt', function(data) {
|
$.get('file:///path/to/example.asar/file.txt', function(data) {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
```
|
```
|
||||||
|
|
||||||
The `asar:` protocol can also be used to request normal files in filesystem,
|
|
||||||
just like the `file:` protocol. But unlike `file:` protocol, there are no
|
|
||||||
slashes (`//`) after `asar:`.
|
|
||||||
|
|
||||||
You can also display a web page in an `asar` archive with `BrowserWindow`:
|
You can also display a web page in an `asar` archive with `BrowserWindow`:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var BrowserWindow = require('browser-window');
|
var BrowserWindow = require('browser-window');
|
||||||
var win = new BrowserWindow({width: 800, height: 600});
|
var win = new BrowserWindow({width: 800, height: 600});
|
||||||
win.loadUrl('asar:/path/to/example.asar/static/index.html');
|
win.loadUrl('file:///path/to/example.asar/static/index.html');
|
||||||
```
|
```
|
||||||
|
|
||||||
### Treating `asar` archive as normal file
|
### Treating `asar` archive as normal file
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue