From 07f7ac787b914b88437dd2f004887ad1ea8b9de0 Mon Sep 17 00:00:00 2001 From: zyuan Date: Wed, 25 Jun 2025 11:14:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=EF=BC=9A=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BA=93=E7=BC=BA=E5=A4=B1=E5=B4=A9?= =?UTF-8?q?=E6=BA=83=EF=BC=9B=E8=A7=A3=E5=86=B3WebEngineView=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=9C=A8=E8=B0=83=E8=AF=95=E6=A8=A1=E5=BC=8Fdebug?= =?UTF-8?q?=EF=BC=8C=E8=A7=A3=E5=86=B3=E6=96=B9=E6=B3=95=E6=98=AF=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=B8=A6=E8=B0=83=E8=AF=95=E7=AC=A6=E5=8F=B7=E7=9A=84?= =?UTF-8?q?release=EF=BC=9B=E5=B0=86html=E5=A4=8D=E5=88=B6=E5=88=B0?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=E7=9B=AE=E5=BD=95=EF=BC=8C=E4=B8=8D=E5=86=8D?= =?UTF-8?q?=E4=BB=A5=E8=B5=84=E6=BA=90=E6=96=87=E4=BB=B6=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 9 +++++++- CMakeLists.txt | 42 +++++++++++++++++++++++++++++++++++-- DataPlatform/mainwindow.cpp | 3 ++- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index bf8edd2..11f3b21 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ *.sdf # --- 编译产物 --- +bin/ *.o *.a *.so @@ -47,4 +48,10 @@ Thumbs.db *.pdb *.exp *.manifest -*.lib \ No newline at end of file +*.lib + +#reportlog.log +reportlog.log + +#QTlog +QTlog/ \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 81c2c75..bef39df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,11 +12,14 @@ if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type (Debug/Release/RelWithDebInfo/MinSizeRel)" FORCE) endif() set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel") -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -O0") # Debug模式:禁用优化,包含调试符号 -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") # Release模式:最大优化[2,6](@ref) + if(MSVC) #add_compile_options(/W4 /WX) # Windows: 开启所有警告并视警告为错误 add_compile_options(/utf-8) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Od /Zi /Fd${CMAKE_CURRENT_SOURCE_DIR}/bin/Release/DPS.pdb") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG") + + else() add_compile_options(-Wall -Wextra -Wpedantic -Werror) # Linux/macOS: 严格警告[1](@ref) endif() @@ -41,6 +44,9 @@ include_directories(include) file(GLOB_RECURSE SOURCES "DataPlatform/*.cpp" "DataPlatform/*.c" "DataPlatform/*.cc") # 自动收集源码,建议手动指定关键文件 file(GLOB_RECURSE HEADERS "DataPlatform/*.hpp" "DataPlatform/*.h") +#设置可执行文件的输出路径 +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) + add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}) # 链接 Qt 模块 @@ -70,6 +76,38 @@ elseif(UNIX AND NOT APPLE) # 明确排除 macOS message(STATUS "Configuring for Linux") endif() +# 拷贝库文件到输出目录 +if(WIN32) + set(MY_DLLS + WebQt.dll + CCSReport.dll + ODI_Common.dll + ODI_DPS.dll + CodeGenerator.dll + xlnt.dll + SqlcipherTool.dll + DBPService.dll + libeay32.dll + SqliteDBI.dll + ) + foreach(dll ${MY_DLLS}) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${CMAKE_SOURCE_DIR}/3th/release/${dll}" + "$/${dll}" + ) + endforeach() +endif() + +# 拷贝资源文件到输出目录 +if(WIN32) + add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + "${CMAKE_SOURCE_DIR}/DataPlatform/html" + "$/html" + ) +endif() + install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin ARCHIVE DESTINATION lib diff --git a/DataPlatform/mainwindow.cpp b/DataPlatform/mainwindow.cpp index 1792e10..d90d059 100644 --- a/DataPlatform/mainwindow.cpp +++ b/DataPlatform/mainwindow.cpp @@ -100,7 +100,8 @@ MainWindow::MainWindow(QWidget* parent) _webView = new WebEngineView(QUrl(BaseUrl + "#/debug/SearchEditModule/save-data-to-file"), this); #else - _webView = new WebEngineView(QUrl(BaseUrl), this); + QString indexHtmlPath = QCoreApplication::applicationDirPath() + "/" + "html/index.html"; + _webView = new WebEngineView(QUrl::fromLocalFile(indexHtmlPath), this); #endif // WEBDEGUB this->setCentralWidget(_webView); _eventModule = new SignalEventModule("MainWindow");