feat: 迁移日汇总任务并修复商务菜单图标
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
package business
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
// 使用 Kra 全局注册的 Element Plus 组件名;不可直接沿用 RuoYi 的 SVG 文件名。
|
||||
var businessMenuIcons = map[string]string{
|
||||
"sw_BusMgmt": "Briefcase",
|
||||
"sw_BusinessList": "UserFilled",
|
||||
"sw_ChannelList": "Connection",
|
||||
"sw_ChannelActivationList": "CircleCheck",
|
||||
"sw_DataAnalysis": "DataAnalysis",
|
||||
"sw_ChannelDataStatistics": "Histogram",
|
||||
"sw_RechargeDetails": "Money",
|
||||
"sw_RegistrationDetails": "User",
|
||||
"sw_GameAnalytics": "TrendCharts",
|
||||
"sw_ServerAnalysis": "Monitor",
|
||||
"sw_RankingAnalysis": "Star",
|
||||
"sw_AlertCenter": "Bell",
|
||||
"sw_AlertList": "Warning",
|
||||
"sw_AlertRules": "Setting",
|
||||
}
|
||||
|
||||
func MenuIcon(name string) string { return businessMenuIcons[name] }
|
||||
|
||||
func migrateBusinessMenuIcons(db *gorm.DB) error {
|
||||
if !db.Migrator().HasTable("sys_base_menus") {
|
||||
return nil
|
||||
}
|
||||
// 仅替换旧迁移和早期模块默认值,保留管理员后来选取的其他图标。
|
||||
legacy := []string{"", "category", "email", "chart", "company", "international", "color", "dict", "cascader", "education", "excel", "star", "process-definition", "documentation", "example", "data-analysis", "user", "money", "warn"}
|
||||
return db.Transaction(func(tx *gorm.DB) error {
|
||||
for name, icon := range businessMenuIcons {
|
||||
if err := tx.Table("sys_base_menus").Where("name=? AND (icon IS NULL OR icon IN ?)", name, legacy).Update("icon", icon).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user