feat: 新增独立工坊宣传模板及配置导入验证

This commit is contained in:
que01 committed 2026-10-15 17:44:52 +08:00
1 parent bf4bbf81c7
commit 04e42b3a80
43 files changed
+5726 -13

No files matched your search

+5 -1
View File
@@ -17,13 +17,16 @@ const templates = fs
const key = process.env.TEMPLATE_KEY || templates[0];
if (!key) throw new Error("No Taro template package found");
if (!templates.includes(key)) throw new Error(`Unsupported Taro template: ${key}`);
process.env.TARO_APP_ID ||= process.env.WEAPP_APP_ID;
process.env.TARO_APP_ID ||= process.env.WEAPP_APP_ID || "touristappid";
const template = path.join(root, "packages", `template-${key}`);
const manifest = JSON.parse(fs.readFileSync(path.join(template, "template.json"), "utf8")) as {
packageKey: string;
defaultBrandSlug?: string;
};
if (manifest.packageKey !== key) throw new Error(`Template key mismatch: ${key}`);
const templateApp = JSON.parse(
fs.readFileSync(path.join(template, "miniapp/app.json"), "utf8"),
) as { tabBar?: { color?: string; selectedColor?: string; backgroundColor?: string } };
const brand = process.env.BRAND_SLUG || manifest.defaultBrandSlug || "default-brand";
fs.cpSync(path.join(template, "miniapp/assets"), path.resolve(__dirname, "../src/assets"), {
recursive: true,
@@ -46,6 +49,7 @@ export default defineConfig({
: path.join(template, "taro"),
},
defineConstants: {
TEMPLATE_TAB_STYLE: JSON.stringify(templateApp.tabBar || {}),
TEMPLATE_KEY: JSON.stringify(key),
BRAND_SLUG: JSON.stringify(brand),
API_BASE_URL: JSON.stringify(process.env.API_BASE_URL || "http://localhost:3001"),
+3 -3
View File
@@ -24,9 +24,9 @@ export default defineAppConfig({
...(!PREVIEW_ALL_TEMPLATES
? {
tabBar: {
color: "#8b8178",
selectedColor: "#3b2118",
backgroundColor: "#ffffff",
color: TEMPLATE_TAB_STYLE.color || "#8b8178",
selectedColor: TEMPLATE_TAB_STYLE.selectedColor || "#3b2118",
backgroundColor: TEMPLATE_TAB_STYLE.backgroundColor || "#ffffff",
list: TEMPLATE_MANIFEST.navigation.map((tab) => ({
pagePath: routes[tab.page],
text: tab.label,
+7 -1
View File
@@ -21,9 +21,13 @@ import "./forms.css";
export function Inquiry({
workspace,
preview = false,
choiceStyle = "picker",
beforeSubmit,
}: {
workspace: RuntimeWorkspace;
preview?: boolean;
choiceStyle?: "chips" | "picker";
beforeSubmit?: React.ReactNode;
}) {
const router = useRouter();
const [offeringId, setOfferingId] = useState(router.params.offeringId || "");
@@ -107,7 +111,8 @@ export function Inquiry({
const value = values[field.key];
const stringValue = typeof value === "string" ? value : "";
const chips =
compactForm && field.key === "type" && ["select", "radio"].includes(field.type);
(choiceStyle === "chips" || (compactForm && field.key === "type")) &&
["select", "radio"].includes(field.type);
return (
<View
className={`form-field ${compactForm && compactFieldKeys.has(field.key) ? "half-field" : ""}`}
@@ -200,6 +205,7 @@ export function Inquiry({
);
})}
</View>
{beforeSubmit}
{error && (
<View className="form-error" role="alert">
{error}
+5
View File
@@ -1,3 +1,8 @@
declare const TEMPLATE_TAB_STYLE: {
color?: string;
selectedColor?: string;
backgroundColor?: string;
};
declare const TEMPLATE_KEY: string;
declare const BRAND_SLUG: string;
declare const API_BASE_URL: string;