Merge branch 'codex/profile-mobile-ui-reference'

This commit is contained in:
2026-05-25 01:41:05 +08:00
74 changed files with 5512 additions and 1090 deletions

View File

@@ -251,6 +251,9 @@ fn map_admin_creation_entry_type_config(
visible: entry.visible,
open: entry.open,
sort_order: entry.sort_order,
category_id: entry.category_id,
category_label: entry.category_label,
category_sort_order: entry.category_sort_order,
updated_at_micros: entry.updated_at_micros,
}
}
@@ -275,6 +278,9 @@ fn validate_admin_creation_entry_config(
visible: payload.visible,
open: payload.open,
sort_order: payload.sort_order,
category_id: payload.category_id.trim().to_string(),
category_label: payload.category_label.trim().to_string(),
category_sort_order: payload.category_sort_order,
})
}

View File

@@ -143,6 +143,15 @@ pub(crate) fn default_creation_entry_config_response() -> CreationEntryConfigRes
title: module_runtime::DEFAULT_CREATION_ENTRY_MODAL_TITLE.to_string(),
description: module_runtime::DEFAULT_CREATION_ENTRY_MODAL_DESCRIPTION.to_string(),
},
event_banner: module_runtime::CreationEntryEventBannerSnapshot {
title: module_runtime::DEFAULT_CREATION_ENTRY_EVENT_TITLE.to_string(),
description: module_runtime::DEFAULT_CREATION_ENTRY_EVENT_DESCRIPTION.to_string(),
cover_image_src: module_runtime::DEFAULT_CREATION_ENTRY_EVENT_COVER_IMAGE_SRC
.to_string(),
prize_pool_mud_points: module_runtime::DEFAULT_CREATION_ENTRY_EVENT_PRIZE_POOL_MUD_POINTS,
starts_at_text: module_runtime::DEFAULT_CREATION_ENTRY_EVENT_STARTS_AT_TEXT.to_string(),
ends_at_text: module_runtime::DEFAULT_CREATION_ENTRY_EVENT_ENDS_AT_TEXT.to_string(),
},
creation_types: module_runtime::default_creation_entry_type_snapshots(0),
updated_at_micros: 0,
})
@@ -259,5 +268,8 @@ mod tests {
assert!(baby_object_match.open);
assert_eq!(baby_object_match.badge, "\u{53ef}\u{521b}\u{5efa}");
assert_eq!(baby_object_match.sort_order, 90);
assert_eq!(baby_object_match.category_id, "character");
assert_eq!(baby_object_match.category_label, "\u{89d2}\u{8272}\u{521b}\u{4f5c}");
assert_eq!(baby_object_match.category_sort_order, 40);
}
}

View File

@@ -516,6 +516,10 @@ impl AppState {
visible: enabled,
open: enabled,
sort_order: i32::try_from(config.creation_types.len()).unwrap_or(i32::MAX),
category_id: module_runtime::DEFAULT_CREATION_ENTRY_CATEGORY_ID.to_string(),
category_label: module_runtime::DEFAULT_CREATION_ENTRY_CATEGORY_LABEL
.to_string(),
category_sort_order: 0,
updated_at_micros: 0,
},
);

View File

@@ -10,8 +10,8 @@ use crate::domain::*;
use crate::errors::RuntimeProfileFieldError;
use crate::format_utc_micros;
use shared_contracts::creation_entry_config::{
CreationEntryConfigResponse, CreationEntryStartCardResponse, CreationEntryTypeModalResponse,
CreationEntryTypeResponse,
CreationEntryConfigResponse, CreationEntryEventBannerResponse, CreationEntryStartCardResponse,
CreationEntryTypeModalResponse, CreationEntryTypeResponse,
};
pub fn build_creation_entry_config_response(
@@ -28,6 +28,14 @@ pub fn build_creation_entry_config_response(
title: snapshot.type_modal.title,
description: snapshot.type_modal.description,
},
event_banner: CreationEntryEventBannerResponse {
title: snapshot.event_banner.title,
description: snapshot.event_banner.description,
cover_image_src: snapshot.event_banner.cover_image_src,
prize_pool_mud_points: snapshot.event_banner.prize_pool_mud_points,
starts_at_text: snapshot.event_banner.starts_at_text,
ends_at_text: snapshot.event_banner.ends_at_text,
},
creation_types: snapshot
.creation_types
.into_iter()
@@ -40,6 +48,9 @@ pub fn build_creation_entry_config_response(
visible: item.visible,
open: item.open,
sort_order: item.sort_order,
category_id: item.category_id,
category_label: item.category_label,
category_sort_order: item.category_sort_order,
updated_at_micros: item.updated_at_micros,
})
.collect(),
@@ -59,6 +70,9 @@ pub fn default_creation_entry_type_snapshots(
true,
true,
10,
"recent",
"最近创作",
10,
updated_at_micros,
),
build_default_creation_entry_type_snapshot(
@@ -70,6 +84,9 @@ pub fn default_creation_entry_type_snapshots(
false,
true,
20,
"recommended",
"热门推荐",
20,
updated_at_micros,
),
build_default_creation_entry_type_snapshot(
@@ -81,6 +98,9 @@ pub fn default_creation_entry_type_snapshots(
true,
true,
30,
"recent",
"最近创作",
10,
updated_at_micros,
),
build_default_creation_entry_type_snapshot(
@@ -92,6 +112,9 @@ pub fn default_creation_entry_type_snapshots(
true,
true,
40,
"recent",
"最近创作",
10,
updated_at_micros,
),
build_default_creation_entry_type_snapshot(
@@ -103,6 +126,9 @@ pub fn default_creation_entry_type_snapshots(
true,
true,
45,
"recommended",
"热门推荐",
20,
updated_at_micros,
),
build_default_creation_entry_type_snapshot(
@@ -114,6 +140,9 @@ pub fn default_creation_entry_type_snapshots(
true,
true,
47,
"festival",
"节日主题",
30,
updated_at_micros,
),
build_default_creation_entry_type_snapshot(
@@ -125,6 +154,9 @@ pub fn default_creation_entry_type_snapshots(
false,
true,
50,
"material",
"材质工艺",
60,
updated_at_micros,
),
build_default_creation_entry_type_snapshot(
@@ -136,6 +168,9 @@ pub fn default_creation_entry_type_snapshots(
true,
false,
60,
"scene",
"生活场景",
50,
updated_at_micros,
),
build_default_creation_entry_type_snapshot(
@@ -147,6 +182,9 @@ pub fn default_creation_entry_type_snapshots(
true,
false,
70,
"character",
"角色创作",
40,
updated_at_micros,
),
build_default_creation_entry_type_snapshot(
@@ -158,6 +196,9 @@ pub fn default_creation_entry_type_snapshots(
false,
true,
80,
"recommended",
"热门推荐",
20,
updated_at_micros,
),
build_default_creation_entry_type_snapshot(
@@ -169,6 +210,9 @@ pub fn default_creation_entry_type_snapshots(
true,
true,
85,
"recommended",
"热门推荐",
20,
updated_at_micros,
),
build_default_creation_entry_type_snapshot(
@@ -180,6 +224,9 @@ pub fn default_creation_entry_type_snapshots(
true,
true,
90,
"character",
"角色创作",
40,
updated_at_micros,
),
]
@@ -195,6 +242,9 @@ fn build_default_creation_entry_type_snapshot(
visible: bool,
open: bool,
sort_order: i32,
category_id: &str,
category_label: &str,
category_sort_order: i32,
updated_at_micros: i64,
) -> CreationEntryTypeSnapshot {
CreationEntryTypeSnapshot {
@@ -206,6 +256,9 @@ fn build_default_creation_entry_type_snapshot(
visible,
open,
sort_order,
category_id: category_id.to_string(),
category_label: category_label.to_string(),
category_sort_order,
updated_at_micros,
}
}

View File

@@ -50,6 +50,15 @@ pub const DEFAULT_CREATION_ENTRY_START_IDLE_BADGE: &str = "模板 Tab";
pub const DEFAULT_CREATION_ENTRY_START_BUSY_BADGE: &str = "正在开启";
pub const DEFAULT_CREATION_ENTRY_MODAL_TITLE: &str = "选择创作类型";
pub const DEFAULT_CREATION_ENTRY_MODAL_DESCRIPTION: &str = "先选玩法类型,再进入对应创作工作台。";
pub const DEFAULT_CREATION_ENTRY_CATEGORY_ID: &str = "recent";
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";
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";
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
@@ -67,6 +76,17 @@ pub struct CreationEntryTypeModalSnapshot {
pub description: String,
}
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct CreationEntryEventBannerSnapshot {
pub title: String,
pub description: String,
pub cover_image_src: String,
pub prize_pool_mud_points: u64,
pub starts_at_text: String,
pub ends_at_text: String,
}
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct CreationEntryTypeSnapshot {
@@ -78,6 +98,9 @@ pub struct CreationEntryTypeSnapshot {
pub visible: bool,
pub open: bool,
pub sort_order: i32,
pub category_id: String,
pub category_label: String,
pub category_sort_order: i32,
pub updated_at_micros: i64,
}
@@ -87,6 +110,7 @@ pub struct CreationEntryConfigSnapshot {
pub config_id: String,
pub start_card: CreationEntryStartCardSnapshot,
pub type_modal: CreationEntryTypeModalSnapshot,
pub event_banner: CreationEntryEventBannerSnapshot,
pub creation_types: Vec<CreationEntryTypeSnapshot>,
pub updated_at_micros: i64,
}
@@ -102,6 +126,9 @@ pub struct CreationEntryTypeAdminUpsertInput {
pub visible: bool,
pub open: bool,
pub sort_order: i32,
pub category_id: String,
pub category_label: String,
pub category_sort_order: i32,
}
#[cfg_attr(feature = "spacetime-types", derive(SpacetimeType))]

View File

@@ -230,6 +230,9 @@ mod tests {
assert!(baby_object_match.open);
assert_eq!(baby_object_match.badge, "可创建");
assert_eq!(baby_object_match.sort_order, 90);
assert_eq!(baby_object_match.category_id, "character");
assert_eq!(baby_object_match.category_label, "角色创作");
assert_eq!(baby_object_match.category_sort_order, 40);
assert_eq!(
baby_object_match.image_src,
"/child-motion-demo/picture-book-grass-stage.png"
@@ -250,6 +253,8 @@ mod tests {
assert!(rpg.open);
assert_eq!(rpg.badge, "可创建");
assert_eq!(rpg.sort_order, 10);
assert_eq!(rpg.category_id, "recent");
assert_eq!(rpg.category_label, "最近创作");
assert_eq!(rpg.image_src, "/creation-type-references/rpg.webp");
}

View File

@@ -30,6 +30,9 @@ pub struct AdminCreationEntryTypeConfigPayload {
pub visible: bool,
pub open: bool,
pub sort_order: i32,
pub category_id: String,
pub category_label: String,
pub category_sort_order: i32,
pub updated_at_micros: i64,
}
@@ -45,6 +48,9 @@ pub struct AdminUpsertCreationEntryTypeConfigRequest {
pub visible: bool,
pub open: bool,
pub sort_order: i32,
pub category_id: String,
pub category_label: String,
pub category_sort_order: i32,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]

View File

@@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
pub struct CreationEntryConfigResponse {
pub start_card: CreationEntryStartCardResponse,
pub type_modal: CreationEntryTypeModalResponse,
pub event_banner: CreationEntryEventBannerResponse,
pub creation_types: Vec<CreationEntryTypeResponse>,
}
@@ -24,6 +25,17 @@ pub struct CreationEntryTypeModalResponse {
pub description: String,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CreationEntryEventBannerResponse {
pub title: String,
pub description: String,
pub cover_image_src: String,
pub prize_pool_mud_points: u64,
pub starts_at_text: String,
pub ends_at_text: String,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
pub struct CreationEntryTypeResponse {
@@ -35,5 +47,8 @@ pub struct CreationEntryTypeResponse {
pub visible: bool,
pub open: bool,
pub sort_order: i32,
pub category_id: String,
pub category_label: String,
pub category_sort_order: i32,
pub updated_at_micros: i64,
}

View File

@@ -11,6 +11,9 @@ impl From<module_runtime::CreationEntryTypeAdminUpsertInput> for CreationEntryTy
visible: input.visible,
open: input.open,
sort_order: input.sort_order,
category_id: input.category_id,
category_label: input.category_label,
category_sort_order: input.category_sort_order,
}
}
}
@@ -151,6 +154,29 @@ pub(crate) fn build_creation_entry_config_record_from_rows(
title: header.modal_title,
description: header.modal_description,
},
event_banner: module_runtime::CreationEntryEventBannerSnapshot {
title: creation_entry_text_or_default(
header.event_title,
module_runtime::DEFAULT_CREATION_ENTRY_EVENT_TITLE,
),
description: creation_entry_text_or_default(
header.event_description,
module_runtime::DEFAULT_CREATION_ENTRY_EVENT_DESCRIPTION,
),
cover_image_src: creation_entry_text_or_default(
header.event_cover_image_src,
module_runtime::DEFAULT_CREATION_ENTRY_EVENT_COVER_IMAGE_SRC,
),
prize_pool_mud_points: header.event_prize_pool_mud_points,
starts_at_text: creation_entry_text_or_default(
header.event_starts_at_text,
module_runtime::DEFAULT_CREATION_ENTRY_EVENT_STARTS_AT_TEXT,
),
ends_at_text: creation_entry_text_or_default(
header.event_ends_at_text,
module_runtime::DEFAULT_CREATION_ENTRY_EVENT_ENDS_AT_TEXT,
),
},
creation_types: creation_types
.into_iter()
.map(|item| module_runtime::CreationEntryTypeSnapshot {
@@ -162,6 +188,15 @@ pub(crate) fn build_creation_entry_config_record_from_rows(
visible: item.visible,
open: item.open,
sort_order: item.sort_order,
category_id: creation_entry_text_or_default(
item.category_id,
module_runtime::DEFAULT_CREATION_ENTRY_CATEGORY_ID,
),
category_label: creation_entry_text_or_default(
item.category_label,
module_runtime::DEFAULT_CREATION_ENTRY_CATEGORY_LABEL,
),
category_sort_order: item.category_sort_order,
updated_at_micros: item.updated_at.to_micros_since_unix_epoch(),
})
.collect(),
@@ -185,6 +220,14 @@ fn map_creation_entry_config_snapshot(
title: snapshot.type_modal.title,
description: snapshot.type_modal.description,
},
event_banner: module_runtime::CreationEntryEventBannerSnapshot {
title: snapshot.event_banner.title,
description: snapshot.event_banner.description,
cover_image_src: snapshot.event_banner.cover_image_src,
prize_pool_mud_points: snapshot.event_banner.prize_pool_mud_points,
starts_at_text: snapshot.event_banner.starts_at_text,
ends_at_text: snapshot.event_banner.ends_at_text,
},
creation_types: snapshot
.creation_types
.into_iter()
@@ -197,6 +240,9 @@ fn map_creation_entry_config_snapshot(
visible: item.visible,
open: item.open,
sort_order: item.sort_order,
category_id: item.category_id,
category_label: item.category_label,
category_sort_order: item.category_sort_order,
updated_at_micros: item.updated_at_micros,
})
.collect(),
@@ -204,6 +250,13 @@ fn map_creation_entry_config_snapshot(
}
}
fn creation_entry_text_or_default(value: Option<String>, default_value: &str) -> String {
value
.map(|value| value.trim().to_string())
.filter(|value| !value.is_empty())
.unwrap_or_else(|| default_value.to_string())
}
pub(crate) fn map_runtime_setting_procedure_result(
result: RuntimeSettingProcedureResult,
) -> Result<RuntimeSettingsRecord, SpacetimeClientError> {

View File

@@ -234,6 +234,7 @@ pub mod creation_entry_config_procedure_result_type;
pub mod creation_entry_config_snapshot_type;
pub mod creation_entry_config_table;
pub mod creation_entry_config_type;
pub mod creation_entry_event_banner_snapshot_type;
pub mod creation_entry_start_card_snapshot_type;
pub mod creation_entry_type_admin_upsert_input_type;
pub mod creation_entry_type_config_table;
@@ -1262,6 +1263,7 @@ pub use creation_entry_config_procedure_result_type::CreationEntryConfigProcedur
pub use creation_entry_config_snapshot_type::CreationEntryConfigSnapshot;
pub use creation_entry_config_table::*;
pub use creation_entry_config_type::CreationEntryConfig;
pub use creation_entry_event_banner_snapshot_type::CreationEntryEventBannerSnapshot;
pub use creation_entry_start_card_snapshot_type::CreationEntryStartCardSnapshot;
pub use creation_entry_type_admin_upsert_input_type::CreationEntryTypeAdminUpsertInput;
pub use creation_entry_type_config_table::*;
@@ -3285,10 +3287,6 @@ impl __sdk::DbUpdate for DbUpdate {
&self.visual_novel_work_profile,
)
.with_updates_by_pk(|row| &row.profile_id);
diff.bark_battle_gallery_view = cache.apply_diff_to_table::<BarkBattleGalleryViewRow>(
"bark_battle_gallery_view",
&self.bark_battle_gallery_view,
);
diff.wooden_fish_agent_session = cache
.apply_diff_to_table::<WoodenFishAgentSessionRow>(
"wooden_fish_agent_session",
@@ -3310,6 +3308,10 @@ impl __sdk::DbUpdate for DbUpdate {
&self.wooden_fish_work_profile,
)
.with_updates_by_pk(|row| &row.profile_id);
diff.bark_battle_gallery_view = cache.apply_diff_to_table::<BarkBattleGalleryViewRow>(
"bark_battle_gallery_view",
&self.bark_battle_gallery_view,
);
diff.big_fish_gallery_view = cache.apply_diff_to_table::<BigFishWorkSummarySnapshot>(
"big_fish_gallery_view",
&self.big_fish_gallery_view,

View File

@@ -4,6 +4,7 @@
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::creation_entry_event_banner_snapshot_type::CreationEntryEventBannerSnapshot;
use super::creation_entry_start_card_snapshot_type::CreationEntryStartCardSnapshot;
use super::creation_entry_type_modal_snapshot_type::CreationEntryTypeModalSnapshot;
use super::creation_entry_type_snapshot_type::CreationEntryTypeSnapshot;
@@ -14,6 +15,7 @@ pub struct CreationEntryConfigSnapshot {
pub config_id: String,
pub start_card: CreationEntryStartCardSnapshot,
pub type_modal: CreationEntryTypeModalSnapshot,
pub event_banner: CreationEntryEventBannerSnapshot,
pub creation_types: Vec<CreationEntryTypeSnapshot>,
pub updated_at_micros: i64,
}

View File

@@ -15,6 +15,12 @@ pub struct CreationEntryConfig {
pub modal_title: String,
pub modal_description: String,
pub updated_at: __sdk::Timestamp,
pub event_title: Option<String>,
pub event_description: Option<String>,
pub event_cover_image_src: Option<String>,
pub event_prize_pool_mud_points: u64,
pub event_starts_at_text: Option<String>,
pub event_ends_at_text: Option<String>,
}
impl __sdk::InModule for CreationEntryConfig {
@@ -33,6 +39,12 @@ pub struct CreationEntryConfigCols {
pub modal_title: __sdk::__query_builder::Col<CreationEntryConfig, String>,
pub modal_description: __sdk::__query_builder::Col<CreationEntryConfig, String>,
pub updated_at: __sdk::__query_builder::Col<CreationEntryConfig, __sdk::Timestamp>,
pub event_title: __sdk::__query_builder::Col<CreationEntryConfig, Option<String>>,
pub event_description: __sdk::__query_builder::Col<CreationEntryConfig, Option<String>>,
pub event_cover_image_src: __sdk::__query_builder::Col<CreationEntryConfig, Option<String>>,
pub event_prize_pool_mud_points: __sdk::__query_builder::Col<CreationEntryConfig, u64>,
pub event_starts_at_text: __sdk::__query_builder::Col<CreationEntryConfig, Option<String>>,
pub event_ends_at_text: __sdk::__query_builder::Col<CreationEntryConfig, Option<String>>,
}
impl __sdk::__query_builder::HasCols for CreationEntryConfig {
@@ -47,6 +59,21 @@ impl __sdk::__query_builder::HasCols for CreationEntryConfig {
modal_title: __sdk::__query_builder::Col::new(table_name, "modal_title"),
modal_description: __sdk::__query_builder::Col::new(table_name, "modal_description"),
updated_at: __sdk::__query_builder::Col::new(table_name, "updated_at"),
event_title: __sdk::__query_builder::Col::new(table_name, "event_title"),
event_description: __sdk::__query_builder::Col::new(table_name, "event_description"),
event_cover_image_src: __sdk::__query_builder::Col::new(
table_name,
"event_cover_image_src",
),
event_prize_pool_mud_points: __sdk::__query_builder::Col::new(
table_name,
"event_prize_pool_mud_points",
),
event_starts_at_text: __sdk::__query_builder::Col::new(
table_name,
"event_starts_at_text",
),
event_ends_at_text: __sdk::__query_builder::Col::new(table_name, "event_ends_at_text"),
}
}
}

View File

@@ -0,0 +1,20 @@
// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD.
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub struct CreationEntryEventBannerSnapshot {
pub title: String,
pub description: String,
pub cover_image_src: String,
pub prize_pool_mud_points: u64,
pub starts_at_text: String,
pub ends_at_text: String,
}
impl __sdk::InModule for CreationEntryEventBannerSnapshot {
type Module = super::RemoteModule;
}

View File

@@ -15,6 +15,9 @@ pub struct CreationEntryTypeAdminUpsertInput {
pub visible: bool,
pub open: bool,
pub sort_order: i32,
pub category_id: String,
pub category_label: String,
pub category_sort_order: i32,
}
impl __sdk::InModule for CreationEntryTypeAdminUpsertInput {

View File

@@ -16,6 +16,9 @@ pub struct CreationEntryTypeConfig {
pub open: bool,
pub sort_order: i32,
pub updated_at: __sdk::Timestamp,
pub category_id: Option<String>,
pub category_label: Option<String>,
pub category_sort_order: i32,
}
impl __sdk::InModule for CreationEntryTypeConfig {
@@ -35,6 +38,9 @@ pub struct CreationEntryTypeConfigCols {
pub open: __sdk::__query_builder::Col<CreationEntryTypeConfig, bool>,
pub sort_order: __sdk::__query_builder::Col<CreationEntryTypeConfig, i32>,
pub updated_at: __sdk::__query_builder::Col<CreationEntryTypeConfig, __sdk::Timestamp>,
pub category_id: __sdk::__query_builder::Col<CreationEntryTypeConfig, Option<String>>,
pub category_label: __sdk::__query_builder::Col<CreationEntryTypeConfig, Option<String>>,
pub category_sort_order: __sdk::__query_builder::Col<CreationEntryTypeConfig, i32>,
}
impl __sdk::__query_builder::HasCols for CreationEntryTypeConfig {
@@ -50,6 +56,12 @@ impl __sdk::__query_builder::HasCols for CreationEntryTypeConfig {
open: __sdk::__query_builder::Col::new(table_name, "open"),
sort_order: __sdk::__query_builder::Col::new(table_name, "sort_order"),
updated_at: __sdk::__query_builder::Col::new(table_name, "updated_at"),
category_id: __sdk::__query_builder::Col::new(table_name, "category_id"),
category_label: __sdk::__query_builder::Col::new(table_name, "category_label"),
category_sort_order: __sdk::__query_builder::Col::new(
table_name,
"category_sort_order",
),
}
}
}

View File

@@ -15,6 +15,9 @@ pub struct CreationEntryTypeSnapshot {
pub visible: bool,
pub open: bool,
pub sort_order: i32,
pub category_id: String,
pub category_label: String,
pub category_sort_order: i32,
pub updated_at_micros: i64,
}

View File

@@ -1159,6 +1159,43 @@ where
fn normalize_migration_row(table_name: &str, value: &serde_json::Value) -> serde_json::Value {
let mut next_value = value.clone();
if table_name == "creation_entry_config" {
if let Some(object) = next_value.as_object_mut() {
// 中文注释:入口活动横幅字段晚于创作入口配置表加入,旧迁移包按运行态默认横幅兼容。
object
.entry("event_title".to_string())
.or_insert(serde_json::Value::Null);
object
.entry("event_description".to_string())
.or_insert(serde_json::Value::Null);
object
.entry("event_cover_image_src".to_string())
.or_insert(serde_json::Value::Null);
object
.entry("event_prize_pool_mud_points".to_string())
.or_insert_with(|| serde_json::Value::from(58_000));
object
.entry("event_starts_at_text".to_string())
.or_insert(serde_json::Value::Null);
object
.entry("event_ends_at_text".to_string())
.or_insert(serde_json::Value::Null);
}
}
if table_name == "creation_entry_type_config" {
if let Some(object) = next_value.as_object_mut() {
// 中文注释:入口分类字段晚于入口类型配置表加入,旧迁移包按未分类兼容。
object
.entry("category_id".to_string())
.or_insert(serde_json::Value::Null);
object
.entry("category_label".to_string())
.or_insert(serde_json::Value::Null);
object
.entry("category_sort_order".to_string())
.or_insert_with(|| serde_json::Value::from(0));
}
}
if table_name == "user_account" {
if let Some(object) = next_value.as_object_mut() {
// 中文注释:头像字段晚于认证拆表加入,旧迁移包按未设置头像兼容。

View File

@@ -11,6 +11,18 @@ pub struct CreationEntryConfig {
pub(crate) modal_title: String,
pub(crate) modal_description: String,
pub(crate) updated_at: Timestamp,
#[default(None::<String>)]
pub(crate) event_title: Option<String>,
#[default(None::<String>)]
pub(crate) event_description: Option<String>,
#[default(None::<String>)]
pub(crate) event_cover_image_src: Option<String>,
#[default(DEFAULT_CREATION_ENTRY_EVENT_PRIZE_POOL_MUD_POINTS)]
pub(crate) event_prize_pool_mud_points: u64,
#[default(None::<String>)]
pub(crate) event_starts_at_text: Option<String>,
#[default(None::<String>)]
pub(crate) event_ends_at_text: Option<String>,
}
#[spacetimedb::table(
@@ -28,6 +40,12 @@ pub struct CreationEntryTypeConfig {
pub(crate) open: bool,
pub(crate) sort_order: i32,
pub(crate) updated_at: Timestamp,
#[default(None::<String>)]
pub(crate) category_id: Option<String>,
#[default(None::<String>)]
pub(crate) category_label: Option<String>,
#[default(0)]
pub(crate) category_sort_order: i32,
}
#[spacetimedb::procedure]
@@ -88,6 +106,9 @@ fn upsert_creation_entry_type_config_in_tx(
open: input.open,
sort_order: input.sort_order,
updated_at: now,
category_id: Some(normalize_category_id(&input.category_id)),
category_label: Some(normalize_category_label(&input.category_label)),
category_sort_order: input.category_sort_order,
};
if ctx.db.creation_entry_type_config().id().find(&id).is_some() {
ctx.db.creation_entry_type_config().id().update(row);
@@ -120,6 +141,9 @@ fn get_or_seed_creation_entry_config_snapshot(
visible: row.visible,
open: row.open,
sort_order: row.sort_order,
category_id: normalize_optional_category_id(row.category_id.as_deref()),
category_label: normalize_optional_category_label(row.category_label.as_deref()),
category_sort_order: row.category_sort_order,
updated_at_micros: row.updated_at.to_micros_since_unix_epoch(),
})
.collect::<Vec<_>>();
@@ -141,6 +165,29 @@ fn get_or_seed_creation_entry_config_snapshot(
title: header.modal_title,
description: header.modal_description,
},
event_banner: CreationEntryEventBannerSnapshot {
title: normalize_optional_text(
header.event_title.as_deref(),
DEFAULT_CREATION_ENTRY_EVENT_TITLE,
),
description: normalize_optional_text(
header.event_description.as_deref(),
DEFAULT_CREATION_ENTRY_EVENT_DESCRIPTION,
),
cover_image_src: normalize_optional_text(
header.event_cover_image_src.as_deref(),
DEFAULT_CREATION_ENTRY_EVENT_COVER_IMAGE_SRC,
),
prize_pool_mud_points: header.event_prize_pool_mud_points,
starts_at_text: normalize_optional_text(
header.event_starts_at_text.as_deref(),
DEFAULT_CREATION_ENTRY_EVENT_STARTS_AT_TEXT,
),
ends_at_text: normalize_optional_text(
header.event_ends_at_text.as_deref(),
DEFAULT_CREATION_ENTRY_EVENT_ENDS_AT_TEXT,
),
},
creation_types,
updated_at_micros: header.updated_at.to_micros_since_unix_epoch(),
})
@@ -164,6 +211,12 @@ fn seed_creation_entry_config_if_missing(ctx: &ReducerContext) {
modal_title: DEFAULT_CREATION_ENTRY_MODAL_TITLE.to_string(),
modal_description: DEFAULT_CREATION_ENTRY_MODAL_DESCRIPTION.to_string(),
updated_at: now,
event_title: Some(DEFAULT_CREATION_ENTRY_EVENT_TITLE.to_string()),
event_description: Some(DEFAULT_CREATION_ENTRY_EVENT_DESCRIPTION.to_string()),
event_cover_image_src: Some(DEFAULT_CREATION_ENTRY_EVENT_COVER_IMAGE_SRC.to_string()),
event_prize_pool_mud_points: DEFAULT_CREATION_ENTRY_EVENT_PRIZE_POOL_MUD_POINTS,
event_starts_at_text: Some(DEFAULT_CREATION_ENTRY_EVENT_STARTS_AT_TEXT.to_string()),
event_ends_at_text: Some(DEFAULT_CREATION_ENTRY_EVENT_ENDS_AT_TEXT.to_string()),
});
}
@@ -348,6 +401,43 @@ fn default_creation_entry_type_configs(now: Timestamp) -> Vec<CreationEntryTypeC
open: snapshot.open,
sort_order: snapshot.sort_order,
updated_at: now,
category_id: Some(snapshot.category_id),
category_label: Some(snapshot.category_label),
category_sort_order: snapshot.category_sort_order,
})
.collect()
}
fn normalize_category_id(value: &str) -> String {
let normalized = value.trim();
if normalized.is_empty() {
DEFAULT_CREATION_ENTRY_CATEGORY_ID.to_string()
} else {
normalized.to_string()
}
}
fn normalize_category_label(value: &str) -> String {
let normalized = value.trim();
if normalized.is_empty() {
DEFAULT_CREATION_ENTRY_CATEGORY_LABEL.to_string()
} else {
normalized.to_string()
}
}
fn normalize_optional_category_id(value: Option<&str>) -> String {
normalize_optional_text(value, DEFAULT_CREATION_ENTRY_CATEGORY_ID)
}
fn normalize_optional_category_label(value: Option<&str>) -> String {
normalize_optional_text(value, DEFAULT_CREATION_ENTRY_CATEGORY_LABEL)
}
fn normalize_optional_text(value: Option<&str>, fallback: &str) -> String {
value
.map(str::trim)
.filter(|normalized| !normalized.is_empty())
.unwrap_or(fallback)
.to_string()
}