Merge branch 'master' into codex/puzzle-clear-template-runtime-fixes

This commit is contained in:
kdletters
2026-06-06 20:01:52 +08:00
425 changed files with 16451 additions and 6022 deletions

View File

@@ -80,7 +80,7 @@ pub fn default_creation_entry_event_banner_snapshots() -> Vec<CreationEntryEvent
ends_at_text: String::new(),
render_mode: "html".to_string(),
html_code: Some(
r#"<section style="box-sizing:border-box;width:100%;min-height:180px;padding:28px 30px;border-radius:24px;background:#fff7ed;color:#6f2f21;font-family:system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;"><h1 style="margin:0 0 10px;font-size:28px;">创作公告</h1><p style="margin:0;font-size:16px;line-height:1.7;">这里可以在后台替换成你的公告 HTML。</p></section>"#
r#"<section style="box-sizing:border-box;width:100%;min-height:180px;padding:28px 30px;border-radius:24px;background:linear-gradient(90deg,rgba(255,247,237,0.96) 0%,rgba(255,247,237,0.82) 48%,rgba(255,247,237,0.18) 100%),url('/creation-type-references/puzzle.webp') center/cover no-repeat;color:#6f2f21;font-family:system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;"><h1 style="margin:0 0 10px;font-size:28px;">创作公告</h1><p style="margin:0;font-size:16px;line-height:1.7;">这里可以在后台替换成你的公告 HTML。</p></section>"#
.to_string(),
),
}]
@@ -233,11 +233,16 @@ pub fn resolve_creation_entry_event_banner_responses(
event_banners_json: Option<&str>,
fallback_banner: &CreationEntryEventBannerSnapshot,
) -> Vec<CreationEntryEventBannerResponse> {
event_banners_json
let banners = event_banners_json
.and_then(|raw| decode_creation_entry_event_banner_snapshots(raw).ok())
.filter(|banners| !banners.is_empty())
.unwrap_or_else(|| vec![fallback_banner.clone()])
.into_iter()
.unwrap_or_else(default_creation_entry_event_banner_snapshots);
if banners.is_empty() {
vec![fallback_banner.clone()]
} else {
banners
}
.into_iter()
.map(build_creation_entry_event_banner_response)
.collect()
}
@@ -399,9 +404,9 @@ pub fn default_creation_entry_type_snapshots(
build_default_creation_entry_type_snapshot(
"jump-hop",
"跳一跳",
"俯视角跳跃闯关",
"主题驱动平台跳跃",
"可创建",
"/creation-type-references/puzzle.webp",
"/creation-type-references/jump-hop.webp",
true,
true,
45,

View File

@@ -57,7 +57,7 @@ pub const DEFAULT_CREATION_ENTRY_CATEGORY_LABEL: &str = "热门推荐";
pub const DEFAULT_CREATION_ENTRY_EVENT_TITLE: &str = "主题创作赛";
pub const DEFAULT_CREATION_ENTRY_EVENT_DESCRIPTION: &str = "用温暖的色彩,捏出秋天的故事。";
pub const DEFAULT_CREATION_ENTRY_EVENT_COVER_IMAGE_SRC: &str =
"/branding/taonier-logo-spiral-reference-concepts/taonier-spiral-bouncy-clay.png";
"/creation-type-references/puzzle.webp";
pub const DEFAULT_CREATION_ENTRY_EVENT_PRIZE_POOL_MUD_POINTS: u64 = 58_000;
pub const DEFAULT_CREATION_ENTRY_EVENT_STARTS_AT_TEXT: &str = "2024.10.20 10:00";
pub const DEFAULT_CREATION_ENTRY_EVENT_ENDS_AT_TEXT: &str = "2024.11.20 23:59";

View File

@@ -319,6 +319,35 @@ mod tests {
assert_eq!(banners, default_creation_entry_event_banner_snapshots());
}
#[test]
fn creation_entry_event_banners_none_returns_default_announcements() {
let legacy_banner = CreationEntryEventBannerSnapshot {
title: "旧结构化横幅".to_string(),
description: "旧库单条字段".to_string(),
cover_image_src:
"/branding/taonier-logo-spiral-reference-concepts/taonier-spiral-bouncy-clay.png"
.to_string(),
prize_pool_mud_points: 58_000,
starts_at_text: "2024.10.20 10:00".to_string(),
ends_at_text: "2024.11.20 23:59".to_string(),
render_mode: "structured".to_string(),
html_code: None,
};
let banners = resolve_creation_entry_event_banner_responses(None, &legacy_banner);
assert_eq!(banners.len(), 1);
assert_eq!(banners[0].render_mode, "html");
assert_eq!(banners[0].title, "创作公告");
assert!(banners[0].html_code.as_deref().unwrap_or("").contains("创作公告"));
assert!(banners[0]
.html_code
.as_deref()
.unwrap_or("")
.contains("/creation-type-references/puzzle.webp"));
assert_ne!(banners[0].cover_image_src, legacy_banner.cover_image_src);
}
#[test]
fn creation_entry_event_banners_json_accepts_announcement_html_code() {
let normalized = normalize_creation_entry_event_banners_json(
@@ -433,6 +462,29 @@ mod tests {
assert_eq!(puzzle_clear.category_id, "recommended");
}
#[test]
fn default_creation_entry_types_include_jump_hop_theme_only_entry() {
let configs = default_creation_entry_type_snapshots(1);
let jump_hop = configs
.iter()
.find(|item| item.id == "jump-hop")
.expect("jump-hop creation entry should be seeded");
assert_eq!(jump_hop.title, "跳一跳");
assert_eq!(jump_hop.subtitle, "主题驱动平台跳跃");
assert!(jump_hop.visible);
assert!(jump_hop.open);
assert_eq!(jump_hop.badge, "可创建");
assert_eq!(jump_hop.sort_order, 45);
assert_eq!(
jump_hop.image_src,
"/creation-type-references/jump-hop.webp"
);
assert_eq!(jump_hop.category_id, "recommended");
assert_eq!(jump_hop.category_label, "热门推荐");
assert_eq!(jump_hop.category_sort_order, 20);
}
#[test]
fn normalized_clamps_music_volume_into_valid_range() {
let low = RuntimeSettings::normalized(-1.0, RuntimePlatformTheme::Light);