减小打包体积

This commit is contained in:
2026-09-06 00:24:19 +08:00
parent 85c4fcde41
commit cc99b7b596
4 changed files with 48 additions and 2 deletions
+3
View File
@@ -8,6 +8,9 @@ node_modules/
*.tsbuildinfo *.tsbuildinfo
.npm-cache .npm-cache
# C++ 编译中间产物(目标文件,clone 后无用)
*.obj
# Generated Vite config output (source is vite.config.ts) # Generated Vite config output (source is vite.config.ts)
vite.config.js vite.config.js
vite.config.d.ts vite.config.d.ts
+14 -2
View File
@@ -81,8 +81,20 @@ std::string form_value(const std::string& body, const std::string& key) {
} }
std::string sanitize_process_error(std::string output) { std::string sanitize_process_error(std::string output) {
output = std::regex_replace(output, std::regex(R"(^Licensed to:.*$)", std::regex::icase | std::regex::multiline), "Spine 授权信息已隐藏"); // 逐行替换,避免依赖 std::regex::multilineMSVC 的 <regex> 未实现该标志)。
return trim(output); const std::regex licensed(R"(^Licensed to:.*$)", std::regex::icase);
std::string result;
std::size_t start = 0;
while (start <= output.size()) {
const auto end = output.find('\n', start);
std::string line = output.substr(start, end - start);
if (!line.empty() && line.back() == '\r') line.pop_back();
result += std::regex_replace(line, licensed, "Spine 授权信息已隐藏");
if (end == std::string::npos) break;
result += '\n';
start = end + 1;
}
return trim(result);
} }
std::pair<std::vector<std::uint8_t>, std::string> convert(const Json& payload, const std::string& executable) { std::pair<std::vector<std::uint8_t>, std::string> convert(const Json& payload, const std::string& executable) {
+31
View File
@@ -0,0 +1,31 @@
@echo off
setlocal
rem 使用 MSVC 编译 Windows 原生连接器(单 exe,体积优化)
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars64.bat" >nul
if errorlevel 1 (
echo 未能初始化 MSVC 环境,请确认已安装 VS 2022 Build Tools 及 C++ 工具集。
exit /b 1
)
set "SRC_DIR=%~dp0..\connector\native"
set "OUT_DIR=%~dp0..\release\connector\windows-x64"
if not exist "%OUT_DIR%" mkdir "%OUT_DIR%"
pushd "%SRC_DIR%"
cl /nologo /std:c++17 /utf-8 /O1 /GL /EHsc /MT /W3 /D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0601 ^
app_windows.cpp config.cpp connector_service.cpp encoding.cpp http_server.cpp json.cpp platform_common.cpp process_windows.cpp workspace.cpp zip.cpp ^
/link /SUBSYSTEM:WINDOWS /LTCG /OPT:REF /OPT:ICF ^
user32.lib gdi32.lib comdlg32.lib ws2_32.lib shell32.lib ole32.lib ^
/OUT:"%OUT_DIR%\SpineParticleConnector.exe"
del /q "%SRC_DIR%\*.obj" >nul 2>&1
set "RC=%ERRORLEVEL%"
popd
if "%RC%"=="0" (
echo.
echo 构建成功:%OUT_DIR%\SpineParticleConnector.exe
) else (
echo.
echo 构建失败,错误码 %RC%
)
exit /b %RC%