X Tutup
Skip to content

Commit aeefee7

Browse files
MarshallOfSoundzeke
authored andcommitted
Fix the download-item doc so it correctly resembles a class
1 parent c1af62a commit aeefee7

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

docs/api/download-item.md

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ win.webContents.session.on('will-download', (event, item, webContents) => {
3737
})
3838
```
3939

40-
## Events
40+
## Class: DownloadItem
4141

42-
### Event: 'updated'
42+
### Instance Events
43+
44+
#### Event: 'updated'
4345

4446
Returns:
4547

@@ -53,7 +55,7 @@ The `state` can be one of following:
5355
* `progressing` - The download is in-progress.
5456
* `interrupted` - The download has interrupted and can be resumed.
5557

56-
### Event: 'done'
58+
#### Event: 'done'
5759

5860
Returns:
5961

@@ -70,86 +72,79 @@ The `state` can be one of following:
7072
* `cancelled` - The download has been cancelled.
7173
* `interrupted` - The download has interrupted and can not resume.
7274

73-
## Methods
75+
### Instance Methods
7476

7577
The `downloadItem` object has the following methods:
7678

77-
### `downloadItem.setSavePath(path)`
79+
#### `downloadItem.setSavePath(path)`
7880

7981
* `path` String - Set the save file path of the download item.
8082

8183
The API is only available in session's `will-download` callback function.
8284
If user doesn't set the save path via the API, Electron will use the original
8385
routine to determine the save path(Usually prompts a save dialog).
8486

85-
### `downloadItem.getSavePath()`
87+
#### `downloadItem.getSavePath()`
8688

8789
Returns `String` - The save path of the download item. This will be either the path
8890
set via `downloadItem.setSavePath(path)` or the path selected from the shown
8991
save dialog.
9092

91-
### `downloadItem.pause()`
93+
#### `downloadItem.pause()`
9294

9395
Pauses the download.
9496

95-
### `downloadItem.isPaused()`
97+
#### `downloadItem.isPaused()`
9698

9799
Returns `Boolean` - Whether the download is paused.
98100

99-
### `downloadItem.resume()`
101+
#### `downloadItem.resume()`
100102

101103
Resumes the download that has been paused.
102104

103-
### `downloadItem.canResume()`
105+
#### `downloadItem.canResume()`
104106

105107
Resumes `Boolean` - Whether the download can resume.
106108

107-
### `downloadItem.cancel()`
109+
#### `downloadItem.cancel()`
108110

109111
Cancels the download operation.
110112

111-
### `downloadItem.getURL()`
113+
#### `downloadItem.getURL()`
112114

113115
Returns `String` - The origin url where the item is downloaded from.
114116

115-
### `downloadItem.getMimeType()`
117+
#### `downloadItem.getMimeType()`
116118

117119
Returns `String` - The files mime type.
118120

119-
### `downloadItem.hasUserGesture()`
121+
#### `downloadItem.hasUserGesture()`
120122

121123
Returns `Boolean` - Whether the download has user gesture.
122124

123-
### `downloadItem.getFilename()`
125+
#### `downloadItem.getFilename()`
124126

125127
Returns `String` - The file name of the download item.
126128

127129
**Note:** The file name is not always the same as the actual one saved in local
128130
disk. If user changes the file name in a prompted download saving dialog, the
129131
actual name of saved file will be different.
130132

131-
### `downloadItem.getTotalBytes()`
133+
#### `downloadItem.getTotalBytes()`
132134

133135
Returns `Integer` - The total size in bytes of the download item.
134136

135137
If the size is unknown, it returns 0.
136138

137-
### `downloadItem.getReceivedBytes()`
139+
#### `downloadItem.getReceivedBytes()`
138140

139141
Returns `Integer` - The received bytes of the download item.
140142

141-
### `downloadItem.getContentDisposition()`
143+
#### `downloadItem.getContentDisposition()`
142144

143145
Returns `String` - The Content-Disposition field from the response
144146
header.
145147

146-
### `downloadItem.getState()`
147-
148-
Returns `String` - The current state.
149-
150-
Possible values are:
148+
#### `downloadItem.getState()`
151149

152-
* `progressing` - The download is in-progress.
153-
* `completed` - The download completed successfully.
154-
* `cancelled` - The download has been cancelled.
155-
* `interrupted` - The download has interrupted.
150+
Returns `String` - The current state. Can be `progressing`, `completed`, `cancelled` or `interrupted`.

0 commit comments

Comments
 (0)
X Tutup