fix: 修复模板页面跳转并移除无入口的下单页
新增运行时 openPage/takePageQuery,tabBar 页自动使用 switchTab 并传递参数 - 编译器写入 tabPages,并拒绝 navigateTo/redirectTo 到 tabBar 页或 switchTab 带参数 - 阿成首页、套餐、出摊、主理人、详情、记录、成功页跳转统一改用 openPage - 套餐筛选改用后台业务提供项分类;详情跳咨询时携带业务提供项 - 移除 capability-booking:小程序无入口且依赖已删除的 /public/brand,需求由咨询表单覆盖"
This commit is contained in:
1 parent
a97cc860cf
commit
55989a5dfe
29 files changed
+353
-119
No files matched your search
@@ -237,6 +237,7 @@ function writeGeneratedFiles(output, manifest, params, appJson, capabilities) {
|
||||
templateKey: manifest.packageKey,
|
||||
templateVersion: manifest.version,
|
||||
runtimeContract: manifest.runtimeContract,
|
||||
tabPages: appJson.tabBar.list.map((item) => item.pagePath),
|
||||
};
|
||||
fs.writeFileSync(
|
||||
path.join(output, "runtime-config.js"),
|
||||
@@ -314,6 +315,7 @@ function validateOutput(output, appJson, packageKey) {
|
||||
}
|
||||
}
|
||||
const hasNpm = fs.existsSync(path.join(output, "miniprogram_npm"));
|
||||
const tabPages = new Set(appJson.tabBar.list.map((item) => item.pagePath));
|
||||
const forbiddenComponents = otherTemplateComponentNames(packageKey);
|
||||
const sourceFiles = listFiles(output, new Set(["miniprogram_npm"])).filter((file) =>
|
||||
/\.(js|json|wxml)$/.test(file),
|
||||
@@ -337,6 +339,16 @@ function validateOutput(output, appJson, packageKey) {
|
||||
if (!resolveRequire(output, file, match[1]))
|
||||
errors.push(`${file}: require("${match[1]}") cannot be resolved`);
|
||||
}
|
||||
// 微信不允许 navigateTo/redirectTo 到 tabBar 页,switchTab 也不能带参数;失败时页面毫无反应。
|
||||
for (const match of source.matchAll(
|
||||
/wx\.(navigateTo|redirectTo|switchTab)\(\s*\{\s*url:\s*["'`]\/?([^"'`?]+)(\?)?/g,
|
||||
)) {
|
||||
const [, method, target, hasQuery] = match;
|
||||
if (method !== "switchTab" && tabPages.has(target))
|
||||
errors.push(`${file}: wx.${method} cannot open tabBar page ${target}; use openPage()`);
|
||||
if (method === "switchTab" && hasQuery)
|
||||
errors.push(`${file}: wx.switchTab cannot pass a query to ${target}; use openPage()`);
|
||||
}
|
||||
}
|
||||
if (file.startsWith("pages/") || file.startsWith("components/")) {
|
||||
for (const token of ["pageRenderer", "templateKey ==="]) {
|
||||
|
||||
Reference in new issue
Block a user