Skip to content

Commit

Permalink
code: some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cnlancehu committed Aug 25, 2023
1 parent 1dc8551 commit 013c31a
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions winnotify.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,44 +85,44 @@ var (

func init() {
// 系统为 windows 时,启用 winnotify 并显示对应的帮助信息

var erroroccurred bool = false
notifyHelpMsg = "\n -n, --winnotify Send notifacation cards, only available on Windows"
handleerr := func() {
notifyerrhandle := func(err error) {
if err != nil {
errhandle("Error while sending notification: " + err.Error())
err = nil
errexit()
erroroccurred = true
}
}
notify = func(title string, message string, succeed bool) {
var tmpFile *os.File
tmpFile, err = os.CreateTemp("", "qcip-*.svg")
handleerr()
notifyerrhandle(err)
if succeed {
tmpFile.Write(successicon)
} else {
tmpFile.Write(failedicon)
}
err = tmpFile.Close()
handleerr()
notifyerrhandle(err)
iconpath := tmpFile.Name()
var notification toast.Notification
if err == nil {
if !erroroccurred {
notification = toast.Notification{
AppID: "QCIP",
Title: title,
Message: message,
Icon: iconpath,
}
} else {
errhandle("Error while showing notification icon: " + err.Error())
notification = toast.Notification{
AppID: "QCIP",
Title: title,
Message: message,
}
}
err = notification.Push()
handleerr()
if erroroccurred {
errhandle("Error occurred when sending notification cards")
}
}
}

0 comments on commit 013c31a

Please sign in to comment.