发布界面优化
This commit is contained in:
@@ -148,14 +148,51 @@ func updateLegacyPublishOptions(tx *gorm.DB, item defaultConfig) error {
|
||||
if err := tx.Where("`key` = ?", item.Key).First(&row).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if !isLegacyPublishOptionsValue(row.Value) {
|
||||
if isLegacyPublishOptionsValue(row.Value) {
|
||||
row.Value = item.Value
|
||||
row.Description = item.Description
|
||||
return tx.Save(&row).Error
|
||||
}
|
||||
var options PublishOptionsDTO
|
||||
if err := json.Unmarshal([]byte(row.Value), &options); err != nil {
|
||||
row.Value = item.Value
|
||||
row.Description = item.Description
|
||||
return tx.Save(&row).Error
|
||||
}
|
||||
before := row.Value
|
||||
isOldPublishOptionsSchema := !strings.Contains(before, `"ban_record_options"`)
|
||||
normalizePublishOptions(&options)
|
||||
if isOldPublishOptionsSchema {
|
||||
applyConditionalBanEvidenceDefault(&options)
|
||||
}
|
||||
raw, err := json.Marshal(options)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
row.Value = string(raw)
|
||||
row.Description = item.Description
|
||||
if row.Value == before {
|
||||
return nil
|
||||
}
|
||||
row.Value = item.Value
|
||||
row.Description = item.Description
|
||||
return tx.Save(&row).Error
|
||||
}
|
||||
|
||||
func applyConditionalBanEvidenceDefault(options *PublishOptionsDTO) {
|
||||
defaults := DefaultPublishOptions()
|
||||
defaultSlots := make(map[string]PublishScreenshotSlot, len(defaults.ScreenshotSlots))
|
||||
for _, item := range defaults.ScreenshotSlots {
|
||||
defaultSlots[item.Key] = item
|
||||
}
|
||||
for index, item := range options.ScreenshotSlots {
|
||||
if item.Key != "tencentSecurity" {
|
||||
continue
|
||||
}
|
||||
if next, ok := defaultSlots[item.Key]; ok {
|
||||
options.ScreenshotSlots[index] = next
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func isLegacyPublishOptionsValue(value string) bool {
|
||||
legacyMarkers := []string{
|
||||
`"kit5"`,
|
||||
|
||||
Reference in New Issue
Block a user