fix: sync env config (#319)

This commit is contained in:
Lykin 2024-08-06 18:12:21 +08:00
parent 0038092193
commit b26f5d2bde
2 changed files with 17 additions and 0 deletions

View File

@ -6,6 +6,7 @@ import (
"github.com/adrg/sysfont" "github.com/adrg/sysfont"
runtime2 "github.com/wailsapp/wails/v2/pkg/runtime" runtime2 "github.com/wailsapp/wails/v2/pkg/runtime"
"net/http" "net/http"
"os"
"sort" "sort"
"strings" "strings"
"sync" "sync"
@ -50,6 +51,7 @@ func (p *preferencesService) SetPreferences(pf types.Preferences) (resp types.JS
return return
} }
p.UpdateEnv()
resp.Success = true resp.Success = true
return return
} }
@ -114,6 +116,11 @@ func (p *preferencesService) GetBuildInDecoder() (resp types.JSResp) {
return return
} }
func (p *preferencesService) GetLanguage() string {
pref := p.pref.GetPreferences()
return pref.General.Language
}
func (p *preferencesService) SetAppVersion(ver string) { func (p *preferencesService) SetAppVersion(ver string) {
if !strings.HasPrefix(ver, "v") { if !strings.HasPrefix(ver, "v") {
p.clientVersion = "v" + ver p.clientVersion = "v" + ver
@ -246,3 +253,12 @@ func (p *preferencesService) CheckForUpdate() (resp types.JSResp) {
} }
return return
} }
// UpdateEnv Update System Environment
func (p *preferencesService) UpdateEnv() {
if p.GetLanguage() == "zh" {
os.Setenv("LANG", "zh_CN.UTF-8")
} else {
os.Unsetenv("LANG")
}
}

View File

@ -35,6 +35,7 @@ func main() {
pubsubSvc := services.Pubsub() pubsubSvc := services.Pubsub()
prefSvc := services.Preferences() prefSvc := services.Preferences()
prefSvc.SetAppVersion(version) prefSvc.SetAppVersion(version)
prefSvc.UpdateEnv()
windowWidth, windowHeight, maximised := prefSvc.GetWindowSize() windowWidth, windowHeight, maximised := prefSvc.GetWindowSize()
windowStartState := options.Normal windowStartState := options.Normal
if maximised { if maximised {