fast-down-gui 0.1.45

超级快的下载器图形化界面
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
import {
    Button,
    LineEdit,
    ScrollView,
    StandardButton,
    TextEdit,
    CheckBox,
    ComboBox,
    Switch,
} from "std-widgets.slint";
import { HDivider } from "divider.slint";
import { NoScrollSpinBox } from "my-spin-box.slint";
import { Header1, Header2 } from "headers.slint";
import { Help } from "info.slint";

export struct DownloadConfig {
    save_dir: string,
    file_name: string,
    threads: int,
    proxy: string,
    headers: string,
    min_chunk_size: int,
    write_buffer_size: int,
    write_queue_cap: int,
    retry_gap_ms: int,
    pull_timeout_ms: int,
    accept_invalid_certs: bool,
    accept_invalid_hostnames: bool,
    ips: string,
    max_speculative: int,
    write_method: int,
    retry_times: int,
    chunk_window: int,
    pre_allocate: bool,
    parse_filename: bool,
}
export struct GeneralConfig {
    max_concurrency: int,
    auto_start: bool,
    exit_after_download: bool,
    ask_before_download: bool,
    skip_headers: string,
    run_as_admin: bool,
}

export component Settings inherits VerticalLayout {
    horizontal-stretch: 1;

    in-out property <DownloadConfig> download_config;
    in-out property <GeneralConfig> general_config;

    callback browse_folder();
    callback config_change(DownloadConfig, GeneralConfig);
    callback view_log();

    changed download_config => {
        config_change(download_config, general_config);
    }

    changed general_config => {
        config_change(download_config, general_config);
    }

    HorizontalLayout {
        padding: 8px;
        Header1 {
            text: "设置";
        }
    }

    HDivider { }

    ScrollView {
        VerticalLayout {
            padding: 16px;
            spacing: 8px;
            alignment: LayoutAlignment.start;

            Header2 {
                text: "基础选项";
            }

            Text {
                text: "保存文件夹";
            }

            HorizontalLayout {
                spacing: 8px;

                LineEdit {
                    text <=> download_config.save-dir;
                    placeholder-text: "留空默认为下载目录";
                }

                Button {
                    text: "浏览";
                    clicked => {
                        browse_folder();
                    }
                }
            }

            Text {
                text: "自定义文件名";
            }

            LineEdit {
                text <=> download_config.file-name;
                placeholder-text: "留空默认为自动获取,开启解析文件名和可以使用占位符";
            }

            HorizontalLayout {
                spacing: 8px;
                VerticalLayout {
                    spacing: 8px;

                    Help {
                        tooltip: "线程越多不意味着越快\n推荐值 32 / 16 / 8";
                        alignment: left;

                        Text {
                            text: "线程数";
                        }
                    }

                    NoScrollSpinBox {
                        minimum: 1;
                        value <=> download_config.threads;
                    }
                }

                VerticalLayout {
                    spacing: 8px;

                    Help {
                        tooltip: "同时下载的任务数\n推荐值 3";

                        Text {
                            text: "并发任务数";
                        }
                    }

                    NoScrollSpinBox {
                        minimum: 1;
                        value <=> general_config.max-concurrency;
                    }
                }
            }

            Help {
                tooltip: "支持 https、http、socks5 代理";
                alignment: left;

                Text {
                    text: "代理";
                }
            }

            LineEdit {
                text <=> download_config.proxy;
                placeholder-text: "留空为系统代理,输入 null 为不使用代理";
            }

            Text {
                text: "请求头";
            }

            TextEdit {
                text <=> download_config.headers;
                min-height: 150px;
                placeholder-text: "Cookie: value\nUser-Agent: Mozilla/5.0";
            }

            HDivider { }

            Header2 {
                text: "高级选项";
            }

            HorizontalLayout {
                spacing: 8px;
                VerticalLayout {
                    spacing: 8px;

                    Help {
                        tooltip: "任务窃取时会保证每个分片的大小 ≥ 该值\n推荐值 8 MiB\n分片太小容易造成强烈竞争\n当无法分片的时候会进入冗余竞争模式";

                        Text {
                            text: "最小分片大小 (字节)";
                        }
                    }

                    NoScrollSpinBox {
                        minimum: 1;
                        value <=> download_config.min-chunk-size;
                    }
                }

                VerticalLayout {
                    spacing: 8px;

                    Help {
                        tooltip: "有利于将随机写入转换为顺序写入,提高写入速度\n推荐值 16 MiB\n该值越大越好";

                        Text {
                            text: "写入缓冲区大小 (字节)";
                        }
                    }

                    NoScrollSpinBox {
                        value <=> download_config.write-buffer-size;
                    }
                }
            }

            HorizontalLayout {
                spacing: 8px;
                VerticalLayout {
                    spacing: 8px;

                    Help {
                        tooltip: "当分片大小太小后,进入冗余竞争模式。\n该值决定了最多有多少个线程在同一分片上竞争下载,以解决下载卡进度 99% 的问题\n推荐值 3";
                        alignment: left;

                        Text {
                            text: "冗余线程数";
                        }
                    }

                    NoScrollSpinBox {
                        value <=> download_config.max-speculative;
                    }
                }

                VerticalLayout {
                    spacing: 8px;

                    Help {
                        tooltip: "如果下载线程太快,填满了写入队列,会触发压背,降低下载速度,防止内存占用过大\n推荐值 10240\n如果内存占用过大,应该调小该值";

                        Text {
                            text: "写入队列大小";
                        }
                    }

                    NoScrollSpinBox {
                        minimum: 1;
                        value <=> download_config.write-queue-cap;
                    }
                }
            }

            HorizontalLayout {
                spacing: 8px;
                VerticalLayout {
                    spacing: 8px;

                    Help {
                        tooltip: "请求失败后的默认重试间隔\n推荐值 500ms\n如果服务器返回中有 Retry-After 头,则遵循服务器返回的设定";
                        alignment: left;

                        Text {
                            text: "重试间隔 (毫秒)";
                        }
                    }

                    NoScrollSpinBox {
                        value <=> download_config.retry-gap-ms;
                    }
                }

                VerticalLayout {
                    spacing: 8px;

                    Help {
                        tooltip: "推荐值 5000ms\n请求发出后,接收字节中,如果在 pull_timeout 这一段时间内一个字节也没收到,则中断连接,重新请求。\n有利于触发 TCP 重新检测拥塞状态,提高下载速度";

                        Text {
                            text: "拉取超时 (毫秒)";
                        }
                    }

                    NoScrollSpinBox {
                        value <=> download_config.pull-timeout-ms;
                    }
                }
            }

            HorizontalLayout {
                spacing: 8px;
                VerticalLayout {
                    spacing: 8px;

                    Help {
                        tooltip: "设置获取元数据的重试次数\n推荐值 10\n注意,这不是下载中的重试次数,下载中会无限重试";
                        alignment: left;

                        Text {
                            text: "重试次数";
                        }
                    }

                    NoScrollSpinBox {
                        value <=> download_config.retry-times;
                    }
                }

                VerticalLayout {
                    spacing: 8px;

                    Help {
                        tooltip: "推荐值 8 KiB\n它会过滤掉小于该值的小空洞,并合成一个大范围,以减小 HTTP 请求数量";

                        Text {
                            text: "块平滑窗口";
                        }
                    }

                    NoScrollSpinBox {
                        value <=> download_config.chunk-window;
                    }
                }
            }

            HorizontalLayout {
                spacing: 8px;

                Help {
                    tooltip: "不安全,极度不建议开启";

                    CheckBox {
                        text: "接受无效证书";
                        horizontal-stretch: 1;
                        checked <=> download_config.accept-invalid-certs;
                    }
                }

                Help {
                    tooltip: "不安全,极度不建议开启";

                    CheckBox {
                        text: "接受无效主机";
                        horizontal-stretch: 1;
                        checked <=> download_config.accept-invalid-hostnames;
                    }
                }
            }

            HorizontalLayout {
                spacing: 8px;

                Help {
                    tooltip: "在下载前预分配文件大小\n如果你的设备支持快速分配,那么强烈推荐开启此选项";
                    alignment: left;

                    CheckBox {
                        text: "文件预分配";
                        checked <=> download_config.pre-allocate;
                    }
                }

                Help {
                    tooltip: "开启后你可以在自定义文件名中使用占位符\n{host} -> 域名或 IP 地址\n{parent_path} -> URL path 中的父路径\n{file_name} -> 完整的文件名\n{file_stem} -> 文件名的前缀\n{file_ext} -> 文件扩展名,含 '.'\n并且支持 strftime 语法,%%、%Y、%m……完整语法请自行查询";

                    CheckBox {
                        text: "解析文件名";
                        horizontal-stretch: 1;
                        checked <=> download_config.parse_filename;
                    }
                }
            }

            HorizontalLayout {
                spacing: 8px;

                Help {
                    tooltip: "开启后从其他地方调用 fast-down 时会弹出添加任务界面来确认\n此时可以临时修改很多配置";
                    CheckBox {
                        text: "下载前确认";
                        checked <=> general_config.ask-before-download;
                    }
                }

                Help {
                    tooltip: "在下载任务完成后,如果检测到软件处于托盘,则会自动退出软件";

                    CheckBox {
                        text: "完成后退出";
                        horizontal-stretch: 1;
                        checked <=> general_config.exit-after-download;
                    }
                }
            }

            HorizontalLayout {
                spacing: 8px;
                Help {
                    tooltip: "开启后会随系统自动启动";

                    CheckBox {
                        text: "开机自启动";
                        horizontal-stretch: 1;
                        checked <=> general_config.auto-start;
                    }
                }

                Help {
                    tooltip: "下次启动时以管理员身份运行,只在 Windows 上生效";

                    CheckBox {
                        text: "管理员运行";
                        horizontal-stretch: 1;
                        checked <=> general_config.run-as-admin;
                    }
                }
            }

            Text {
                text: "写入方法";
            }

            ComboBox {
                model: ["内存映射文件 (推荐)", "标准库 (兼容性好)"];
                current-index <=> download_config.write-method;
            }

            Help {
                tooltip: "外部调用下载时,会自动去除掉这些请求头";
                alignment: left;

                Text {
                    text: "跳过请求头";
                }
            }

            TextEdit {
                text <=> general_config.skip-headers;
                min-height: 100px;
                placeholder-text: "Accept\nCookie\n一行一个";
            }

            Help {
                tooltip: "使用哪些地址来发送请求\n如果你有多个网卡可用,可以填写他们的对外 IP 地址,请求会在这些 IP 地址上轮换,下载不一定会更快,还会与 VPN 软件冲突";
                alignment: left;

                Text {
                    text: "网卡池";
                }
            }

            TextEdit {
                text <=> download_config.ips;
                min-height: 150px;
                placeholder-text: "192.168.1.8\n192.168.1.9\n留空则使用默认网卡发送请求";
            }

            Button {
                text: "查看日志";
                clicked => {
                    view_log()
                }
            }
        }
    }
}