Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
jinyaoMa committed Sep 17, 2022
1 parent 91ddbc2 commit 1ae0265
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions backend/tray/tray.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
_ "embed"
"my-app/backend/app"
"my-app/backend/model"
"my-app/backend/pkg/i18n"
"my-app/backend/tray/menus"
"my-app/backend/web"
Expand Down Expand Up @@ -84,17 +85,6 @@ func (t *tray) ChangeTheme(theme string) *tray {
return t
}

func (t *tray) updateLocales() {
locale := i18n.I18n().Locale()
systray.SetTitle(locale.AppName)
systray.SetTooltip(locale.AppName)
t.openWindow.SetLocale(locale)
t.apiService.SetLocale(locale)
t.displayLanguage.SetLocale(locale)
t.colorTheme.SetLocale(locale)
t.quit.SetLocale(locale)
}

func (t *tray) onReady() {
systray.SetTemplateIcon(icon, icon)

Expand Down Expand Up @@ -156,6 +146,13 @@ func (t *tray) onReady() {
default:
runtime.WindowSetSystemDefaultTheme(t.wailsCtx)
}
option := model.MyOption{
Name: app.CfgTheme,
}
result := option.Update(theme)
if result.Error != nil {
app.App().TrayLog().Fatalf("failed to update theme option: %+v\n", result.Error)
}
return true
},
})
Expand Down Expand Up @@ -201,3 +198,22 @@ func (t *tray) onQuit() {
web.Web().Stop()
runtime.Quit(t.wailsCtx)
}

func (t *tray) updateLocales() {
locale := i18n.I18n().Locale()
systray.SetTitle(locale.AppName)
systray.SetTooltip(locale.AppName)
t.openWindow.SetLocale(locale)
t.apiService.SetLocale(locale)
t.displayLanguage.SetLocale(locale)
t.colorTheme.SetLocale(locale)
t.quit.SetLocale(locale)

option := model.MyOption{
Name: app.CfgLanguage,
}
result := option.Update(locale.Lang.Code)
if result.Error != nil {
app.App().TrayLog().Fatalf("failed to update language option: %+v\n", result.Error)
}
}

0 comments on commit 1ae0265

Please sign in to comment.