优化发布界面

This commit is contained in:
yml2213
2026-05-23 11:31:28 +08:00
parent ce554432c2
commit 367f26ffd1
13 changed files with 348 additions and 240 deletions
@@ -58,12 +58,15 @@ func DefaultPublishOptions() PublishOptionsDTO {
},
},
QuantityItems: []PublishQuantityItem{
{Key: "awmAmmo", Label: "AWM子弹", Price: "0.8元/发"},
{Key: "helmet6", Label: "6头数量", Price: "2元/"},
{Key: "armor6", Label: "6甲数量", Price: "3元/"},
{Key: "kit5", Label: "5级全装套数量", Price: "5元/个"},
{Key: "level6Ammo", Label: "6级子弹", Price: "0.26元/"},
{Key: "gridCard9", Label: "9格体验卡", Price: "5元/张", Placeholder: "如果是赛季9格,此处填0即可"},
{Key: "level6Ammo", Label: "6级弹", Price: "0.1元/发", Placeholder: "按单发数量填写,60发=6元"},
{Key: "awmAmmo", Label: "AWM子弹", Price: "0.6元/"},
{Key: "barrettAmmo", Label: "巴雷特子弹", Price: "0.3元/"},
{Key: "armor6", Label: "6甲", Price: "2.5元/个"},
{Key: "helmet6", Label: "6", Price: "1.5元/"},
{Key: "gridCard9", Label: "9格体验卡", Price: "3元/张", Placeholder: "如果是赛季9格,此处填0即可"},
{Key: "redPacket45", Label: "45格大红包", Price: "1.5元/个"},
{Key: "coffeeBean", Label: "高级咖啡豆", Price: "2.5元/个"},
{Key: "bulletPart", Label: "高级子弹零件", Price: "3元/个"},
},
ScreenshotSlots: []PublishScreenshotSlot{
{Key: "coin", Label: "纯币截图", Required: true, Hint: "请上传纯币截图(必传)"},
@@ -3,6 +3,7 @@ package systemconfig
import (
"encoding/json"
"errors"
"strings"
"hfb_sys/backend/internal/model"
@@ -132,11 +133,54 @@ func (r *Repository) ensureDefaults() error {
if err := tx.Clauses(clause.OnConflict{DoNothing: true}).Create(&row).Error; err != nil {
return err
}
if item.Key == publishOptionsConfigKey {
if err := updateLegacyPublishOptions(tx, item); err != nil {
return err
}
}
}
return nil
})
}
func updateLegacyPublishOptions(tx *gorm.DB, item defaultConfig) error {
var row model.SystemConfig
if err := tx.Where("`key` = ?", item.Key).First(&row).Error; err != nil {
return err
}
if !isLegacyPublishOptionsValue(row.Value) {
return nil
}
row.Value = item.Value
row.Description = item.Description
return tx.Save(&row).Error
}
func isLegacyPublishOptionsValue(value string) bool {
legacyMarkers := []string{
`"kit5"`,
"5级全装套",
"6级子弹",
"6头数量",
"6甲数量",
"0.26元/发",
"0.8元/发",
"çº",
"å¼",
"å…",
"å¤",
"ä½",
"é«",
"ï¼",
}
for _, marker := range legacyMarkers {
if strings.Contains(value, marker) {
return true
}
}
return false
}
func appendAuditLog(tx *gorm.DB, actorID uint64, action string, bizID uint64, meta AuditMeta, detail map[string]any) error {
raw, err := json.Marshal(detail)
if err != nil {
+13 -13
View File
@@ -78,9 +78,9 @@ VALUES
'ban_record', '无封禁记录',
'resources', JSON_ARRAY(
JSON_OBJECT('key', 'awmAmmo', 'label', 'AWM子弹', 'quantity', 80, 'mode', '收费'),
JSON_OBJECT('key', 'helmet6', 'label', '6头数量', 'quantity', 6, 'mode', '收费'),
JSON_OBJECT('key', 'armor6', 'label', '6甲数量', 'quantity', 4, 'mode', '收费'),
JSON_OBJECT('key', 'level6Ammo', 'label', '6级', 'quantity', 360, 'mode', '收费')
JSON_OBJECT('key', 'helmet6', 'label', '6头', 'quantity', 6, 'mode', '收费'),
JSON_OBJECT('key', 'armor6', 'label', '6甲', 'quantity', 4, 'mode', '收费'),
JSON_OBJECT('key', 'level6Ammo', 'label', '6级弹', 'quantity', 360, 'mode', '收费')
),
'skin_groups', JSON_OBJECT(
'melee', JSON_ARRAY('龙牙', '信条'),
@@ -116,7 +116,7 @@ VALUES
'ban_record', '无封禁记录',
'resources', JSON_ARRAY(
JSON_OBJECT('key', 'awmAmmo', 'label', 'AWM子弹', 'quantity', 30, 'mode', '收费'),
JSON_OBJECT('key', 'helmet6', 'label', '6头数量', 'quantity', 2, 'mode', '收费')
JSON_OBJECT('key', 'helmet6', 'label', '6头', 'quantity', 2, 'mode', '收费')
),
'skin_groups', JSON_OBJECT(
'melee', JSON_ARRAY('怜悯'),
@@ -187,9 +187,9 @@ VALUES
'ban_record', '无封禁记录',
'resources', JSON_ARRAY(
JSON_OBJECT('key', 'awmAmmo', 'label', 'AWM子弹', 'quantity', 120, 'mode', '收费'),
JSON_OBJECT('key', 'helmet6', 'label', '6头数量', 'quantity', 10, 'mode', '收费'),
JSON_OBJECT('key', 'armor6', 'label', '6甲数量', 'quantity', 8, 'mode', '收费'),
JSON_OBJECT('key', 'level6Ammo', 'label', '6级', 'quantity', 800, 'mode', '收费')
JSON_OBJECT('key', 'helmet6', 'label', '6头', 'quantity', 10, 'mode', '收费'),
JSON_OBJECT('key', 'armor6', 'label', '6甲', 'quantity', 8, 'mode', '收费'),
JSON_OBJECT('key', 'level6Ammo', 'label', '6级弹', 'quantity', 800, 'mode', '收费')
),
'skin_groups', JSON_OBJECT(
'melee', JSON_ARRAY('坠星者', '处刑者'),
@@ -225,7 +225,7 @@ VALUES
'ban_record', '无封禁记录',
'resources', JSON_ARRAY(
JSON_OBJECT('key', 'awmAmmo', 'label', 'AWM子弹', 'quantity', 80, 'mode', '赠送'),
JSON_OBJECT('key', 'kit5', 'label', '5级全装套数量', 'quantity', 6, 'mode', '收费')
JSON_OBJECT('key', 'redPacket45', 'label', '45格大红包', 'quantity', 6, 'mode', '收费')
),
'skin_groups', JSON_OBJECT(
'melee', JSON_ARRAY('影锋'),
@@ -259,8 +259,8 @@ VALUES
'online_time', JSON_OBJECT('start', '14:00', 'end', '01:00'),
'ban_record', '无封禁记录',
'resources', JSON_ARRAY(
JSON_OBJECT('key', 'kit5', 'label', '5级全装套数量', 'quantity', 3, 'mode', '收费'),
JSON_OBJECT('key', 'helmet6', 'label', '6头数量', 'quantity', 1, 'mode', '收费')
JSON_OBJECT('key', 'coffeeBean', 'label', '高级咖啡豆', 'quantity', 3, 'mode', '收费'),
JSON_OBJECT('key', 'helmet6', 'label', '6头', 'quantity', 1, 'mode', '收费')
),
'skin_groups', JSON_OBJECT(
'melee', JSON_ARRAY('北极星'),
@@ -295,8 +295,8 @@ VALUES
'ban_record', '无封禁记录',
'resources', JSON_ARRAY(
JSON_OBJECT('key', 'awmAmmo', 'label', 'AWM子弹', 'quantity', 48, 'mode', '收费'),
JSON_OBJECT('key', 'armor6', 'label', '6甲数量', 'quantity', 3, 'mode', '收费'),
JSON_OBJECT('key', 'helmet6', 'label', '6头数量', 'quantity', 4, 'mode', '收费')
JSON_OBJECT('key', 'armor6', 'label', '6甲', 'quantity', 3, 'mode', '收费'),
JSON_OBJECT('key', 'helmet6', 'label', '6头', 'quantity', 4, 'mode', '收费')
),
'skin_groups', JSON_OBJECT(
'melee', JSON_ARRAY('赤枭', '黑海'),
@@ -331,7 +331,7 @@ VALUES
'online_time', JSON_OBJECT('start', '10:00', 'end', '24:00'),
'ban_record', '无封禁记录',
'resources', JSON_ARRAY(
JSON_OBJECT('key', 'level6Ammo', 'label', '6级', 'quantity', 520, 'mode', '赠送'),
JSON_OBJECT('key', 'level6Ammo', 'label', '6级弹', 'quantity', 520, 'mode', '赠送'),
JSON_OBJECT('key', 'awmAmmo', 'label', 'AWM子弹', 'quantity', 100, 'mode', '收费'),
JSON_OBJECT('key', 'gridCard9', 'label', '9格体验卡', 'quantity', 2, 'mode', '收费')
),