mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-11 18:30:25 +08:00
切换语言时保存语言设置
This commit is contained in:
@@ -174,6 +174,17 @@ func FindAdminLang(adminId int64) string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UpdateAdminLang 修改某个管理员选择的语言
|
||||||
|
func UpdateAdminLang(adminId int64, langCode string) {
|
||||||
|
locker.Lock()
|
||||||
|
defer locker.Unlock()
|
||||||
|
|
||||||
|
list, ok := sharedAdminModuleMapping[adminId]
|
||||||
|
if ok {
|
||||||
|
list.Lang = langCode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func FindAdminLangForAction(actionPtr actions.ActionWrapper) (langCode langs.LangCode) {
|
func FindAdminLangForAction(actionPtr actions.ActionWrapper) (langCode langs.LangCode) {
|
||||||
locker.Lock()
|
locker.Lock()
|
||||||
defer locker.Unlock()
|
defer locker.Unlock()
|
||||||
|
|||||||
@@ -3,8 +3,9 @@
|
|||||||
package lang
|
package lang
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
"net/http"
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SwitchAction struct {
|
type SwitchAction struct {
|
||||||
@@ -23,12 +24,13 @@ func (this *SwitchAction) RunPost(params struct{}) {
|
|||||||
langCode = "zh-cn"
|
langCode = "zh-cn"
|
||||||
}
|
}
|
||||||
|
|
||||||
this.AddCookie(&http.Cookie{
|
configloaders.UpdateAdminLang(this.AdminId(), langCode)
|
||||||
Name: "edgelang",
|
|
||||||
Value: langCode,
|
_, err := this.RPC().AdminRPC().UpdateAdminLang(this.AdminContext(), &pb.UpdateAdminLangRequest{LangCode: langCode})
|
||||||
Path: "/",
|
if err != nil {
|
||||||
MaxAge: 86400 * 365,
|
this.ErrorPage(err)
|
||||||
})
|
return
|
||||||
|
}
|
||||||
|
|
||||||
this.Success()
|
this.Success()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user