mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-03 20:40:26 +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"
|
||||
|
||||
2
web/public/js/langs/base.js
Normal file
2
web/public/js/langs/base.js
Normal file
@@ -0,0 +1,2 @@
|
||||
// generated by 'langs generate'
|
||||
window.LANG_MESSAGES_BASE = {"admin_dashboard@ui_dns":"DNS","admin_dashboard@ui_events":"事件","admin_dashboard@ui_overview":"概况","admin_dashboard@ui_user":"用户","admin_dashboard@ui_waf":"WAF"};
|
||||
5
web/public/js/langs/en-us.css
Normal file
5
web/public/js/langs/en-us.css
Normal file
@@ -0,0 +1,5 @@
|
||||
.main-menu .menu .item {
|
||||
font-size: 0.9em;
|
||||
line-height: 1.3;
|
||||
}
|
||||
/*# sourceMappingURL=en-us.css.map */
|
||||
1
web/public/js/langs/en-us.css.map
Normal file
1
web/public/js/langs/en-us.css.map
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"sources":["en-us.less"],"names":[],"mappings":"AAAA,UACC,MACC;EACC,gBAAA;EACA,gBAAA","file":"en-us.css"}
|
||||
2
web/public/js/langs/en-us.js
Normal file
2
web/public/js/langs/en-us.js
Normal file
@@ -0,0 +1,2 @@
|
||||
// generated by 'langs generate'
|
||||
window.LANG_MESSAGES = {};
|
||||
8
web/public/js/langs/en-us.less
Normal file
8
web/public/js/langs/en-us.less
Normal file
@@ -0,0 +1,8 @@
|
||||
.main-menu {
|
||||
.menu {
|
||||
.item {
|
||||
font-size: 0.9em;
|
||||
line-height: 1.3;
|
||||
}
|
||||
}
|
||||
}
|
||||
0
web/public/js/langs/zh-cn.css
Normal file
0
web/public/js/langs/zh-cn.css
Normal file
@@ -19,7 +19,9 @@
|
||||
<script type="text/javascript" src="/js/utils.min.js"></script>
|
||||
<script type="text/javascript" src="/js/sweetalert2/dist/sweetalert2.all.min.js" async></script>
|
||||
<script type="text/javascript" src="/js/date.tea.js"></script>
|
||||
<script type="text/javascript" src="/js/langs/{$.teaLang}.js?v=1.2.0"></script>
|
||||
<script type="text/javascript" src="/js/langs/base.js?v=1.2.0"></script>
|
||||
<script type="text/javascript" src="/js/langs/{$.teaLang}.js?v=1.3.2"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/js/langs/{$.teaLang}.css?v=1.3.2"/>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/_/@default/@layout_override.css" media="all"/>
|
||||
</head>
|
||||
@@ -60,6 +62,8 @@
|
||||
<span class="hover-span"><span class="disabled">{{teaUsername}}</span></span>
|
||||
</a>
|
||||
|
||||
<a href="" class="item" title="switch language" @click.prevent="switchLang"><i class="icon language"></i> </a>
|
||||
|
||||
<!-- 背景颜色 -->
|
||||
<a href="" class="item" title="点击切换界面风格" @click.prevent="changeTheme()"><i class="icon adjust"></i></a>
|
||||
|
||||
|
||||
@@ -205,8 +205,21 @@ Tea.context(function () {
|
||||
return message
|
||||
}
|
||||
}
|
||||
if (window.LANG_MESSAGES_BASE != null) {
|
||||
let message = window.LANG_MESSAGES_BASE[code]
|
||||
if (typeof message == "string") {
|
||||
return message
|
||||
}
|
||||
}
|
||||
return "{{ LANG('" + code + "') }}"
|
||||
}
|
||||
|
||||
this.switchLang = function () {
|
||||
this.$post("/settings/lang/switch")
|
||||
.success(function () {
|
||||
window.location.reload()
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
window.NotifySuccess = function (message, url, params) {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
{$layout}
|
||||
|
||||
<warning-message v-if="serverIsChanged">服务配置已修改,请在命令行下重启后生效。</warning-message>
|
||||
<div v-if="serverIsChanged">
|
||||
<div class="margin"></div>
|
||||
<warning-message>服务配置已修改,请在命令行下重启后生效(<code-label>edge-admin restart</code-label>)。</warning-message>
|
||||
</div>
|
||||
|
||||
<h3>HTTP <a href="/settings/server/http" v-if="!teaDemoEnabled" @click.prevent="updateHTTP()">修改</a><a v-if="teaDemoEnabled">[演示版无法修改]</a></h3>
|
||||
<h3>通过HTTP访问管理平台 <a href="/settings/server/http" v-if="!teaDemoEnabled" @click.prevent="updateHTTP()">修改</a><a v-if="teaDemoEnabled">[演示版无法修改]</a></h3>
|
||||
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
@@ -22,7 +25,7 @@
|
||||
|
||||
<div class="ui divider"></div>
|
||||
|
||||
<h3>HTTPS <a href="" v-if="!teaDemoEnabled" @click.prevent="updateHTTPS()">修改</a><a v-if="teaDemoEnabled">[演示版无法修改]</a></h3>
|
||||
<h3>通过HTTPS访问管理平台 <a href="" v-if="!teaDemoEnabled" @click.prevent="updateHTTPS()">修改</a><a v-if="teaDemoEnabled">[演示版无法修改]</a></h3>
|
||||
<table class="ui table definition selectable">
|
||||
<tr>
|
||||
<td>状态</td>
|
||||
|
||||
Reference in New Issue
Block a user