diff --git a/manifest.json b/manifest.json index 6147525..f2c52f8 100644 --- a/manifest.json +++ b/manifest.json @@ -107,7 +107,7 @@ }, "router" : { "mode" : "history", - "base" : "/hwappx/common" + "base" : "/hwappx/common/" }, "title" : "", "devServer" : { diff --git a/vue.config.js b/vue.config.js index ae55ea4..74bf2b9 100644 --- a/vue.config.js +++ b/vue.config.js @@ -74,11 +74,15 @@ try { function _readManifestBase(manifestPath) { try { const raw = fs.readFileSync(manifestPath, 'utf8'); - // 去掉 /* */ 和 // 注释(HBuilder 生成的 JSON 允许注释) const clean = raw.replace(/\/\*[\s\S]*?\*\//g, '').replace(/\/\/.*$/gm, ''); const manifest = JSON.parse(clean); if (manifest?.h5?.router?.base) { - return manifest.h5.router.base.replace(/^\/+|\/+$/g, '').replace(/\//g, '.'); + let base = manifest.h5.router.base; + if (!base.endsWith('/')) { + console.warn(`[manifest] h5.router.base "${base}" 不规范,已自动补全 /`); + base = base + '/'; + } + return base.replace(/^\/+|\/+$/g, '').replace(/\//g, '.'); } } catch (e) { console.warn('[manifest] 读取 h5.router.base 失败:', e.message);