File tree Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Expand file tree Collapse file tree 2 files changed +21
-5
lines changed Original file line number Diff line number Diff line change 4
4
5
5
6
6
// main
7
- #[ tokio:: main( worker_threads = 3 ) ]
7
+ #[ tokio:: main]
8
8
async fn main ( ) {
9
9
// 初始化一些东西
10
10
let save_path = std:: path:: Path :: new ( ui:: data:: SAVE_DIR ) ;
@@ -22,24 +22,40 @@ async fn main() {
22
22
23
23
root. show ( ) ;
24
24
25
+ let mut handlers: Vec < tokio:: task:: JoinHandle < ( ) > > = vec ! [ ] ;
26
+
25
27
// app.run().unwrap();
26
28
27
29
while app. wait ( ) {
28
30
app. redraw ( ) ;
29
31
// 刷新状态栏
30
32
buffer. status_bar . set_value ( unsafe { & ui:: STATUS_BAR_CONTENT } ) ;
33
+
31
34
// 刷新文件系统
32
35
buffer. refresh_file_system ( ui:: data:: SAVE_DIR ) ;
33
36
37
+ // 查看是否还有下载在运行
38
+ let mut handle_flag = true ;
39
+ for handle in handlers. iter ( ) {
40
+ if !handle. is_finished ( ) { // 如果没有停止,就是 false
41
+ handle_flag = false ;
42
+ }
43
+ }
44
+ if handle_flag { // 如果还是 true 的话,那就清楚 status bar
45
+ ui:: change_status_bar_content ( & std:: string:: String :: new ( ) ) ;
46
+ }
47
+
34
48
if let Some ( msg) = receiver. recv ( ) {
35
49
match msg {
36
50
Message :: Start => {
37
51
let buffer_clone = buffer. clone ( ) ;
38
52
println ! ( "Start" ) ;
39
53
40
- tokio:: spawn ( async {
41
- ui:: network:: start ( buffer_clone) . await ;
42
- } ) ;
54
+ handlers. push (
55
+ tokio:: spawn ( async {
56
+ ui:: network:: start ( buffer_clone) . await ;
57
+ } )
58
+ ) ;
43
59
}
44
60
}
45
61
}
Original file line number Diff line number Diff line change @@ -121,7 +121,7 @@ pub fn add_widgets(root: &mut window::Window, sender: app::Sender<Message>) -> B
121
121
122
122
123
123
let mut start_bt = button:: Button :: default ( )
124
- . with_label ( "Start" ) ;
124
+ . with_label ( "Start Download " ) ;
125
125
start_bt. set_color ( Color :: White ) ;
126
126
start_bt. emit ( buffer. sender , Message :: Start ) ;
127
127
You can’t perform that action at this time.
0 commit comments