mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +08:00
切换语言时保存语言设置
This commit is contained in:
@@ -3,8 +3,9 @@
|
||||
package lang
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"net/http"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
type SwitchAction struct {
|
||||
@@ -23,12 +24,13 @@ func (this *SwitchAction) RunPost(params struct{}) {
|
||||
langCode = "zh-cn"
|
||||
}
|
||||
|
||||
this.AddCookie(&http.Cookie{
|
||||
Name: "edgelang",
|
||||
Value: langCode,
|
||||
Path: "/",
|
||||
MaxAge: 86400 * 365,
|
||||
})
|
||||
configloaders.UpdateAdminLang(this.AdminId(), langCode)
|
||||
|
||||
_, err := this.RPC().AdminRPC().UpdateAdminLang(this.AdminContext(), &pb.UpdateAdminLangRequest{LangCode: langCode})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user