-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zm
committed
Nov 17, 2020
1 parent
166d8a4
commit 4d97ab2
Showing
24 changed files
with
565 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// | ||
// DownloadPanel.swift | ||
// HostsToolForMac | ||
// | ||
// Created by zm on 2020/11/17. | ||
// Copyright © 2020 ZzzM. All rights reserved. | ||
// | ||
|
||
import Cocoa | ||
|
||
class DownloadPanel: NSPanel { | ||
|
||
@IBOutlet weak var progressIndicator: NSProgressIndicator! | ||
|
||
var task: URLSessionTask! | ||
|
||
override func awakeFromNib() { | ||
|
||
progressIndicator.startAnimation(.none) | ||
task = Network.request(url: HostsType.current.url) { [self] in | ||
Helper.deliverNotification($0.hosts | ||
.compared | ||
.executed | ||
.message) | ||
|
||
close(.none) | ||
} failure: { [self] in | ||
|
||
if $0.code == -999 { | ||
Helper.deliverNotification($0.localizedDescription) | ||
} else { | ||
close(.none) | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
@IBAction func close(_ sender: Any?) { | ||
|
||
DispatchQueue.mainAsync { [self] in | ||
progressIndicator.stopAnimation(.none) | ||
close() | ||
} | ||
|
||
task.cancel() | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
extension DownloadPanel: NSWindowDelegate { | ||
override func close() { | ||
super.close() | ||
NSApp.abortModal() | ||
} | ||
} |
Oops, something went wrong.