feat: add puzzle clear template runtime

This commit is contained in:
2026-06-03 22:11:46 +08:00
parent 6e74cf5add
commit 1b5e098225
148 changed files with 19588 additions and 241 deletions

View File

@@ -1,4 +1,5 @@
use crate::puzzle::{PuzzleGalleryCardViewRow, puzzle_gallery_card_view, puzzle_gallery_view};
use crate::puzzle_clear::{puzzle_clear_gallery_card_view, puzzle_clear_gallery_view};
use crate::*;
use module_custom_world::{CustomWorldGalleryEntrySnapshot, CustomWorldProfileSnapshot};
use module_puzzle::PuzzleWorkProfile;
@@ -17,6 +18,11 @@ pub fn public_work_gallery_entry(ctx: &AnonymousViewContext) -> Vec<PublicWorkGa
.into_iter()
.map(map_puzzle_gallery_entry),
);
entries.extend(
puzzle_clear_gallery_card_view(ctx)
.into_iter()
.map(map_puzzle_clear_gallery_entry),
);
entries.extend(
custom_world_public_gallery_snapshots(ctx)
.into_iter()
@@ -74,6 +80,11 @@ pub fn public_work_detail_entry(ctx: &AnonymousViewContext) -> Vec<PublicWorkDet
.into_iter()
.map(map_puzzle_detail_entry),
);
entries.extend(
puzzle_clear_gallery_view(ctx)
.into_iter()
.map(map_puzzle_clear_detail_entry),
);
entries.extend(
custom_world_public_profile_snapshots(ctx)
.into_iter()
@@ -273,6 +284,65 @@ fn map_puzzle_detail_entry(row: PuzzleWorkProfile) -> PublicWorkDetailEntry {
gallery_to_detail(entry, detail_payload_json)
}
fn map_puzzle_clear_gallery_entry(row: PuzzleClearGalleryCardViewRow) -> PublicWorkGalleryEntry {
let sort_time_micros = row.published_at_micros.unwrap_or(row.updated_at_micros);
PublicWorkGalleryEntry {
source_type: "puzzle-clear".to_string(),
work_id: row.work_id,
profile_id: row.profile_id,
source_session_id: None,
public_work_code: row.public_work_code,
owner_user_id: row.owner_user_id,
author_display_name: row.author_display_name,
world_name: row.work_title,
subtitle: "拼消消".to_string(),
summary_text: row.work_description,
cover_image_src: row.cover_image_src,
cover_asset_id: None,
theme_tags: fallback_tags(vec![row.theme_prompt], &["拼消消"]),
play_count: row.play_count,
remix_count: 0,
like_count: 0,
published_at_micros: row.published_at_micros,
updated_at_micros: row.updated_at_micros,
sort_time_micros,
}
}
fn map_puzzle_clear_detail_entry(row: PuzzleClearGalleryViewRow) -> PublicWorkDetailEntry {
let entry = PublicWorkGalleryEntry {
source_type: "puzzle-clear".to_string(),
work_id: row.work_id,
profile_id: row.profile_id.clone(),
source_session_id: empty_string_to_option(row.source_session_id),
public_work_code: build_prefixed_public_work_code("PC", &row.profile_id),
owner_user_id: row.owner_user_id,
author_display_name: row.author_display_name,
world_name: row.work_title,
subtitle: "拼消消".to_string(),
summary_text: row.work_description,
cover_image_src: row.cover_image_src,
cover_asset_id: None,
theme_tags: fallback_tags(vec![row.theme_prompt.clone()], &["拼消消"]),
play_count: row.play_count,
remix_count: 0,
like_count: 0,
published_at_micros: row.published_at_micros,
updated_at_micros: row.updated_at_micros,
sort_time_micros: row.published_at_micros.unwrap_or(row.updated_at_micros),
};
let detail_payload_json = json_string(json!({
"sourceType": "puzzle-clear",
"themePrompt": row.theme_prompt,
"patternGroupCount": row.pattern_groups.len(),
"cardAssetCount": row.card_assets.len(),
"generationStatus": row.generation_status,
"hasBoardBackground": row.board_background_asset.is_some(),
}));
gallery_to_detail(entry, detail_payload_json)
}
fn map_custom_world_gallery_entry(row: CustomWorldGalleryEntrySnapshot) -> PublicWorkGalleryEntry {
PublicWorkGalleryEntry {
source_type: "custom-world".to_string(),