mirror of
https://github.com/flipped-aurora/gin-vue-admin.git
synced 2026-09-26 22:31:17 +00:00
+ Add a default language option so this language will be used as a fallback in case of no current language transaction exist for any string.
+ Add translation to "auto_code_package.go" in server module. + Add translation to "auto_code_plugin.go" in server module. + Add translation to "request.js" in web module. + Add translation to "sysDictionary.vue" in web module. + Rearrange translations file for web module.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package system
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
common "github.com/flipped-aurora/gin-vue-admin/server/model/common/request"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
||||
@@ -8,7 +10,6 @@ import (
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type AutoCodePackageApi struct{}
|
||||
@@ -30,16 +31,16 @@ func (a *AutoCodePackageApi) Create(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
if strings.Contains(info.PackageName, "\\") || strings.Contains(info.PackageName, "/") || strings.Contains(info.PackageName, "..") {
|
||||
response.FailWithMessage("包名不合法", c)
|
||||
response.FailWithMessage(global.Translate("system.auto_code_package.packageNameInvalid"), c)
|
||||
return
|
||||
} // PackageName可能导致路径穿越的问题 / 和 \ 都要防止
|
||||
err := autoCodePackageService.Create(c.Request.Context(), &info)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("创建失败!", zap.Error(err))
|
||||
response.FailWithMessage("创建失败", c)
|
||||
global.GVA_LOG.Error(global.Translate("gernal.creationFail"), zap.Error(err))
|
||||
response.FailWithMessage(global.Translate("gernal.creationFailErr"), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("创建成功", c)
|
||||
response.OkWithMessage(global.Translate("gernal.createSuccss"), c)
|
||||
}
|
||||
|
||||
// Delete
|
||||
@@ -56,11 +57,11 @@ func (a *AutoCodePackageApi) Delete(c *gin.Context) {
|
||||
_ = c.ShouldBindJSON(&info)
|
||||
err := autoCodePackageService.Delete(c.Request.Context(), info)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("删除失败!", zap.Error(err))
|
||||
response.FailWithMessage("删除失败", c)
|
||||
global.GVA_LOG.Error(global.Translate("genral.deleteFail"), zap.Error(err))
|
||||
response.FailWithMessage(global.Translate("general.deletFailErr"), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("删除成功", c)
|
||||
response.OkWithMessage(global.Translate("general.deleteSuccess"), c)
|
||||
}
|
||||
|
||||
// All
|
||||
@@ -74,11 +75,11 @@ func (a *AutoCodePackageApi) Delete(c *gin.Context) {
|
||||
func (a *AutoCodePackageApi) All(c *gin.Context) {
|
||||
data, err := autoCodePackageService.All(c.Request.Context())
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("获取失败!", zap.Error(err))
|
||||
response.FailWithMessage("获取失败", c)
|
||||
global.GVA_LOG.Error(global.Translate("global.getDataFail"), zap.Error(err))
|
||||
response.FailWithMessage(global.Translate("global.getDataFailErr"), c)
|
||||
return
|
||||
}
|
||||
response.OkWithDetailed(gin.H{"pkgs": data}, "获取成功", c)
|
||||
response.OkWithDetailed(gin.H{"pkgs": data}, global.Translate("general.getDataSuccess"), c)
|
||||
}
|
||||
|
||||
// Templates
|
||||
@@ -92,9 +93,9 @@ func (a *AutoCodePackageApi) All(c *gin.Context) {
|
||||
func (a *AutoCodePackageApi) Templates(c *gin.Context) {
|
||||
data, err := autoCodePackageService.Templates(c.Request.Context())
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("获取失败!", zap.Error(err))
|
||||
response.FailWithMessage("获取失败", c)
|
||||
global.GVA_LOG.Error(global.Translate("general.getDataFail"), zap.Error(err))
|
||||
response.FailWithMessage(global.Translate("general.getDataFailErr"), c)
|
||||
return
|
||||
}
|
||||
response.OkWithDetailed(data, "获取成功", c)
|
||||
response.OkWithDetailed(data, global.Translate("general.getDataSuccess"), c)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package system
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/global"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
|
||||
"github.com/flipped-aurora/gin-vue-admin/server/model/system/request"
|
||||
@@ -27,13 +28,13 @@ func (a *AutoCodePluginApi) Install(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
web, server, err := autoCodePluginService.Install(header)
|
||||
webStr := "web插件安装成功"
|
||||
serverStr := "server插件安装成功"
|
||||
webStr := global.Translate("system.auto_code_plugin.webPluginInstalledSuccess")
|
||||
serverStr := global.Translate("system.auto_code_plugin.serverPluginInstalledSuccess")
|
||||
if web == -1 {
|
||||
webStr = "web端插件未成功安装,请按照文档自行解压安装,如果为纯后端插件请忽略此条提示"
|
||||
webStr = global.Translate("system.auto_code_plugin.webPluginInstallFail")
|
||||
}
|
||||
if server == -1 {
|
||||
serverStr = "server端插件未成功安装,请按照文档自行解压安装,如果为纯前端插件请忽略此条提示"
|
||||
serverStr = global.Translate("system.auto_code_plugin.serverPluginInstallFail")
|
||||
}
|
||||
if err != nil {
|
||||
response.FailWithMessage(err.Error(), c)
|
||||
@@ -50,7 +51,6 @@ func (a *AutoCodePluginApi) Install(c *gin.Context) {
|
||||
}}, c)
|
||||
}
|
||||
|
||||
// Packaged
|
||||
// @Tags AutoCodePlugin
|
||||
// @Summary 打包插件
|
||||
// @Security ApiKeyAuth
|
||||
@@ -63,11 +63,11 @@ func (a *AutoCodePluginApi) Packaged(c *gin.Context) {
|
||||
plugName := c.Query("plugName")
|
||||
zipPath, err := autoCodePluginService.PubPlug(plugName)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("打包失败!", zap.Error(err))
|
||||
response.FailWithMessage("打包失败"+err.Error(), c)
|
||||
global.GVA_LOG.Error(global.Translate("system.auto_code_plugin.packingFailed"), zap.Error(err))
|
||||
response.FailWithMessage(global.Translate("system.auto_code_plugin.packingFailedError")+err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage(fmt.Sprintf("打包成功,文件路径为:%s", zipPath), c)
|
||||
response.OkWithMessage(fmt.Sprintf(global.Translate("system.auto_code_plugin.packingSuccess")+"%s", zipPath), c)
|
||||
}
|
||||
|
||||
// Packaged
|
||||
@@ -87,11 +87,11 @@ func (a *AutoCodePluginApi) InitMenu(c *gin.Context) {
|
||||
}
|
||||
err = autoCodePluginService.InitMenu(menuInfo)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("创建初始化Menu失败!", zap.Error(err))
|
||||
response.FailWithMessage("创建初始化Menu失败"+err.Error(), c)
|
||||
global.GVA_LOG.Error(global.Translate("system.auto_code_plugin.initMenuCreationFail"), zap.Error(err))
|
||||
response.FailWithMessage(global.Translate("system.auto_code_plugin.initMenuCreationFailError")+err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("文件变更成功", c)
|
||||
response.OkWithMessage(global.Translate("system.auto_code_plugin.fileChangedSuccessfully"), c)
|
||||
}
|
||||
|
||||
// Packaged
|
||||
@@ -111,9 +111,9 @@ func (a *AutoCodePluginApi) InitAPI(c *gin.Context) {
|
||||
}
|
||||
err = autoCodePluginService.InitAPI(apiInfo)
|
||||
if err != nil {
|
||||
global.GVA_LOG.Error("创建初始化API失败!", zap.Error(err))
|
||||
response.FailWithMessage("创建初始化API失败"+err.Error(), c)
|
||||
global.GVA_LOG.Error(global.Translate("system.auto_code_plugin.initApiCreationFail"), zap.Error(err))
|
||||
response.FailWithMessage(global.Translate("system.auto_code_plugin.initApiCreationFailError")+err.Error(), c)
|
||||
return
|
||||
}
|
||||
response.OkWithMessage("文件变更成功", c)
|
||||
response.OkWithMessage(global.Translate("system.auto_code_plugin.fileChangedSuccessfully"), c)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user