mirror of
https://github.com/AynaLivePlayer/AynaLivePlayer.git
synced 2025-12-06 18:32:50 +08:00
add updater
This commit is contained in:
@@ -114,28 +114,16 @@ func (b *bascicConfig) CreatePanel() fyne.CanvasObject {
|
||||
&config.General.PlayNextOnFail,
|
||||
config.General.PlayNextOnFail),
|
||||
)
|
||||
//checkUpdateBox := container.NewHBox(
|
||||
// widget.NewLabel(i18n.T("gui.config.basic.auto_check_update")),
|
||||
// component.NewCheckOneWayBinding(
|
||||
// i18n.T("gui.config.basic.auto_check_update.prompt"),
|
||||
// &config.General.AutoCheckUpdate,
|
||||
// config.General.AutoCheckUpdate),
|
||||
//)
|
||||
//checkUpdateBtn := widget.NewButton(i18n.T("gui.config.basic.check_update"), func() {
|
||||
// err := API.App().CheckUpdate()
|
||||
// if err != nil {
|
||||
// showDialogIfError(err)
|
||||
// return
|
||||
// }
|
||||
// if API.App().LatestVersion().Version > API.App().Version().Version {
|
||||
// dialog.ShowCustom(
|
||||
// i18n.T("gui.update.new_version"),
|
||||
// "OK",
|
||||
// widget.NewRichTextFromMarkdown(API.App().LatestVersion().Info),
|
||||
// MainWindow)
|
||||
// }
|
||||
//})
|
||||
//b.panel = container.NewVBox(randomPlaylist, outputDevice, skipPlaylist, skipWhenErr, checkUpdateBox, checkUpdateBtn)
|
||||
b.panel = container.NewVBox(randomPlaylist, skipWhenErr, outputDevice)
|
||||
checkUpdateBox := container.NewHBox(
|
||||
widget.NewLabel(i18n.T("gui.config.basic.auto_check_update")),
|
||||
component.NewCheckOneWayBinding(
|
||||
i18n.T("gui.config.basic.auto_check_update.prompt"),
|
||||
&config.General.AutoCheckUpdate,
|
||||
config.General.AutoCheckUpdate),
|
||||
)
|
||||
checkUpdateBtn := widget.NewButton(i18n.T("gui.config.basic.check_update"), func() {
|
||||
global.EventManager.CallA(events.CheckUpdateCmd, events.CheckUpdateCmdEvent{})
|
||||
})
|
||||
b.panel = container.NewVBox(randomPlaylist, skipWhenErr, outputDevice, checkUpdateBox, checkUpdateBtn)
|
||||
return b.panel
|
||||
}
|
||||
|
||||
21
gui/gui.go
21
gui/gui.go
@@ -78,28 +78,9 @@ func Initialize() {
|
||||
dialog.ShowError(err, MainWindow)
|
||||
})
|
||||
|
||||
checkUpdate()
|
||||
MainWindow.SetFixedSize(true)
|
||||
if config.General.ShowSystemTray {
|
||||
setupSysTray()
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//func checkUpdate() {
|
||||
// l().Info("checking updates...")
|
||||
// err := API.App().CheckUpdate()
|
||||
// if err != nil {
|
||||
// showDialogIfError(err)
|
||||
// l().Warnf("check update failed", err)
|
||||
// return
|
||||
// }
|
||||
// l().Infof("latest version: v%s", API.App().LatestVersion().Version)
|
||||
// if API.App().LatestVersion().Version > API.App().Version().Version {
|
||||
// l().Info("new update available")
|
||||
// dialog.ShowCustom(
|
||||
// i18n.T("gui.update.new_version"),
|
||||
// "OK",
|
||||
// widget.NewRichTextFromMarkdown(API.App().LatestVersion().Info),
|
||||
// MainWindow)
|
||||
// }
|
||||
//}
|
||||
|
||||
31
gui/updater.go
Normal file
31
gui/updater.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package gui
|
||||
|
||||
import (
|
||||
"AynaLivePlayer/core/events"
|
||||
"AynaLivePlayer/global"
|
||||
"AynaLivePlayer/pkg/event"
|
||||
"AynaLivePlayer/pkg/i18n"
|
||||
"fyne.io/fyne/v2/dialog"
|
||||
"fyne.io/fyne/v2/widget"
|
||||
)
|
||||
|
||||
func checkUpdate() {
|
||||
global.EventManager.RegisterA(
|
||||
events.CheckUpdateResultUpdate, "gui.updater.check_update", func(event *event.Event) {
|
||||
data := event.Data.(events.CheckUpdateResultUpdateEvent)
|
||||
msg := data.Info.Version.String() + "\n\n\n" + data.Info.Info
|
||||
if data.HasUpdate {
|
||||
dialog.ShowCustom(
|
||||
i18n.T("gui.update.new_version"),
|
||||
"OK",
|
||||
widget.NewRichTextFromMarkdown(msg),
|
||||
MainWindow)
|
||||
} else {
|
||||
dialog.ShowCustom(
|
||||
i18n.T("gui.update.already_latest_version"),
|
||||
"OK",
|
||||
widget.NewRichTextFromMarkdown(""),
|
||||
MainWindow)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user