解决登录显示、首页显示bug

This commit is contained in:
2026-05-19 11:06:46 +08:00
parent 2f7e097e6c
commit 00a859c551
181 changed files with 55329 additions and 998 deletions

View File

@@ -14,6 +14,8 @@ const root = path.resolve(__dirname, "..");
const pagesJson = path.join(root, "pages.json");
const pagesFull = path.join(root, "pages.full.json");
const backupDir = path.join(root, ".pages-backup");
const pagesModeFile = path.join(root, "utils", "pagesMode.uts");
const currentClientFile = path.join(root, "config", "current-client.uts");
const pageExtensions = [".uvue", ".vue", ".nvue"];
const consumerUserPages = [
@@ -51,6 +53,8 @@ const targetConfigs = {
fileName: "pages.consumer.json",
label: "消费者端",
entryPath: "pages/main/index",
homeRedirect: "/pages/main/index",
tabBarPath: "/pages/main/index",
orderedTopLevelPaths: [
"pages/main/index",
...consumerUserPages,
@@ -88,6 +92,8 @@ const targetConfigs = {
fileName: "pages.merchant.json",
label: "商家端",
entryPath: "pages/user/login",
homeRedirect: "/pages/mall/merchant/index",
tabBarPath: "",
orderedTopLevelPaths: [
"pages/user/login",
"pages/user/boot",
@@ -127,6 +133,8 @@ const targetConfigs = {
fileName: "pages.admin.json",
label: "管理后台",
entryPath: "pages/user/login",
homeRedirect: "/pages/mall/admin/homePage/index",
tabBarPath: "",
orderedTopLevelPaths: [
"pages/user/login",
"pages/user/boot",
@@ -159,6 +167,19 @@ const targetConfigs = {
};
},
},
delivery: {
fileName: "pages.delivery.json",
label: "服务人员端/上门服务端",
entryPath: "pages/user/login",
homeRedirect: "/pages/mall/delivery/home/index",
tabBarPath: "/pages/mall/delivery/home/index",
standalone: true,
},
};
const fullModeConfig = {
homeRedirect: "/pages/main/index",
tabBarPath: "/pages/main/index",
};
const mode = process.argv[2]; // 'consumer' | 'merchant' | 'admin' | 'full'
@@ -172,6 +193,24 @@ function writeJson(filePath, content) {
fs.writeFileSync(filePath, `${JSON.stringify(content, null, 2)}\n`, "utf8");
}
function writePagesMode(modeName) {
fs.writeFileSync(
pagesModeFile,
`export const CURRENT_PAGES_MODE = '${modeName}'\n`,
"utf8",
);
}
function writeCurrentClient(modeName) {
fs.mkdirSync(path.dirname(currentClientFile), { recursive: true });
fs.writeFileSync(
currentClientFile,
`export const CURRENT_CLIENT: string = '${modeName}'\n`,
"utf8",
);
console.log(`🔁 已同步当前端标识 → ${modeName}`);
}
function ensureFullBackup() {
if (fs.existsSync(pagesFull)) {
return;
@@ -373,6 +412,8 @@ function writeTargetConfig(targetName, config) {
const targetPath = path.join(root, targetConfigs[targetName].fileName);
writeJson(targetPath, config);
fs.copyFileSync(targetPath, pagesJson);
writePagesMode(targetName);
writeCurrentClient(targetName);
const pageCount = config.pages.length;
const subPackageCount = config.subPackages.length;
@@ -386,6 +427,35 @@ function writeTargetConfig(targetName, config) {
console.log(" 恢复完整版本npm run pages:full");
}
function switchStandaloneConfig(targetName) {
const targetPath = path.join(root, targetConfigs[targetName].fileName);
if (!fs.existsSync(targetPath)) {
console.error(`${targetConfigs[targetName].fileName} 不存在。`);
process.exit(1);
}
const config = readJson(targetPath);
validateGeneratedConfig(targetName, config);
fs.copyFileSync(targetPath, pagesJson);
writePagesMode(targetName);
writeCurrentClient(targetName);
const pageCount = config.pages != null ? config.pages.length : 0;
const subPackageCount =
config.subPackages != null ? config.subPackages.length : 0;
const tabBarCount =
config.tabBar != null && Array.isArray(config.tabBar.list)
? config.tabBar.list.length
: 0;
console.log(`✅ 已切换为【${targetConfigs[targetName].label}专属编译模式】`);
console.log(` 目标配置:${targetConfigs[targetName].fileName}`);
console.log(` pages${pageCount}`);
console.log(` subPackages${subPackageCount}`);
console.log(` tabBar${tabBarCount}`);
console.log(" 恢复完整版本npm run pages:full");
}
function restoreFullPages() {
if (!fs.existsSync(pagesFull)) {
console.error("❌ pages.full.json 不存在。");
@@ -395,6 +465,8 @@ function restoreFullPages() {
backupCurrentPages("full");
fs.copyFileSync(pagesFull, pagesJson);
writePagesMode("full");
writeCurrentClient("full");
console.log("✅ 已恢复【完整 pages.json】");
console.log(" 包含 consumer + merchant + admin 全部页面。");
}
@@ -405,6 +477,11 @@ if (mode === "full") {
ensureFullBackup();
backupCurrentPages(mode);
if (targetConfigs[mode].standalone === true) {
switchStandaloneConfig(mode);
process.exit(0);
}
const fullConfig = readJson(pagesFull);
const sourceCondition = fs.existsSync(pagesJson)
? (() => {
@@ -421,6 +498,7 @@ if (mode === "full") {
} else {
console.log("用法:");
console.log(" npm run pages:consumer 切换到消费者端专属编译模式");
console.log(" npm run pages:delivery 切换到服务人员端专属编译模式");
console.log(" npm run pages:merchant 切换到商家端专属编译模式");
console.log(" npm run pages:admin 切换到管理后台专属编译模式");
console.log(" npm run pages:full 恢复完整编译模式");