@echo off chcp 65001 >nul cd /d "%~dp0" set NAME=智慧运营中台-分发包 set OUT=%CD%\dist\%NAME% set ZIP=%CD%\dist\%NAME%.zip if exist "%OUT%" rmdir /s /q "%OUT%" if exist "%ZIP%" del /q "%ZIP%" if not exist "dist" mkdir "dist" mkdir "%OUT%" rem 根目录代码:复制全部 *.js,新增模块不会漏 for %%f in (*.js) do ( copy /y "%%f" "%OUT%\" >nul ) for %%f in (package.json package-lock.json config.example.json README.md 启动.bat 启动.command 启动.sh 打包分发.bat 打包分发.command) do ( if exist "%%f" copy /y "%%f" "%OUT%\" >nul ) robocopy public "%OUT%\public" /E /NFL /NDL /NJH /NJS >nul robocopy napos "%OUT%\napos" /E /NFL /NDL /NJH /NJS >nul robocopy server "%OUT%\server" /E /NFL /NDL /NJH /NJS >nul robocopy scripts "%OUT%\scripts" /E /NFL /NDL /NJH /NJS >nul robocopy node_modules "%OUT%\node_modules" /E /NFL /NDL /NJH /NJS >nul rem 敏感文件与数据默认不进包 if exist "%OUT%\config.json" del /q "%OUT%\config.json" if exist "%OUT%\session.json" del /q "%OUT%\session.json" if exist "%OUT%\manual-shops.json" del /q "%OUT%\manual-shops.json" if exist "%OUT%\ops-export.json" del /q "%OUT%\ops-export.json" if exist "%OUT%\data" rmdir /s /q "%OUT%\data" if exist "%OUT%\workspace" rmdir /s /q "%OUT%\workspace" rem 可选:带上演示数据库(双击运行时默认不带;需要时在命令行执行 打包分发.bat --with-data) if /i "%~1"=="--with-data" ( if exist "data\ops.db" ( mkdir "%OUT%\data" copy /y "data\ops.db" "%OUT%\data\ops.db" >nul echo 已包含演示数据库 data\ops.db ) ) pushd "%OUT%" node -e "require('./server/routes/index.js')" >nul 2>nul if errorlevel 1 ( echo 打包失败:分发包缺少运行期模块,请检查根目录 *.js 是否完整。 popd rmdir /s /q "%OUT%" pause exit /b 1 ) popd powershell -NoProfile -Command "Compress-Archive -LiteralPath '%OUT%' -DestinationPath '%ZIP%' -Force" if exist "%ZIP%" rmdir /s /q "%OUT%" echo 已生成分发包: %ZIP% echo 默认不含 config.json / data / workspace(密钥与数据只留在本机)。 echo 对方解压后双击 启动.bat;首次启动自动生成配置与空数据库。 echo 要求 Node.js 22.13 及以上。 pause