From 7d956a9b5da12b716c4a90396fab8f7c3e2e8e3f Mon Sep 17 00:00:00 2001 From: Gucheng Wang Date: Thu, 5 Oct 2023 22:16:29 +0800 Subject: [PATCH] Add language --- conf/app.conf | 1 + run/git.go | 2 +- run/run.go | 10 ++++++++-- run/util.go | 4 ++++ run/util_path.go | 3 +++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/conf/app.conf b/conf/app.conf index d8fd427..5dc53d3 100644 --- a/conf/app.conf +++ b/conf/app.conf @@ -16,3 +16,4 @@ casdoorApplication = "app-casibase" isDemoMode = false appDir = "C:/github_repos" dbPass = "" +language = "en" diff --git a/run/git.go b/run/git.go index ddc408b..a4100be 100644 --- a/run/git.go +++ b/run/git.go @@ -80,7 +80,7 @@ func gitGetLatestCommitHash(path string) string { func gitPull(path string) bool { oldHash := gitGetLatestCommitHash(path) - cmd := exec.Command("git", "pull") + cmd := exec.Command("git", "pull", "--rebase", "--autostash") cmd.Dir = path out, err := cmd.CombinedOutput() println(out) diff --git a/run/run.go b/run/run.go index 626ae20..698ef12 100644 --- a/run/run.go +++ b/run/run.go @@ -33,16 +33,22 @@ func CreateRepo(siteName string, needStart bool, diff string) { } else if diff != "" { gitApply(path, diff) } + + updateBatFile(siteName) + updateShortcutFile(siteName) } else { affected := gitPull(path) if affected { gitWebBuild(path) } + + if !needStart { + stopProcess(siteName) + startProcess(siteName) + } } if needStart { - updateBatFile(siteName) - updateShortcutFile(siteName) startProcess(siteName) } } diff --git a/run/util.go b/run/util.go index eddfa56..f9f26b6 100644 --- a/run/util.go +++ b/run/util.go @@ -106,6 +106,10 @@ func stopProcess(name string) { fmt.Printf("Stopping process: [%s]\n", name) windowName := fmt.Sprintf("%s.bat - Shortcut", name) + if language != "en" { + windowName = fmt.Sprintf("%s.bat - 快捷方式", name) + } + // taskkill /IM "casdoor.bat - Shortcut" /F // taskkill /F /FI "WINDOWTITLE eq casdoor.bat - Shortcut" /T cmd := exec.Command("taskkill", "/F", "/FI", fmt.Sprintf("WINDOWTITLE eq %s", windowName), "/T") diff --git a/run/util_path.go b/run/util_path.go index 7fb7f21..025d7e5 100644 --- a/run/util_path.go +++ b/run/util_path.go @@ -24,6 +24,7 @@ import ( ) var username string +var language string func init() { usr, err := user.Current() @@ -36,6 +37,8 @@ func init() { if len(tokens) == 2 { username = tokens[1] } + + language = beego.AppConfig.String("language") } func GetRepoPath(name string) string {