-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
26 changed files
with
263 additions
and
864 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ | |
.DS_Store | ||
xcuserdata/ | ||
|
||
Package/*.app | ||
Package/*.pkg | ||
Package/* |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
11 changes: 10 additions & 1 deletion
11
NuwaClient/Assets.xcassets/AppIcon.appiconset/Contents.json
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 |
---|---|---|
@@ -1,52 +1,61 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "icon_16x16.png", | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"filename" : "icon_32x32.png", | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"filename" : "icon_128x128.png", | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"filename" : "icon_256x256.png", | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"filename" : "icon_512x512.png", | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "512x512" | ||
}, | ||
{ | ||
"filename" : "nuwa.png", | ||
"filename" : "icon_512x512@2x.png", | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "512x512" | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
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,126 @@ | ||
// | ||
// UpdateViewController.swift | ||
// NuwaClient | ||
// | ||
// Created by ConradSun on 2024/5/12. | ||
// | ||
|
||
import Cocoa | ||
|
||
class UpdateViewController: NSViewController { | ||
@IBOutlet weak var iconImageView: NSImageView! | ||
@IBOutlet weak var launchProgressIndicator: NSProgressIndicator! | ||
|
||
private var updateCheckTask: Process? | ||
private var checkResultPipe: Pipe? | ||
private var checkInfoWindow: NSAlert? | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
let icon = NSImage(named: "AppIcon") | ||
icon?.size = NSMakeSize(80, 80) | ||
iconImageView.image = icon | ||
|
||
launchProgressIndicator.isIndeterminate = true | ||
launchProgressIndicator.style = .bar | ||
launchProgressIndicator.startAnimation(nil) | ||
|
||
checkInfoWindow = NSAlert() | ||
checkInfoWindow?.alertStyle = .informational | ||
|
||
DispatchQueue.global().async { [self] in | ||
var latestVersion = String() | ||
let currentVersion = Bundle.main.object(forInfoDictionaryKey: VersionInfoKey) as! String | ||
|
||
initCheckTask() | ||
if let checkResult = launchCheckTask() { | ||
let contentList = checkResult.split(separator: "\r\n") | ||
for contentItem in contentList { | ||
if contentItem.contains("location") { | ||
let tag = contentItem.split(separator: "/").last! | ||
if tag.first == "v" { | ||
Logger(.Info, "The latest version is \(tag).") | ||
latestVersion = tag.dropFirst().lowercased() | ||
} | ||
} | ||
} | ||
} | ||
|
||
DispatchQueue.main.async { [self] in | ||
setupInfoWindow(latestVersion: latestVersion, currentVersion: currentVersion) | ||
view.window?.close() | ||
let resp = checkInfoWindow?.runModal() | ||
if resp == .alertSecondButtonReturn { | ||
let downloadAddr = URL(string: PackageURL) | ||
NSWorkspace.shared.open(downloadAddr!) | ||
} | ||
} | ||
} | ||
} | ||
|
||
override func viewDidDisappear() { | ||
super.viewDidDisappear() | ||
updateCheckTask?.terminate() | ||
} | ||
|
||
private func initCheckTask() { | ||
updateCheckTask = Process() | ||
checkResultPipe = Pipe() | ||
updateCheckTask?.arguments = ["-I", ReleaseURL] | ||
updateCheckTask?.standardOutput = checkResultPipe | ||
|
||
if #available(macOS 10.13, *) { | ||
updateCheckTask?.executableURL = URL(fileURLWithPath: "/usr/bin/curl") | ||
} else { | ||
updateCheckTask?.launchPath = "/usr/bin/curl" | ||
} | ||
} | ||
|
||
private func setupInfoWindow(latestVersion: String, currentVersion: String) { | ||
if latestVersion.isEmpty { | ||
checkInfoWindow?.alertStyle = .critical | ||
checkInfoWindow?.messageText = "Error" | ||
checkInfoWindow?.informativeText = "Failed to get latest info for NuwaStone." | ||
} else if latestVersion == currentVersion { | ||
checkInfoWindow?.messageText = "You're up-to-date!" | ||
checkInfoWindow?.informativeText = "NuwaStone \(currentVersion) is the latest version." | ||
} else { | ||
checkInfoWindow?.messageText = "You're out-of-date!" | ||
checkInfoWindow?.informativeText = "Newer version \(latestVersion) is currently avaliable." | ||
checkInfoWindow?.addButton(withTitle: "Ignore") | ||
checkInfoWindow?.addButton(withTitle: "Update") | ||
} | ||
} | ||
|
||
private func launchCheckTask() -> String? { | ||
var output = Data() | ||
|
||
if #available(macOS 10.13, *) { | ||
try? updateCheckTask?.run() | ||
} else { | ||
updateCheckTask?.launch() | ||
} | ||
|
||
if #available(macOS 10.15.4, *) { | ||
guard let value = try? checkResultPipe?.fileHandleForReading.readToEnd() else { | ||
return nil | ||
} | ||
output = value | ||
} else { | ||
guard let value = checkResultPipe?.fileHandleForReading.readDataToEndOfFile() else { | ||
return nil | ||
} | ||
output = value | ||
} | ||
|
||
guard let result = String(data: output, encoding: .utf8) else { | ||
return nil | ||
} | ||
return result | ||
} | ||
|
||
@IBAction func cancelButtonClicked(_ sender: NSButton) { | ||
view.window?.close() | ||
} | ||
} |
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
Binary file modified
BIN
+135 KB
(150%)
...odeproj/project.xcworkspace/xcuserdata/sunkang.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
Oops, something went wrong.