mirror of
https://github.com/yhl452493373/frpc-panel.git
synced 2026-04-04 06:17:00 +08:00
add i18n translations
This commit is contained in:
@@ -55,5 +55,15 @@
|
|||||||
"Local Port": "Local Port",
|
"Local Port": "Local Port",
|
||||||
"Operation": "Operation",
|
"Operation": "Operation",
|
||||||
"Confirm": "Confirm",
|
"Confirm": "Confirm",
|
||||||
"Cancel": "Cancel"
|
"Cancel": "Cancel",
|
||||||
|
"Token Invalid": "Token invalid",
|
||||||
|
"Operate Success": "Operate success",
|
||||||
|
"Operate Failed": "Operate failed",
|
||||||
|
"Should Check Proxy": "You should check at least one proxy",
|
||||||
|
"Confirm Remove Proxy": "Confirm to remove proxy ?",
|
||||||
|
"Operation Confirm": "Operation confirm",
|
||||||
|
"Param Error": "Param error",
|
||||||
|
"Frp Client Error": "Frp client error",
|
||||||
|
"Proxy Exist,": "Proxy name exist",
|
||||||
|
"Proxy Not Exist": "Proxy name not exist"
|
||||||
}
|
}
|
||||||
@@ -55,5 +55,15 @@
|
|||||||
"Local Port": "本地端口",
|
"Local Port": "本地端口",
|
||||||
"Operation": "操作",
|
"Operation": "操作",
|
||||||
"Confirm": "确定",
|
"Confirm": "确定",
|
||||||
"Cancel": "取消"
|
"Cancel": "取消",
|
||||||
|
"Token Invalid": "登录信息无效",
|
||||||
|
"Operate Success": "操作成功",
|
||||||
|
"Operate Failed": "操作失败",
|
||||||
|
"Should Check Proxy": "请选中需要操作的代理",
|
||||||
|
"Confirm Remove Proxy": "确定删除代理?",
|
||||||
|
"Operation Confirm": "操作确认",
|
||||||
|
"Param Error": "参数错误",
|
||||||
|
"Frp Client Error": "Frp客户端错误",
|
||||||
|
"Proxy Exist": "代理名称重复",
|
||||||
|
"Proxy Not Exist": "代理名称不存在"
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ var loadClientInfo = (function ($) {
|
|||||||
type: 'none'
|
type: 'none'
|
||||||
}).done(function (result) {
|
}).done(function (result) {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
renderCommonInfo(result.data);
|
renderClientInfo(result.data);
|
||||||
} else {
|
} else {
|
||||||
layui.layer.msg(result.message);
|
layui.layer.msg(result.message);
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ var loadClientInfo = (function ($) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderCommonInfo(data) {
|
function renderClientInfo(data) {
|
||||||
data.tcp_mux = i18n[data.tcp_mux];
|
data.tcp_mux = i18n[data.tcp_mux];
|
||||||
data.tls_enable = i18n[data.tls_enable];
|
data.tls_enable = i18n[data.tls_enable];
|
||||||
var html = layui.laytpl($('#clientInfoTemplate').html()).render(data);
|
var html = layui.laytpl($('#clientInfoTemplate').html()).render(data);
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ var loadProxyInfo = (function ($) {
|
|||||||
if (result.success) {
|
if (result.success) {
|
||||||
reloadTable();
|
reloadTable();
|
||||||
layui.layer.close(index);
|
layui.layer.close(index);
|
||||||
layui.layer.msg('OperateSuccess', function (index) {
|
layui.layer.msg(i18n['OperateSuccess'], function (index) {
|
||||||
layui.layer.close(index);
|
layui.layer.close(index);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -252,11 +252,11 @@ var loadProxyInfo = (function ($) {
|
|||||||
*/
|
*/
|
||||||
function batchRemovePopup(data) {
|
function batchRemovePopup(data) {
|
||||||
if (data.length === 0) {
|
if (data.length === 0) {
|
||||||
layui.layer.msg('ShouldCheckProxy');
|
layui.layer.msg(i18n['ShouldCheckProxy']);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
layui.layer.confirm('ConfirmRemoveProxy', {
|
layui.layer.confirm(i18n['ConfirmRemoveProxy'], {
|
||||||
title: 'OperationConfirm',
|
title: i18n['OperationConfirm'],
|
||||||
btn: [i18n['Confirm'], i18n['Cancel']]
|
btn: [i18n['Confirm'], i18n['Cancel']]
|
||||||
}, function (index) {
|
}, function (index) {
|
||||||
var loading = layui.layer.load();
|
var loading = layui.layer.load();
|
||||||
@@ -269,7 +269,7 @@ var loadProxyInfo = (function ($) {
|
|||||||
if (result.success) {
|
if (result.success) {
|
||||||
reloadTable();
|
reloadTable();
|
||||||
layui.layer.close(index);
|
layui.layer.close(index);
|
||||||
layui.layer.msg('OperateSuccess', function (index) {
|
layui.layer.msg(i18n['OperateSuccess'], function (index) {
|
||||||
layui.layer.close(index);
|
layui.layer.close(index);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -295,19 +295,16 @@ var loadProxyInfo = (function ($) {
|
|||||||
* @param result
|
* @param result
|
||||||
*/
|
*/
|
||||||
function errorMsg(result) {
|
function errorMsg(result) {
|
||||||
layui.layer.msg(result.message);
|
var reason = i18n['OtherError'];
|
||||||
// var reason = i18n['OtherError'];
|
if (result.code === 1)
|
||||||
// if (result.code === 1)
|
reason = i18n['ParamError'];
|
||||||
// reason = i18n['ParamError'];
|
else if (result.code === 2)
|
||||||
// else if (result.code === 2)
|
reason = i18n['FrpClientError'];
|
||||||
// reason = i18n['SaveError'];
|
else if (result.code === 3)
|
||||||
// else if (result.code === 3)
|
reason = i18n['ProxyExist'];
|
||||||
// reason = i18n['FrpServerError'];
|
else if (result.code === 4)
|
||||||
// else if (result.code === 4)
|
reason = i18n['ProxyNotExist'];
|
||||||
// reason = i18n['ProxyExist'];
|
layui.layer.msg(i18n['OperateFailed'] + ',' + reason)
|
||||||
// else if (result.code === 5)
|
|
||||||
// reason = i18n['ProxyNotExist'];
|
|
||||||
// layui.layer.msg(i18n['OperateFailed'] + ',' + reason)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return loadProxyInfo;
|
return loadProxyInfo;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
var http_port, https_port;
|
|
||||||
(function ($) {
|
(function ($) {
|
||||||
$(function () {
|
$(function () {
|
||||||
function init() {
|
function init() {
|
||||||
|
|||||||
@@ -153,7 +153,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="layui-tab-content">
|
<div class="layui-tab-content">
|
||||||
<input type="hidden" name="type">
|
<input type="hidden" name="type">
|
||||||
<input type="hidden" name="${ .oldNameKey }" id="oldName">
|
<input type="hidden" name="${ .OldNameKey }" id="oldName">
|
||||||
<div class="layui-tab-item layui-show">
|
<div class="layui-tab-item layui-show">
|
||||||
<div class="layui-form-item">
|
<div class="layui-form-item">
|
||||||
<label class="layui-form-label">${ .ProxyName }</label>
|
<label class="layui-form-label">${ .ProxyName }</label>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func (c *HandleController) MakeIndexFunc() func(context *gin.Context) {
|
|||||||
return func(context *gin.Context) {
|
return func(context *gin.Context) {
|
||||||
context.HTML(http.StatusOK, "index.html", gin.H{
|
context.HTML(http.StatusOK, "index.html", gin.H{
|
||||||
"version": c.Version,
|
"version": c.Version,
|
||||||
"oldNameKey": oldNameKey,
|
"OldNameKey": OldNameKey,
|
||||||
"showExit": trimString(c.CommonInfo.AdminUser) != "" && trimString(c.CommonInfo.AdminPwd) != "",
|
"showExit": trimString(c.CommonInfo.AdminUser) != "" && trimString(c.CommonInfo.AdminPwd) != "",
|
||||||
"FrpcPanel": ginI18n.MustGetMessage(context, "Frpc Panel"),
|
"FrpcPanel": ginI18n.MustGetMessage(context, "Frpc Panel"),
|
||||||
"ClientInfo": ginI18n.MustGetMessage(context, "Client Info"),
|
"ClientInfo": ginI18n.MustGetMessage(context, "Client Info"),
|
||||||
@@ -103,22 +103,32 @@ func (c *HandleController) MakeIndexFunc() func(context *gin.Context) {
|
|||||||
func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
|
func (c *HandleController) MakeLangFunc() func(context *gin.Context) {
|
||||||
return func(context *gin.Context) {
|
return func(context *gin.Context) {
|
||||||
context.JSON(http.StatusOK, gin.H{
|
context.JSON(http.StatusOK, gin.H{
|
||||||
"EmptyData": ginI18n.MustGetMessage(context, "Empty data"),
|
"EmptyData": ginI18n.MustGetMessage(context, "Empty data"),
|
||||||
"true": ginI18n.MustGetMessage(context, "true"),
|
"true": ginI18n.MustGetMessage(context, "true"),
|
||||||
"false": ginI18n.MustGetMessage(context, "false"),
|
"false": ginI18n.MustGetMessage(context, "false"),
|
||||||
"Name": ginI18n.MustGetMessage(context, "Name"),
|
"Name": ginI18n.MustGetMessage(context, "Name"),
|
||||||
"Type": ginI18n.MustGetMessage(context, "Type"),
|
"Type": ginI18n.MustGetMessage(context, "Type"),
|
||||||
"LocalAddress": ginI18n.MustGetMessage(context, "Local Address"),
|
"LocalAddress": ginI18n.MustGetMessage(context, "Local Address"),
|
||||||
"Plugin": ginI18n.MustGetMessage(context, "Plugin"),
|
"Plugin": ginI18n.MustGetMessage(context, "Plugin"),
|
||||||
"RemoteAddress": ginI18n.MustGetMessage(context, "Remote Address"),
|
"RemoteAddress": ginI18n.MustGetMessage(context, "Remote Address"),
|
||||||
"Status": ginI18n.MustGetMessage(context, "Status"),
|
"Status": ginI18n.MustGetMessage(context, "Status"),
|
||||||
"Info": ginI18n.MustGetMessage(context, "Info"),
|
"Info": ginI18n.MustGetMessage(context, "Info"),
|
||||||
"running": ginI18n.MustGetMessage(context, "running"),
|
"running": ginI18n.MustGetMessage(context, "running"),
|
||||||
"LocalIp": ginI18n.MustGetMessage(context, "Local Ip"),
|
"LocalIp": ginI18n.MustGetMessage(context, "Local Ip"),
|
||||||
"LocalPort": ginI18n.MustGetMessage(context, "Local Port"),
|
"LocalPort": ginI18n.MustGetMessage(context, "Local Port"),
|
||||||
"Operation": ginI18n.MustGetMessage(context, "Operation"),
|
"Operation": ginI18n.MustGetMessage(context, "Operation"),
|
||||||
"Confirm": ginI18n.MustGetMessage(context, "Confirm"),
|
"Confirm": ginI18n.MustGetMessage(context, "Confirm"),
|
||||||
"Cancel": ginI18n.MustGetMessage(context, "Cancel"),
|
"Cancel": ginI18n.MustGetMessage(context, "Cancel"),
|
||||||
|
"TokenInvalid": ginI18n.MustGetMessage(context, "Token Invalid"),
|
||||||
|
"OperateSuccess": ginI18n.MustGetMessage(context, "Operate Success"),
|
||||||
|
"OperateFailed": ginI18n.MustGetMessage(context, "Operate Failed"),
|
||||||
|
"ShouldCheckProxy": ginI18n.MustGetMessage(context, "Should Check Proxy"),
|
||||||
|
"ConfirmRemoveProxy": ginI18n.MustGetMessage(context, "Confirm Remove Proxy"),
|
||||||
|
"OperationConfirm": ginI18n.MustGetMessage(context, "Operation Confirm"),
|
||||||
|
"ParamError": ginI18n.MustGetMessage(context, "Param Error"),
|
||||||
|
"FrpClientError": ginI18n.MustGetMessage(context, "Frp Client Error"),
|
||||||
|
"ProxyExist": ginI18n.MustGetMessage(context, "Proxy Exist"),
|
||||||
|
"ProxyNotExist": ginI18n.MustGetMessage(context, "Proxy Not Exist"),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +153,7 @@ func (c *HandleController) MakeAddProxyFunc() func(context *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
name := proxy[nameKey]
|
name := proxy[NameKey]
|
||||||
|
|
||||||
if trimString(name) == "" {
|
if trimString(name) == "" {
|
||||||
response.Success = false
|
response.Success = false
|
||||||
@@ -163,13 +173,13 @@ func (c *HandleController) MakeAddProxyFunc() func(context *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(proxy, nameKey)
|
delete(proxy, NameKey)
|
||||||
clientProxies[name] = proxy
|
clientProxies[name] = proxy
|
||||||
|
|
||||||
res := c.UpdateFrpcConfig()
|
res := c.UpdateFrpcConfig()
|
||||||
if !res.Success {
|
if !res.Success {
|
||||||
response.Success = false
|
response.Success = false
|
||||||
response.Code = SaveError
|
response.Code = res.Code
|
||||||
response.Message = fmt.Sprintf("proxy add failed, error : %v", res.Message)
|
response.Message = fmt.Sprintf("proxy add failed, error : %v", res.Message)
|
||||||
log.Printf(response.Message)
|
log.Printf(response.Message)
|
||||||
context.JSON(http.StatusOK, &response)
|
context.JSON(http.StatusOK, &response)
|
||||||
@@ -200,8 +210,8 @@ func (c *HandleController) MakeUpdateProxyFunc() func(context *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
oldName := proxy[oldNameKey]
|
oldName := proxy[OldNameKey]
|
||||||
name := proxy[nameKey]
|
name := proxy[NameKey]
|
||||||
|
|
||||||
if trimString(oldName) == "" || trimString(name) == "" {
|
if trimString(oldName) == "" || trimString(name) == "" {
|
||||||
response.Success = false
|
response.Success = false
|
||||||
@@ -212,6 +222,15 @@ func (c *HandleController) MakeUpdateProxyFunc() func(context *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if _, exist := clientProxies[oldName]; !exist {
|
||||||
|
response.Success = false
|
||||||
|
response.Code = ProxyNotExist
|
||||||
|
response.Message = fmt.Sprintf("proxy update failed, proxy not exist")
|
||||||
|
log.Printf(response.Message)
|
||||||
|
context.JSON(http.StatusOK, &response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if oldName != name {
|
if oldName != name {
|
||||||
if _, exist := clientProxies[name]; exist {
|
if _, exist := clientProxies[name]; exist {
|
||||||
response.Success = false
|
response.Success = false
|
||||||
@@ -223,15 +242,15 @@ func (c *HandleController) MakeUpdateProxyFunc() func(context *gin.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(proxy, nameKey)
|
delete(proxy, NameKey)
|
||||||
delete(proxy, oldNameKey)
|
delete(proxy, OldNameKey)
|
||||||
delete(clientProxies, oldName)
|
delete(clientProxies, oldName)
|
||||||
clientProxies[name] = proxy
|
clientProxies[name] = proxy
|
||||||
|
|
||||||
res := c.UpdateFrpcConfig()
|
res := c.UpdateFrpcConfig()
|
||||||
if !res.Success {
|
if !res.Success {
|
||||||
response.Success = false
|
response.Success = false
|
||||||
response.Code = SaveError
|
response.Code = res.Code
|
||||||
response.Message = fmt.Sprintf("user update failed, error : %v", res.Message)
|
response.Message = fmt.Sprintf("user update failed, error : %v", res.Message)
|
||||||
log.Printf(response.Message)
|
log.Printf(response.Message)
|
||||||
context.JSON(http.StatusOK, &response)
|
context.JSON(http.StatusOK, &response)
|
||||||
@@ -264,7 +283,7 @@ func (c *HandleController) MakeRemoveProxyFunc() func(context *gin.Context) {
|
|||||||
|
|
||||||
tempProxyNames := make([]string, len(proxies))
|
tempProxyNames := make([]string, len(proxies))
|
||||||
for index, proxy := range proxies {
|
for index, proxy := range proxies {
|
||||||
name := proxy[nameKey]
|
name := proxy[NameKey]
|
||||||
|
|
||||||
if trimString(name) == "" {
|
if trimString(name) == "" {
|
||||||
response.Success = false
|
response.Success = false
|
||||||
@@ -294,7 +313,7 @@ func (c *HandleController) MakeRemoveProxyFunc() func(context *gin.Context) {
|
|||||||
res := c.UpdateFrpcConfig()
|
res := c.UpdateFrpcConfig()
|
||||||
if !res.Success {
|
if !res.Success {
|
||||||
response.Success = false
|
response.Success = false
|
||||||
response.Code = SaveError
|
response.Code = res.Code
|
||||||
response.Message = fmt.Sprintf("proxy remvoe failed, error : %v", res.Message)
|
response.Message = fmt.Sprintf("proxy remvoe failed, error : %v", res.Message)
|
||||||
log.Printf(response.Message)
|
log.Printf(response.Message)
|
||||||
context.JSON(http.StatusOK, &response)
|
context.JSON(http.StatusOK, &response)
|
||||||
@@ -314,7 +333,7 @@ func (c *HandleController) MakeProxyFunc() func(context *gin.Context) {
|
|||||||
response, err := c.getClientResponse(request, c.buildClient())
|
response, err := c.getClientResponse(request, c.buildClient())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.Code = FrpServerError
|
res.Code = FrpClientError
|
||||||
res.Success = false
|
res.Success = false
|
||||||
res.Message = err.Error()
|
res.Message = err.Error()
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
@@ -348,7 +367,7 @@ func (c *HandleController) UpdateFrpcConfig() ProxyResponse {
|
|||||||
response, err := c.getClientResponse(request, c.buildClient())
|
response, err := c.getClientResponse(request, c.buildClient())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.Code = FrpServerError
|
res.Code = FrpClientError
|
||||||
res.Success = false
|
res.Success = false
|
||||||
res.Message = err.Error()
|
res.Message = err.Error()
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
@@ -368,7 +387,7 @@ func (c *HandleController) ReloadFrpcConfig(res *ProxyResponse) {
|
|||||||
response, err := c.getClientResponse(request, c.buildClient())
|
response, err := c.getClientResponse(request, c.buildClient())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.Code = FrpServerError
|
res.Code = FrpClientError
|
||||||
res.Success = false
|
res.Success = false
|
||||||
res.Message = err.Error()
|
res.Message = err.Error()
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ func (c *HandleController) parseConfigure(content, proxyType string) (interface{
|
|||||||
currentProxies[name] = section
|
currentProxies[name] = section
|
||||||
}
|
}
|
||||||
clientProxies[name] = section
|
clientProxies[name] = section
|
||||||
delete(clientProxies[name], nameKey)
|
delete(clientProxies[name], NameKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
if proxyType == "none" {
|
if proxyType == "none" {
|
||||||
|
|||||||
@@ -7,24 +7,14 @@ import (
|
|||||||
const (
|
const (
|
||||||
Success int = iota
|
Success int = iota
|
||||||
ParamError
|
ParamError
|
||||||
SaveError
|
FrpClientError
|
||||||
FrpServerError
|
|
||||||
ProxyExist
|
ProxyExist
|
||||||
ProxyNotExist
|
ProxyNotExist
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ProxyAdd int = iota
|
NameKey = "name"
|
||||||
ProxyUpdate
|
OldNameKey = "_old_name"
|
||||||
ProxyRemove
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
nameKey = "name"
|
|
||||||
oldNameKey = "_old_name"
|
|
||||||
)
|
|
||||||
|
|
||||||
const (
|
|
||||||
SessionName = "GOSESSION"
|
SessionName = "GOSESSION"
|
||||||
AuthName = "_PANEL_AUTH"
|
AuthName = "_PANEL_AUTH"
|
||||||
LoginUrl = "/login"
|
LoginUrl = "/login"
|
||||||
|
|||||||
Reference in New Issue
Block a user