feat: 新增api自动生成配置

This commit is contained in:
DEV_DSW
2025-12-16 11:30:08 +08:00
parent bfc602c420
commit a7b4c23155
67 changed files with 9570 additions and 4588 deletions

23
scripts/clean.js Normal file
View File

@@ -0,0 +1,23 @@
const { execSync } = require('child_process')
const fs = require('fs-extra')
const path = require('path')
function cleanOutRoot() {
const outDir = path.resolve(process.cwd(), 'out')
if (!fs.pathExistsSync(outDir)) {
return
}
fs.removeSync(outDir)
if (fs.pathExistsSync(outDir)) {
execSync(`cmd /c rd /s /q "${outDir}"`, { stdio: 'ignore' })
process.exitCode = 1
}
}
cleanOutRoot()

View File

@@ -0,0 +1,23 @@
const fs = require('fs')
const path = require('path')
const entryPath = path.join(process.cwd(), '.vite/build/main.js')
const jscPath = path.join(process.cwd(), '.vite/build/main.jsc')
if (!fs.existsSync(entryPath)) {
throw new Error('主进程入口未找到,请先构建主进程')
}
if (!fs.existsSync(jscPath)) {
const bytenode = require('bytenode')
bytenode.compileFile({ filename: entryPath, output: jscPath })
}
const content = [
"require('bytenode')",
"require('./main.jsc')"
].join('\n')
const outputPath = entryPath
fs.mkdirSync(path.dirname(outputPath), { recursive: true })
fs.writeFileSync(outputPath, content)
console.log(`生产环境入口文件已生成: ${outputPath}`)