@@ -67,8 +67,38 @@ const copyStaticFile = (fileName) => {
|
||||
console.log(`Copied ${fileName} to ${path.relative(projectRoot, targetFile)}`)
|
||||
}
|
||||
|
||||
const rewriteCopiedGuideDataUrls = () => {
|
||||
const guideDataDir = path.join(h5Root, 'static', 'guide-data')
|
||||
const replacements = [
|
||||
['http://1.92.206.90:9000/museum-assets', '/museum-assets'],
|
||||
['http://1.92.206.90:9000/tts-audio', '/tts-audio'],
|
||||
['https://guide.whaoyue.com/museum-assets', '/museum-assets'],
|
||||
['https://guide.whaoyue.com/tts-audio', '/tts-audio'],
|
||||
['https://guide.whaoyue.com/app-api', '/app-api'],
|
||||
['"sourceHost": "1.92.206.90:5237"', '"sourceHost": ""']
|
||||
]
|
||||
|
||||
for (const entry of fs.readdirSync(guideDataDir, { withFileTypes: true })) {
|
||||
if (!entry.isFile() || !entry.name.endsWith('.json')) continue
|
||||
|
||||
const filePath = path.join(guideDataDir, entry.name)
|
||||
let text = fs.readFileSync(filePath, 'utf8')
|
||||
const original = text
|
||||
|
||||
for (const [from, to] of replacements) {
|
||||
text = text.split(from).join(to)
|
||||
}
|
||||
|
||||
if (text !== original) {
|
||||
fs.writeFileSync(filePath, text, 'utf8')
|
||||
console.log(`Rewrote guide-data URLs in ${path.relative(projectRoot, filePath)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
copyStaticSubtree('nav-assets')
|
||||
copyStaticSubtree('guide-data')
|
||||
rewriteCopiedGuideDataUrls()
|
||||
copyStaticSubtree('guide')
|
||||
copyStaticSubtree('icons')
|
||||
// 讲解业务单元封面由 H5 运行时按 /static/explain/... 动态加载。
|
||||
|
||||
@@ -43,18 +43,20 @@ const h5JavaScriptCode = h5JavaScriptFiles
|
||||
.map((filePath) => readText(filePath))
|
||||
.join('\n')
|
||||
|
||||
for (const required of ['第三方导航', 'third-party-providers']) {
|
||||
assertContains(pageChunkCode, required, 'H5 首页 chunk')
|
||||
for (const required of [
|
||||
'第三方',
|
||||
'打开地图',
|
||||
'jweixin',
|
||||
'miniProgram',
|
||||
'/pages/open-location/index',
|
||||
'baidumap://',
|
||||
'iosamap://',
|
||||
'androidamap://'
|
||||
]) {
|
||||
assertContains(h5JavaScriptCode, required, 'H5 全量 JS')
|
||||
}
|
||||
|
||||
for (const forbidden of [
|
||||
'打开地图导航',
|
||||
'native-location',
|
||||
'jweixin',
|
||||
'wx.miniProgram',
|
||||
'宿主地图',
|
||||
'/pages/open-location/index'
|
||||
]) {
|
||||
for (const forbidden of ['native-location']) {
|
||||
assertNotContains(h5JavaScriptCode, forbidden, 'H5 全量 JS')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user