This commit is contained in:
@@ -54,6 +54,19 @@ const copyPublicStaticSubtree = (subtree) => {
|
||||
console.log(`Copied public static ${subtree} assets to ${path.relative(projectRoot, targetDir)}`)
|
||||
}
|
||||
|
||||
const copyPublicRootSubtree = (subtree) => {
|
||||
const sourceDir = path.join(projectRoot, 'public', subtree)
|
||||
const targetDir = path.join(h5Root, subtree)
|
||||
|
||||
if (!fs.existsSync(sourceDir)) {
|
||||
throw new Error(`Public assets not found: ${sourceDir}`)
|
||||
}
|
||||
|
||||
fs.rmSync(targetDir, { recursive: true, force: true })
|
||||
copyDirectory(sourceDir, targetDir)
|
||||
console.log(`Copied public ${subtree} assets to ${path.relative(projectRoot, targetDir)}`)
|
||||
}
|
||||
|
||||
const copyStaticFile = (fileName) => {
|
||||
const sourceFile = path.join(projectRoot, 'static', fileName)
|
||||
const targetFile = path.join(h5Root, 'static', fileName)
|
||||
@@ -96,6 +109,42 @@ const rewriteCopiedGuideDataUrls = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const rewriteCopiedEngineUrls = () => {
|
||||
const engineDir = path.join(h5Root, 'engine')
|
||||
const replacements = [
|
||||
['http://1.92.206.90:9000/museum-assets', '/museum-assets'],
|
||||
['http://1.92.206.90:9000/tts-audio', '/tts-audio'],
|
||||
['http://1.92.206.90:9000', 'http://legacy-minio.local:9000'],
|
||||
['https://1.92.206.90:9000', 'https://legacy-minio.local:9000'],
|
||||
['https://guide.whaoyue.com/museum-assets', '/museum-assets'],
|
||||
['https://guide.whaoyue.com/tts-audio', '/tts-audio'],
|
||||
['https://guide.whaoyue.com/app-api', '/app-api']
|
||||
]
|
||||
|
||||
const rewriteTextFiles = (dir) => {
|
||||
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
||||
const filePath = path.join(dir, entry.name)
|
||||
if (entry.isDirectory()) {
|
||||
rewriteTextFiles(filePath)
|
||||
continue
|
||||
}
|
||||
if (!entry.isFile() || !/\.(?:html|js|mjs|json|css|map)$/i.test(entry.name)) continue
|
||||
|
||||
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 engine URLs in ${path.relative(projectRoot, filePath)}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rewriteTextFiles(engineDir)
|
||||
}
|
||||
|
||||
copyStaticSubtree('nav-assets')
|
||||
copyStaticSubtree('guide-data')
|
||||
rewriteCopiedGuideDataUrls()
|
||||
@@ -108,6 +157,8 @@ copyStaticSubtree('three')
|
||||
copyStaticFile('exhibit-placeholder.jpg')
|
||||
copyStaticFile('hall-placeholder.jpg')
|
||||
copyPublicStaticSubtree('Fonts')
|
||||
copyPublicRootSubtree('engine')
|
||||
rewriteCopiedEngineUrls()
|
||||
|
||||
if (fs.existsSync(faviconSource)) {
|
||||
fs.copyFileSync(faviconSource, faviconTarget)
|
||||
|
||||
Reference in New Issue
Block a user