fix: 按契约显示统一创作表头

This commit is contained in:
2026-06-06 23:51:53 +08:00
parent 18908609fc
commit d0be3f36aa
7 changed files with 21 additions and 147 deletions

View File

@@ -122,8 +122,7 @@ fn upsert_creation_entry_type_config_in_tx(
if input.title.trim().is_empty() {
return Err("入口标题不能为空".to_string());
}
let unified_creation_spec_json =
normalize_unified_creation_spec_json(&id, input.title.trim(), &input)?;
let unified_creation_spec_json = normalize_unified_creation_spec_json(&id, &input)?;
let row = CreationEntryTypeConfig {
id: id.clone(),
title: input.title.trim().to_string(),
@@ -298,7 +297,6 @@ fn seed_creation_entry_config_if_missing(ctx: &ReducerContext) {
migrate_baby_object_match_entry_from_old_coming_soon_default(ctx, now);
migrate_wooden_fish_entry_from_old_puzzle_image_default(ctx, now);
migrate_jump_hop_entry_from_old_puzzle_default(ctx, now);
migrate_unified_creation_titles_to_entry_defaults(ctx, now);
}
fn migrate_rpg_entry_from_old_hidden_default(ctx: &ReducerContext, now: Timestamp) {
@@ -479,51 +477,6 @@ fn migrate_jump_hop_entry_from_old_puzzle_default(ctx: &ReducerContext, now: Tim
});
}
fn migrate_unified_creation_titles_to_entry_defaults(ctx: &ReducerContext, now: Timestamp) {
let rows = ctx
.db
.creation_entry_type_config()
.iter()
.collect::<Vec<_>>();
for row in rows {
let Some(raw_spec_json) = row.unified_creation_spec_json.as_deref() else {
continue;
};
let Ok(spec) =
shared_contracts::creation_entry_config::decode_unified_creation_spec_response(
raw_spec_json,
)
else {
continue;
};
let normalized =
shared_contracts::creation_entry_config::normalize_unified_creation_spec_title_for_entry(
&row.id,
&row.title,
spec.clone(),
);
if normalized.title == spec.title {
continue;
}
let Ok(unified_creation_spec_json) =
shared_contracts::creation_entry_config::encode_unified_creation_spec_response(
&normalized,
)
else {
continue;
};
ctx.db
.creation_entry_type_config()
.id()
.update(CreationEntryTypeConfig {
unified_creation_spec_json: Some(unified_creation_spec_json),
updated_at: now,
..row
});
}
}
fn default_creation_entry_type_configs(now: Timestamp) -> Vec<CreationEntryTypeConfig> {
module_runtime::default_creation_entry_type_snapshots(now.to_micros_since_unix_epoch())
.into_iter()
@@ -547,7 +500,6 @@ fn default_creation_entry_type_configs(now: Timestamp) -> Vec<CreationEntryTypeC
fn normalize_unified_creation_spec_json(
id: &str,
entry_title: &str,
input: &CreationEntryTypeAdminUpsertInput,
) -> Result<Option<String>, String> {
let Some(spec_json) = input.unified_creation_spec_json.as_deref() else {
@@ -560,12 +512,6 @@ fn normalize_unified_creation_spec_json(
let spec =
shared_contracts::creation_entry_config::decode_unified_creation_spec_response(normalized)?;
let spec =
shared_contracts::creation_entry_config::normalize_unified_creation_spec_title_for_entry(
id,
entry_title,
spec,
);
shared_contracts::creation_entry_config::validate_unified_creation_spec_for_play(id, &spec)?;
shared_contracts::creation_entry_config::encode_unified_creation_spec_response(&spec).map(Some)
}