调整图片画布路由和画布数据模型

将图片画布入口改为 /editor/canvas

新增 editor_canvas 表并关联 editor_project 默认画布

更新 project API 响应中的 canvas 快照兼容层

统一图片画布侧栏列表项和图标按钮组件

同步前端测试、SpacetimeDB bindings、技术文档和 TRACKING 记录
This commit is contained in:
2026-06-13 22:09:45 +08:00
parent a1b9ac8544
commit 242860e2d3
21 changed files with 1649 additions and 295 deletions

View File

@@ -0,0 +1,23 @@
// 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};
use super::editor_project_viewport_snapshot_type::EditorProjectViewportSnapshot;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
pub struct EditorCanvasSnapshot {
pub canvas_id: String,
pub project_id: String,
pub title: String,
pub viewport: EditorProjectViewportSnapshot,
pub layers_json: String,
pub created_at_micros: i64,
pub updated_at_micros: i64,
}
impl __sdk::InModule for EditorCanvasSnapshot {
type Module = super::RemoteModule;
}

View File

@@ -0,0 +1,159 @@
// 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 super::editor_canvas_type::EditorCanvas;
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
/// Table handle for the table `editor_canvas`.
///
/// Obtain a handle from the [`EditorCanvasTableAccess::editor_canvas`] method on [`super::RemoteTables`],
/// like `ctx.db.editor_canvas()`.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.editor_canvas().on_insert(...)`.
pub struct EditorCanvasTableHandle<'ctx> {
imp: __sdk::TableHandle<EditorCanvas>,
ctx: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
#[allow(non_camel_case_types)]
/// Extension trait for access to the table `editor_canvas`.
///
/// Implemented for [`super::RemoteTables`].
pub trait EditorCanvasTableAccess {
#[allow(non_snake_case)]
/// Obtain a [`EditorCanvasTableHandle`], which mediates access to the table `editor_canvas`.
fn editor_canvas(&self) -> EditorCanvasTableHandle<'_>;
}
impl EditorCanvasTableAccess for super::RemoteTables {
fn editor_canvas(&self) -> EditorCanvasTableHandle<'_> {
EditorCanvasTableHandle {
imp: self.imp.get_table::<EditorCanvas>("editor_canvas"),
ctx: std::marker::PhantomData,
}
}
}
pub struct EditorCanvasInsertCallbackId(__sdk::CallbackId);
pub struct EditorCanvasDeleteCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::Table for EditorCanvasTableHandle<'ctx> {
type Row = EditorCanvas;
type EventContext = super::EventContext;
fn count(&self) -> u64 {
self.imp.count()
}
fn iter(&self) -> impl Iterator<Item = EditorCanvas> + '_ {
self.imp.iter()
}
type InsertCallbackId = EditorCanvasInsertCallbackId;
fn on_insert(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> EditorCanvasInsertCallbackId {
EditorCanvasInsertCallbackId(self.imp.on_insert(Box::new(callback)))
}
fn remove_on_insert(&self, callback: EditorCanvasInsertCallbackId) {
self.imp.remove_on_insert(callback.0)
}
type DeleteCallbackId = EditorCanvasDeleteCallbackId;
fn on_delete(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row) + Send + 'static,
) -> EditorCanvasDeleteCallbackId {
EditorCanvasDeleteCallbackId(self.imp.on_delete(Box::new(callback)))
}
fn remove_on_delete(&self, callback: EditorCanvasDeleteCallbackId) {
self.imp.remove_on_delete(callback.0)
}
}
pub struct EditorCanvasUpdateCallbackId(__sdk::CallbackId);
impl<'ctx> __sdk::TableWithPrimaryKey for EditorCanvasTableHandle<'ctx> {
type UpdateCallbackId = EditorCanvasUpdateCallbackId;
fn on_update(
&self,
callback: impl FnMut(&Self::EventContext, &Self::Row, &Self::Row) + Send + 'static,
) -> EditorCanvasUpdateCallbackId {
EditorCanvasUpdateCallbackId(self.imp.on_update(Box::new(callback)))
}
fn remove_on_update(&self, callback: EditorCanvasUpdateCallbackId) {
self.imp.remove_on_update(callback.0)
}
}
/// Access to the `canvas_id` unique index on the table `editor_canvas`,
/// which allows point queries on the field of the same name
/// via the [`EditorCanvasCanvasIdUnique::find`] method.
///
/// Users are encouraged not to explicitly reference this type,
/// but to directly chain method calls,
/// like `ctx.db.editor_canvas().canvas_id().find(...)`.
pub struct EditorCanvasCanvasIdUnique<'ctx> {
imp: __sdk::UniqueConstraintHandle<EditorCanvas, String>,
phantom: std::marker::PhantomData<&'ctx super::RemoteTables>,
}
impl<'ctx> EditorCanvasTableHandle<'ctx> {
/// Get a handle on the `canvas_id` unique index on the table `editor_canvas`.
pub fn canvas_id(&self) -> EditorCanvasCanvasIdUnique<'ctx> {
EditorCanvasCanvasIdUnique {
imp: self.imp.get_unique_constraint::<String>("canvas_id"),
phantom: std::marker::PhantomData,
}
}
}
impl<'ctx> EditorCanvasCanvasIdUnique<'ctx> {
/// Find the subscribed row whose `canvas_id` column value is equal to `col_val`,
/// if such a row is present in the client cache.
pub fn find(&self, col_val: &String) -> Option<EditorCanvas> {
self.imp.find(col_val)
}
}
#[doc(hidden)]
pub(super) fn register_table(client_cache: &mut __sdk::ClientCache<super::RemoteModule>) {
let _table = client_cache.get_or_make_table::<EditorCanvas>("editor_canvas");
_table.add_unique_constraint::<String>("canvas_id", |row| &row.canvas_id);
}
#[doc(hidden)]
pub(super) fn parse_table_update(
raw_updates: __ws::v2::TableUpdate,
) -> __sdk::Result<__sdk::TableUpdate<EditorCanvas>> {
__sdk::TableUpdate::parse_table_update(raw_updates).map_err(|e| {
__sdk::InternalError::failed_parse("TableUpdate<EditorCanvas>", "TableUpdate")
.with_cause(e)
.into()
})
}
#[allow(non_camel_case_types)]
/// Extension trait for query builder access to the table `EditorCanvas`.
///
/// Implemented for [`__sdk::QueryTableAccessor`].
pub trait editor_canvasQueryTableAccess {
#[allow(non_snake_case)]
/// Get a query builder for the table `EditorCanvas`.
fn editor_canvas(&self) -> __sdk::__query_builder::Table<EditorCanvas>;
}
impl editor_canvasQueryTableAccess for __sdk::QueryTableAccessor {
fn editor_canvas(&self) -> __sdk::__query_builder::Table<EditorCanvas> {
__sdk::__query_builder::Table::new("editor_canvas")
}
}

View File

@@ -0,0 +1,80 @@
// 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 EditorCanvas {
pub canvas_id: String,
pub project_id: String,
pub owner_user_id: String,
pub title: String,
pub viewport_x: f64,
pub viewport_y: f64,
pub viewport_scale: f64,
pub layers_json: String,
pub created_at: __sdk::Timestamp,
pub updated_at: __sdk::Timestamp,
}
impl __sdk::InModule for EditorCanvas {
type Module = super::RemoteModule;
}
/// Column accessor struct for the table `EditorCanvas`.
///
/// Provides typed access to columns for query building.
pub struct EditorCanvasCols {
pub canvas_id: __sdk::__query_builder::Col<EditorCanvas, String>,
pub project_id: __sdk::__query_builder::Col<EditorCanvas, String>,
pub owner_user_id: __sdk::__query_builder::Col<EditorCanvas, String>,
pub title: __sdk::__query_builder::Col<EditorCanvas, String>,
pub viewport_x: __sdk::__query_builder::Col<EditorCanvas, f64>,
pub viewport_y: __sdk::__query_builder::Col<EditorCanvas, f64>,
pub viewport_scale: __sdk::__query_builder::Col<EditorCanvas, f64>,
pub layers_json: __sdk::__query_builder::Col<EditorCanvas, String>,
pub created_at: __sdk::__query_builder::Col<EditorCanvas, __sdk::Timestamp>,
pub updated_at: __sdk::__query_builder::Col<EditorCanvas, __sdk::Timestamp>,
}
impl __sdk::__query_builder::HasCols for EditorCanvas {
type Cols = EditorCanvasCols;
fn cols(table_name: &'static str) -> Self::Cols {
EditorCanvasCols {
canvas_id: __sdk::__query_builder::Col::new(table_name, "canvas_id"),
project_id: __sdk::__query_builder::Col::new(table_name, "project_id"),
owner_user_id: __sdk::__query_builder::Col::new(table_name, "owner_user_id"),
title: __sdk::__query_builder::Col::new(table_name, "title"),
viewport_x: __sdk::__query_builder::Col::new(table_name, "viewport_x"),
viewport_y: __sdk::__query_builder::Col::new(table_name, "viewport_y"),
viewport_scale: __sdk::__query_builder::Col::new(table_name, "viewport_scale"),
layers_json: __sdk::__query_builder::Col::new(table_name, "layers_json"),
created_at: __sdk::__query_builder::Col::new(table_name, "created_at"),
updated_at: __sdk::__query_builder::Col::new(table_name, "updated_at"),
}
}
}
/// Indexed column accessor struct for the table `EditorCanvas`.
///
/// Provides typed access to indexed columns for query building.
pub struct EditorCanvasIxCols {
pub canvas_id: __sdk::__query_builder::IxCol<EditorCanvas, String>,
pub owner_user_id: __sdk::__query_builder::IxCol<EditorCanvas, String>,
pub project_id: __sdk::__query_builder::IxCol<EditorCanvas, String>,
}
impl __sdk::__query_builder::HasIxCols for EditorCanvas {
type IxCols = EditorCanvasIxCols;
fn ix_cols(table_name: &'static str) -> Self::IxCols {
EditorCanvasIxCols {
canvas_id: __sdk::__query_builder::IxCol::new(table_name, "canvas_id"),
owner_user_id: __sdk::__query_builder::IxCol::new(table_name, "owner_user_id"),
project_id: __sdk::__query_builder::IxCol::new(table_name, "project_id"),
}
}
}
impl __sdk::__query_builder::CanBeLookupTable for EditorCanvas {}

View File

@@ -4,8 +4,8 @@
#![allow(unused, clippy::all)]
use spacetimedb_sdk::__codegen::{self as __sdk, __lib, __sats, __ws};
use super::editor_canvas_snapshot_type::EditorCanvasSnapshot;
use super::editor_project_resource_snapshot_type::EditorProjectResourceSnapshot;
use super::editor_project_viewport_snapshot_type::EditorProjectViewportSnapshot;
#[derive(__lib::ser::Serialize, __lib::de::Deserialize, Clone, PartialEq, Debug)]
#[sats(crate = __lib)]
@@ -13,8 +13,7 @@ pub struct EditorProjectSnapshot {
pub project_id: String,
pub owner_user_id: String,
pub title: String,
pub viewport: EditorProjectViewportSnapshot,
pub layers_json: String,
pub canvas: EditorCanvasSnapshot,
pub resources: Vec<EditorProjectResourceSnapshot>,
pub created_at_micros: i64,
pub updated_at_micros: i64,