fix: i18n特殊字符调整

This commit is contained in:
meilin.huang
2025-04-16 12:09:55 +08:00
parent 1b40d345eb
commit 585cbbed23
15 changed files with 51 additions and 44 deletions

View File

@@ -108,9 +108,9 @@ http://go.mayfly.run
如果觉得项目不错,或者已经在使用了,希望你可以去 <a target="_blank" href="https://github.com/dromara/mayfly-go">Github</a> 或者 <a target="_blank" href="https://gitee.com/dromara/mayfly-go">Gitee</a> 帮我点个 ⭐ Star这将是对我极大的鼓励与支持。 如果觉得项目不错,或者已经在使用了,希望你可以去 <a target="_blank" href="https://github.com/dromara/mayfly-go">Github</a> 或者 <a target="_blank" href="https://gitee.com/dromara/mayfly-go">Gitee</a> 帮我点个 ⭐ Star这将是对我极大的鼓励与支持。
> 喝杯咖啡 ☕️ 或者来杯奶茶 🧋,让作者更有精神,写出更棒的代码!这将是对作者最大的鼓励和支持! > 喝杯咖啡 ☕️ 或者来杯奶茶 🧋,让作者更有精神,写出更棒的代码!
<img class="no-margin" src="https://foruda.gitee.com/images/1744113367791412282/36a3c23b_1240250.png" alt="微信打赏" width="200" height="200"> <img class="no-margin" src="https://foruda.gitee.com/images/1744113367791412282/36a3c23b_1240250.png" alt="微信打赏" width="200" height="200">
> **特别感谢:** > **特别感谢:**
> 赞助金额达 199 元以上加微信wx-error我将邀请您进入付费交流群,享受更快、更优先的技术支持! > 赞助金额达 199 元以上加微信wx-error可受邀进入付费交流群,享受更快、更优先的技术支持与交流服务

View File

@@ -16,6 +16,6 @@ export default {
sendMsg: 'Send Message', sendMsg: 'Send Message',
selectTmplPlaceholder: 'Select message template, support fuzzy search by number', selectTmplPlaceholder: 'Select message template, support fuzzy search by number',
msgTmplTooltip: msgTmplTooltip:
'Message template supports variable replacement, the variable format is {{.variable}}, the following are common built-in variables <br/>{{.receiver}}: used to @ specify the recipient', "Message template supports variable replacement, the variable format is {'{{.variable}}'} </br> the following are common built-in variables <br/>{'{{.receiver}}'}: used to {'@'} specify the recipient",
}, },
}; };

View File

@@ -48,7 +48,7 @@ export default {
lastLoginTime: 'Last Login Time', lastLoginTime: 'Last Login Time',
usernamePlacholder: '5-16 uppercase letters, numbers, -.: characters', usernamePlacholder: '5-16 uppercase letters, numbers, -.: characters',
random: 'Random', random: 'Random',
usernamePatternErrMsg: 'Only 5-16 uppercase letters, numbers, and -@.: characters are allowed', usernamePatternErrMsg: "Only 5-16 uppercase letters, numbers, and -.:{'@'} characters are allowed",
accountSearchPlaceholder: 'Enter account fuzzy search and select', accountSearchPlaceholder: 'Enter account fuzzy search and select',
accountInfo: 'Account Information', accountInfo: 'Account Information',
allocateRoleTitle: 'Allocate the `{name}` role', allocateRoleTitle: 'Allocate the `{name}` role',

View File

@@ -15,6 +15,6 @@ export default {
send: '发送', send: '发送',
sendMsg: '发送消息', sendMsg: '发送消息',
selectTmplPlaceholder: '选择消息模板,支持编号模糊搜索', selectTmplPlaceholder: '选择消息模板,支持编号模糊搜索',
msgTmplTooltip: '消息模板支持变量替换,变量格式为{{.变量名}},以下为通用内置变量 <br/>{{.receiver}}:用于@指定接收人', msgTmplTooltip: "消息模板支持变量替换,变量格式为{'{{.变量名}}'},以下为通用内置变量 <br/>{'{{.receiver}}'}:用于{'@'}指定接收人",
}, },
}; };

View File

@@ -47,7 +47,7 @@ export default {
deleteAccountConfirm: '确定删除【{name}】的账号?', deleteAccountConfirm: '确定删除【{name}】的账号?',
usernamePlacholder: '5-16位大小写字母、数字、_-.:', usernamePlacholder: '5-16位大小写字母、数字、_-.:',
random: '随机', random: '随机',
usernamePatternErrMsg: '只允许输入5-16位大小写字母、数字、_-@.:', usernamePatternErrMsg: "只允许输入5-16位大小写字母、数字、_-.:{'@'}",
accountSearchPlaceholder: '输入账号模糊搜索并选择', accountSearchPlaceholder: '输入账号模糊搜索并选择',
accountInfo: '账号信息', accountInfo: '账号信息',
allocateRoleTitle: '分配 `{name}` 的角色', allocateRoleTitle: '分配 `{name}` 的角色',

View File

@@ -47,6 +47,8 @@ type DataSyncTask interface {
GetTaskLogList(condition *entity.DataSyncLogQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) GetTaskLogList(condition *entity.DataSyncLogQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error)
} }
var _ (DataSyncTask) = (*dataSyncAppImpl)(nil)
type dataSyncAppImpl struct { type dataSyncAppImpl struct {
base.AppImpl[*entity.DataSyncTask, repository.DataSyncTask] base.AppImpl[*entity.DataSyncTask, repository.DataSyncTask]
@@ -105,12 +107,14 @@ func (app *dataSyncAppImpl) AddCronJob(ctx context.Context, taskEntity *entity.D
// 根据状态添加新的任务 // 根据状态添加新的任务
if taskEntity.Status == entity.DataSyncTaskStatusEnable { if taskEntity.Status == entity.DataSyncTaskStatusEnable {
taskId := taskEntity.Id taskId := taskEntity.Id
scheduler.AddFunByKey(key, taskEntity.TaskCron, func() { if err := scheduler.AddFunByKey(key, taskEntity.TaskCron, func() {
logx.Infof("start the data synchronization task: %d", taskId) logx.Infof("start the data synchronization task: %d", taskId)
if err := app.RunCronJob(ctx, taskId); err != nil { if err := app.RunCronJob(ctx, taskId); err != nil {
logx.Errorf("the data synchronization task failed to execute at a scheduled time: %s", err.Error()) logx.Errorf("the data synchronization task failed to execute at a scheduled time: %s", err.Error())
} }
}) }); err != nil {
logx.ErrorTrace("add db data sync cron job failed", err)
}
} }
} }

View File

@@ -64,6 +64,8 @@ type DbSqlExec interface {
GetPageList(condition *entity.DbSqlExecQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error) GetPageList(condition *entity.DbSqlExecQuery, pageParam *model.PageParam, toEntity any, orderBy ...string) (*model.PageResult[any], error)
} }
var _ (DbSqlExec) = (*dbSqlExecAppImpl)(nil)
type dbSqlExecAppImpl struct { type dbSqlExecAppImpl struct {
dbApp Db `inject:"T"` dbApp Db `inject:"T"`
dbSqlExecRepo repository.DbSqlExec `inject:"T"` dbSqlExecRepo repository.DbSqlExec `inject:"T"`

View File

@@ -58,6 +58,8 @@ type DbTransferTask interface {
TimerDeleteTransferFile() TimerDeleteTransferFile()
} }
var _ (DbTransferTask) = (*dbTransferAppImpl)(nil)
type dbTransferAppImpl struct { type dbTransferAppImpl struct {
base.AppImpl[*entity.DbTransferTask, repository.DbTransferTask] base.AppImpl[*entity.DbTransferTask, repository.DbTransferTask]
@@ -114,11 +116,13 @@ func (app *dbTransferAppImpl) AddCronJob(ctx context.Context, taskEntity *entity
} }
taskId := taskEntity.Id taskId := taskEntity.Id
scheduler.AddFunByKey(key, taskEntity.Cron, func() { if err := scheduler.AddFunByKey(key, taskEntity.Cron, func() {
logx.Infof("start the synchronization task: %d", taskId) logx.Infof("start the synchronization task: %d", taskId)
logId, _ := app.CreateLog(ctx, taskId) logId, _ := app.CreateLog(ctx, taskId)
app.Run(ctx, taskId, logId) app.Run(ctx, taskId, logId)
}) }); err != nil {
logx.ErrorTrace("add db transfer cron job failed", err)
}
} }
} }

View File

@@ -165,9 +165,11 @@ func (m *machineCronJobAppImpl) addCronJob(mcj *entity.MachineCronJob) {
return return
} }
scheduler.AddFunByKey(key, mcj.Cron, func() { if err := scheduler.AddFunByKey(key, mcj.Cron, func() {
m.RunCronJob(key) m.RunCronJob(key)
}) }); err != nil {
logx.ErrorTrace("add machine cron job failed", err)
}
} }
func (m *machineCronJobAppImpl) runCronJob0(mid uint64, cronJob *entity.MachineCronJob) { func (m *machineCronJobAppImpl) runCronJob0(mid uint64, cronJob *entity.MachineCronJob) {

View File

@@ -562,15 +562,6 @@ func initResource(tx *gorm.DB) error {
Type: 2, Type: 2,
Weight: 19999999, Weight: 19999999,
}, },
{
Model: model.Model{CreateModel: model.CreateModel{DeletedModel: model.DeletedModel{IdModel: model.IdModel{Id: 30}}}},
Pid: 14,
UiPath: "Xlqig32x/sfslfel/32xax2xA/",
Name: "menu.accountEdit",
Code: "account:update",
Type: 2,
Weight: 19999999,
},
{ {
Model: model.Model{CreateModel: model.CreateModel{DeletedModel: model.DeletedModel{IdModel: model.IdModel{Id: 31}}}}, Model: model.Model{CreateModel: model.CreateModel{DeletedModel: model.DeletedModel{IdModel: model.IdModel{Id: 31}}}},
Pid: 14, Pid: 14,

View File

@@ -70,6 +70,8 @@ type App[T model.ModelI] interface {
Tx(ctx context.Context, funcs ...func(context.Context) error) (err error) Tx(ctx context.Context, funcs ...func(context.Context) error) (err error)
} }
var _ (App[*model.Model]) = (*AppImpl[*model.Model, *RepoImpl[*model.Model]])(nil)
// 基础application接口实现 // 基础application接口实现
type AppImpl[T model.ModelI, R Repo[T]] struct { type AppImpl[T model.ModelI, R Repo[T]] struct {
Repo R `inject:"T"` // repo接口, 根据类型进行注入 Repo R `inject:"T"` // repo接口, 根据类型进行注入

View File

@@ -93,6 +93,8 @@ type Repo[T model.ModelI] interface {
CountByCond(cond any) int64 CountByCond(cond any) int64
} }
var _ (Repo[*model.Model]) = (*RepoImpl[*model.Model])(nil)
// 基础repo接口 // 基础repo接口
type RepoImpl[T model.ModelI] struct { type RepoImpl[T model.ModelI] struct {
model any // 模型实例 model any // 模型实例

View File

@@ -2,7 +2,6 @@ package biz
import ( import (
"context" "context"
"fmt"
"mayfly-go/pkg/errorx" "mayfly-go/pkg/errorx"
"mayfly-go/pkg/i18n" "mayfly-go/pkg/i18n"
"mayfly-go/pkg/utils/anyx" "mayfly-go/pkg/utils/anyx"
@@ -22,7 +21,7 @@ func ErrIsNil(err error, msgAndParams ...any) {
panic(errorx.NewBiz(err.Error())) panic(errorx.NewBiz(err.Error()))
} }
panic(errorx.NewBiz(fmt.Sprintf(msgAndParams[0].(string), msgAndParams[1:]...))) panic(errorx.NewBiz(msgAndParams[0].(string), msgAndParams[1:]...))
} }
} }
@@ -44,7 +43,7 @@ func ErrIsNilI(ctx context.Context, err error, msgId i18n.MsgId, attrs ...any) {
func ErrNotNil(err error, msg string, params ...any) { func ErrNotNil(err error, msg string, params ...any) {
if err == nil { if err == nil {
panic(errorx.NewBiz(fmt.Sprintf(msg, params...))) panic(errorx.NewBiz(msg, params...))
} }
} }
@@ -54,7 +53,7 @@ func ErrNotNil(err error, msg string, params ...any) {
// biz.ErrIsNilAppendErr(err, "xxxx: %s") // biz.ErrIsNilAppendErr(err, "xxxx: %s")
func ErrIsNilAppendErr(err error, msg string) { func ErrIsNilAppendErr(err error, msg string) {
if err != nil { if err != nil {
panic(errorx.NewBiz(fmt.Sprintf(msg, err.Error()))) panic(errorx.NewBiz(msg, err.Error()))
} }
} }
@@ -64,13 +63,13 @@ func ErrIsNilAppendErr(err error, msg string) {
// biz.ErrIsNilAppendErr(err, "xxxx: %s") // biz.ErrIsNilAppendErr(err, "xxxx: %s")
func ErrIsNilAppendErrI(ctx context.Context, err error, msgId i18n.MsgId) { func ErrIsNilAppendErrI(ctx context.Context, err error, msgId i18n.MsgId) {
if err != nil { if err != nil {
panic(errorx.NewBiz(fmt.Sprintf(i18n.TC(ctx, msgId), err.Error()))) panic(errorx.NewBiz(i18n.TC(ctx, msgId), err.Error()))
} }
} }
func IsTrue(exp bool, msg string, params ...any) { func IsTrue(exp bool, msg string, params ...any) {
if !exp { if !exp {
panic(errorx.NewBiz(fmt.Sprintf(msg, params...))) panic(errorx.NewBiz(msg, params...))
} }
} }
@@ -88,19 +87,19 @@ func IsTrueBy(exp bool, err *errorx.BizError) {
func NotEmpty(str string, msg string, params ...any) { func NotEmpty(str string, msg string, params ...any) {
if str == "" { if str == "" {
panic(errorx.NewBiz(fmt.Sprintf(msg, params...))) panic(errorx.NewBiz(msg, params...))
} }
} }
func NotNil(data any, msg string, params ...any) { func NotNil(data any, msg string, params ...any) {
if reflect.ValueOf(data).IsNil() { if reflect.ValueOf(data).IsNil() {
panic(errorx.NewBiz(fmt.Sprintf(msg, params...))) panic(errorx.NewBiz(msg, params...))
} }
} }
func NotBlank(data any, msg string, params ...any) { func NotBlank(data any, msg string, params ...any) {
if anyx.IsBlank(data) { if anyx.IsBlank(data) {
panic(errorx.NewBiz(fmt.Sprintf(msg, params...))) panic(errorx.NewBiz(msg, params...))
} }
} }

View File

@@ -1,7 +1,6 @@
package scheduler package scheduler
import ( import (
"mayfly-go/pkg/biz"
"mayfly-go/pkg/logx" "mayfly-go/pkg/logx"
"sync" "sync"
@@ -25,14 +24,14 @@ func Stop() {
cronService.Stop() cronService.Stop()
} }
// 根据任务id移除 // Remove 根据任务id移除
func Remove(id cron.EntryID) { func Remove(id cron.EntryID) {
cronService.Remove(id) cronService.Remove(id)
} }
// 根据任务key移除 // RemoveByKey 根据任务key移除
func RemoveByKey(key string) { func RemoveByKey(key string) {
logx.Debugf("移除cron任务 => [key = %s]", key) logx.Debugf("remove cron func => [key = %s]", key)
id, ok := key2IdMap.Load(key) id, ok := key2IdMap.Load(key)
if ok { if ok {
Remove(id.(cron.EntryID)) Remove(id.(cron.EntryID))
@@ -44,18 +43,21 @@ func GetCron() *cron.Cron {
return cronService return cronService
} }
// 添加任务 // AddFun 添加任务
func AddFun(spec string, cmd func()) cron.EntryID { func AddFun(spec string, cmd func()) (cron.EntryID, error) {
id, err := cronService.AddFunc(spec, cmd) return cronService.AddFunc(spec, cmd)
biz.ErrIsNilAppendErr(err, "添加任务失败: %s")
return id
} }
// 根据key添加定时任务 // AddFunByKey 根据key添加定时任务
func AddFunByKey(key, spec string, cmd func()) { func AddFunByKey(key, spec string, cmd func()) error {
logx.Debugf("添加cron任务 => [key = %s]", key) logx.Debugf("add cron func => [key = %s]", key)
RemoveByKey(key) RemoveByKey(key)
key2IdMap.Store(key, AddFun(spec, cmd)) id, err := AddFun(spec, cmd)
if err != nil {
return err
}
key2IdMap.Store(key, id)
return nil
} }
func ExistKey(key string) bool { func ExistKey(key string) bool {

View File

@@ -764,7 +764,6 @@ INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`,
INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(27, 5, 'Xlqig32x/UGxla231/JExq23XK/', 2, 1, 'menu.menuPermissionEdit', 'resource:update', 30000000, 'null', 1, 'admin', 1, 'admin', '2021-05-31 18:04:03', '2024-11-07 14:04:10', 0, NULL); INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(27, 5, 'Xlqig32x/UGxla231/JExq23XK/', 2, 1, 'menu.menuPermissionEdit', 'resource:update', 30000000, 'null', 1, 'admin', 1, 'admin', '2021-05-31 18:04:03', '2024-11-07 14:04:10', 0, NULL);
INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(28, 5, 'Xlqig32x/UGxla231/Elex13XK/', 2, 1, 'menu.menuPermissionEnableDisable', 'resource:changeStatus', 40000000, 'null', 1, 'admin', 1, 'admin', '2021-05-31 18:04:33', '2024-11-07 14:04:53', 0, NULL); INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(28, 5, 'Xlqig32x/UGxla231/Elex13XK/', 2, 1, 'menu.menuPermissionEnableDisable', 'resource:changeStatus', 40000000, 'null', 1, 'admin', 1, 'admin', '2021-05-31 18:04:33', '2024-11-07 14:04:53', 0, NULL);
INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(29, 14, 'Xlqig32x/sfslfel/xlawx2xA/', 2, 1, 'menu.accountAdd', 'account:add', 19999999, 'null', 1, 'admin', 1, 'admin', '2021-05-31 19:23:42', '2024-11-07 14:11:46', 0, NULL); INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(29, 14, 'Xlqig32x/sfslfel/xlawx2xA/', 2, 1, 'menu.accountAdd', 'account:add', 19999999, 'null', 1, 'admin', 1, 'admin', '2021-05-31 19:23:42', '2024-11-07 14:11:46', 0, NULL);
INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(30, 14, 'Xlqig32x/sfslfel/32xax2xA/', 2, 1, 'menu.accountEdit', 'account:update', 19999999, 'null', 1, 'admin', 1, 'admin', '2021-05-31 19:23:58', '2024-11-07 14:11:56', 0, NULL);
INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(31, 14, 'Xlqig32x/sfslfel/eubale13/', 2, 1, 'menu.accountBase', 'account', 9999999, 'null', 1, 'admin', 1, 'admin', '2021-05-31 21:25:06', '2024-11-07 14:11:27', 0, NULL); INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(31, 14, 'Xlqig32x/sfslfel/eubale13/', 2, 1, 'menu.accountBase', 'account', 9999999, 'null', 1, 'admin', 1, 'admin', '2021-05-31 21:25:06', '2024-11-07 14:11:27', 0, NULL);
INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(32, 5, 'Xlqig32x/UGxla231/321q23XK/', 2, 1, 'menu.menuPermissionBase', 'resource', 9999999, 'null', 1, 'admin', 1, 'admin', '2021-05-31 21:25:25', '2024-11-07 14:03:59', 0, NULL); INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(32, 5, 'Xlqig32x/UGxla231/321q23XK/', 2, 1, 'menu.menuPermissionBase', 'resource', 9999999, 'null', 1, 'admin', 1, 'admin', '2021-05-31 21:25:25', '2024-11-07 14:03:59', 0, NULL);
INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(33, 11, 'Xlqig32x/lxqSiae1/908xKxq3/', 2, 1, 'menu.roleBase', 'role', 9999999, 'null', 1, 'admin', 1, 'admin', '2021-05-31 21:25:40', '2024-11-07 14:13:03', 0, NULL); INSERT INTO `t_sys_resource` (`id`, `pid`, `ui_path`, `type`, `status`, `name`, `code`, `weight`, `meta`, `creator_id`, `creator`, `modifier_id`, `modifier`, `create_time`, `update_time`, `is_deleted`, `delete_time`) values(33, 11, 'Xlqig32x/lxqSiae1/908xKxq3/', 2, 1, 'menu.roleBase', 'role', 9999999, 'null', 1, 'admin', 1, 'admin', '2021-05-31 21:25:40', '2024-11-07 14:13:03', 0, NULL);