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"),