feat: 建立组件化模板预览基线并规划可视化编辑
This commit is contained in:
1 parent
c5af790554
commit
0b14b5a814
46 files changed
+1880
-427
No files matched your search
@@ -6,7 +6,8 @@ import { navigate } from "../../../apps/taro/src/runtime/navigation";
|
||||
import { presentation, offering, slot, text, rows } from "../../../apps/taro/src/runtime/content";
|
||||
import type { RuntimeWorkspace } from "@personal-brand/types";
|
||||
import "./style.css";
|
||||
const asset = (name: string) => `/assets/${name}`;
|
||||
const asset = (name: string) =>
|
||||
`/assets/${PREVIEW_ALL_TEMPLATES ? "acheng-campus-food/" : ""}${name}`;
|
||||
function Home({ workspace }: { workspace: RuntimeWorkspace }) {
|
||||
const brand = workspace.brand;
|
||||
const p = presentation(workspace, "home");
|
||||
@@ -115,7 +116,7 @@ function Service({ workspace }: { workspace: RuntimeWorkspace }) {
|
||||
].filter((row) => row.title && row.detail);
|
||||
const steps = rows(process?.config.steps).filter((step) => step.title && step.detail);
|
||||
return (
|
||||
<View className="food-service">
|
||||
<View className="food-service" data-editor-target="acheng-campus-food.service.service">
|
||||
<View className="page service-page">
|
||||
{schedule && scheduleRows.length > 0 && (
|
||||
<View className="service-card schedule-card">
|
||||
@@ -220,7 +221,7 @@ function Profile({ workspace }: { workspace: RuntimeWorkspace }) {
|
||||
const p = presentation(workspace, "profile");
|
||||
const credentials = workspace.trustItems.filter((item) => item.type === "credential");
|
||||
return (
|
||||
<View className="food-profile">
|
||||
<View className="food-profile" data-editor-target="acheng-campus-food.profile.identity">
|
||||
<View className="page">
|
||||
<View className="profile-card">
|
||||
<View className="portrait">
|
||||
@@ -340,13 +341,22 @@ function Profile({ workspace }: { workspace: RuntimeWorkspace }) {
|
||||
</View>
|
||||
);
|
||||
}
|
||||
const formTargets: Record<string, string> = {
|
||||
inquiry: "acheng-campus-food.inquiry.booking",
|
||||
success: "acheng-campus-food.success.successCopy",
|
||||
records: "acheng-campus-food.records.recordsCopy",
|
||||
};
|
||||
export function TemplatePage({ workspace, page, children, offeringId }: TemplateProps) {
|
||||
if (page === "home") return <Home workspace={workspace} />;
|
||||
if (page === "service") return <Service workspace={workspace} />;
|
||||
if (page === "profile") return <Profile workspace={workspace} />;
|
||||
if (page === "offerings") return <OfferingList workspace={workspace} />;
|
||||
if (page === "detail") return <Detail workspace={workspace} id={offeringId} />;
|
||||
return <View className="food-forms">{children}</View>;
|
||||
return (
|
||||
<View className="food-forms" data-editor-target={formTargets[page]}>
|
||||
{children}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
function OfferingList({ workspace }: { workspace: RuntimeWorkspace }) {
|
||||
const p = presentation(workspace, "offerings");
|
||||
@@ -363,7 +373,7 @@ function OfferingList({ workspace }: { workspace: RuntimeWorkspace }) {
|
||||
.includes(query.trim().toLowerCase()),
|
||||
);
|
||||
return (
|
||||
<View className="food-list">
|
||||
<View className="food-list" data-editor-target="acheng-campus-food.offerings.menu">
|
||||
<View className="page">
|
||||
<View className="filters">
|
||||
<Button
|
||||
@@ -437,7 +447,7 @@ function Detail({ workspace, id }: { workspace: RuntimeWorkspace; id?: string })
|
||||
const item = offering(found);
|
||||
const p = presentation(workspace, "detail");
|
||||
return (
|
||||
<View className="food-detail">
|
||||
<View className="food-detail" data-editor-target="acheng-campus-food.detail.dishDetail">
|
||||
<View className="detail">
|
||||
<View className="hero-wrap">
|
||||
<Image
|
||||
@@ -454,7 +464,7 @@ function Detail({ workspace, id }: { workspace: RuntimeWorkspace; id?: string })
|
||||
<Text>{item.series}</Text>
|
||||
</View>
|
||||
</View>
|
||||
<View className="content">
|
||||
<View className="content" data-editor-target="acheng-campus-food.detail.detailCopy">
|
||||
<View className="price-card">
|
||||
<View>
|
||||
<Text>{p.priceLabel || "参考价格"}</Text>
|
||||
|
||||
Reference in new issue
Block a user