mirror of
				https://github.com/TeaOSLab/EdgeAdmin.git
				synced 2025-11-04 05:00:25 +08:00 
			
		
		
		
	部分菜单实现中英文切换
This commit is contained in:
		
							
								
								
									
										17
									
								
								internal/web/actions/default/settings/lang/init.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								internal/web/actions/default/settings/lang/init.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
package lang
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/configloaders"
 | 
			
		||||
	"github.com/TeaOSLab/EdgeAdmin/internal/web/helpers"
 | 
			
		||||
	"github.com/iwind/TeaGo"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	TeaGo.BeforeStart(func(server *TeaGo.Server) {
 | 
			
		||||
		server.
 | 
			
		||||
			Helper(helpers.NewUserMustAuth(configloaders.AdminModuleCodeServer)).
 | 
			
		||||
			Prefix("/settings/lang").
 | 
			
		||||
			Post("/switch", new(SwitchAction)).
 | 
			
		||||
			EndAll()
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										33
									
								
								internal/web/actions/default/settings/lang/switch.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								internal/web/actions/default/settings/lang/switch.go
									
									
									
									
									
										Normal 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()
 | 
			
		||||
}
 | 
			
		||||
@@ -117,6 +117,7 @@ import (
 | 
			
		||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings"
 | 
			
		||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/backup"
 | 
			
		||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/database"
 | 
			
		||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/lang"
 | 
			
		||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/login"
 | 
			
		||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/profile"
 | 
			
		||||
	_ "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/settings/security"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user