feat: electron desktop packaging, CDN asset migration, production docs, scene JSON spec

This commit is contained in:
2026-06-09 23:20:27 +08:00
parent 48fb89449a
commit 3a7dd2f405
35 changed files with 900 additions and 135 deletions

36
scripts/pack-html.mjs Normal file
View File

@@ -0,0 +1,36 @@
// Web 打包脚本vite build → 验证 JSON → zip → release/mygame.zip
import { execSync } from 'child_process'
import { existsSync, readFileSync, mkdirSync, rmSync } from 'fs'
import { join, dirname } from 'path'
import { fileURLToPath } from 'url'
const __dirname = dirname(fileURLToPath(import.meta.url))
const root = join(__dirname, '..')
const dist = join(root, 'dist')
const release = join(root, 'release')
const jsonPath = join(dist, 'scenes', 'my_story.json')
console.log('🔨 Building...')
execSync('npx vite build', { cwd: root, stdio: 'inherit' })
if (existsSync(jsonPath)) {
try {
JSON.parse(readFileSync(jsonPath, 'utf-8'))
console.log('✅ JSON 格式验证通过')
} catch (err) {
console.error('❌ JSON 解析失败:', err.message)
process.exit(1)
}
} else {
console.log('⚠️ 未找到 my_story.json跳过验证')
}
rmSync(release, { recursive: true, force: true })
mkdirSync(release, { recursive: true })
const zipName = 'mygame'
console.log('📦 打包中...')
execSync(`zip -r ${join(release, zipName)}.zip .`, { cwd: dist, stdio: 'inherit' })
console.log(`\n✅ 打包完成 → ${join(release, zipName)}.zip`)
console.log('📤 将此 zip 上传到 itch.io → 选择 "HTML" 类型 → 发布')