部分菜单实现中英文切换

This commit is contained in:
刘祥超
2023-12-12 11:47:41 +08:00
parent bacb94abe6
commit fc6fb7dce2
12 changed files with 93 additions and 4 deletions

View File

@@ -0,0 +1,33 @@
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package lang
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"net/http"
)
type SwitchAction struct {
actionutils.ParentAction
}
func (this *SwitchAction) Init() {
this.Nav("", "", "")
}
func (this *SwitchAction) RunPost(params struct{}) {
var langCode = this.LangCode()
if len(langCode) == 0 || langCode == "zh-cn" {
langCode = "en-us"
} else {
langCode = "zh-cn"
}
this.AddCookie(&http.Cookie{
Name: "edgelang",
Value: langCode,
Path: "/",
})
this.Success()
}