单点维护 model3d 的 ts-rs 导出根目录

在 model3d/mod.rs 新增 model3d_ts_export_dir 宏,集中定义仓库相对导出根路径

common、image_to_model、multiview_to_model、text_to_model 改为调用宏并只声明各自子目录名
This commit is contained in:
2026-09-19 13:02:46 +08:00
parent 35be25dbd6
commit eda9da4d8d
5 changed files with 21 additions and 16 deletions
@@ -1,7 +1,4 @@
pub(crate) const MODEL3D_TS_EXPORT_DIR: &str = concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../../packages/shared/src/contracts/model3d/common/"
);
pub(crate) const MODEL3D_TS_EXPORT_DIR: &str = crate::model3d::model3d_ts_export_dir!("common/");
mod compression;
mod export_orientation;
@@ -1,7 +1,5 @@
pub(crate) const MODEL3D_TS_EXPORT_DIR: &str = concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../../packages/shared/src/contracts/model3d/image-to-model/"
);
pub(crate) const MODEL3D_TS_EXPORT_DIR: &str =
crate::model3d::model3d_ts_export_dir!("image-to-model/");
mod request;
@@ -1,5 +1,19 @@
//! Provider-neutral 3D model generation contracts.
/// 3D 模型契约的 ts-rs 生成根目录;各子目录只追加自己的目录名,
/// 避免仓库相对路径在多处重复维护。
macro_rules! model3d_ts_export_dir {
($subdirectory:literal) => {
concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../../packages/shared/src/contracts/model3d/",
$subdirectory
)
};
}
pub(crate) use model3d_ts_export_dir;
pub mod common;
pub mod image_to_model;
pub mod multiview_to_model;
@@ -1,7 +1,5 @@
pub(crate) const MODEL3D_TS_EXPORT_DIR: &str = concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../../packages/shared/src/contracts/model3d/multiview-to-model/"
);
pub(crate) const MODEL3D_TS_EXPORT_DIR: &str =
crate::model3d::model3d_ts_export_dir!("multiview-to-model/");
mod request;
@@ -1,7 +1,5 @@
pub(crate) const MODEL3D_TS_EXPORT_DIR: &str = concat!(
env!("CARGO_MANIFEST_DIR"),
"/../../../packages/shared/src/contracts/model3d/text-to-model/"
);
pub(crate) const MODEL3D_TS_EXPORT_DIR: &str =
crate::model3d::model3d_ts_export_dir!("text-to-model/");
mod request;
mod response;