diff --git a/CApi/CMakeLists.txt b/CApi/CMakeLists.txt index 023d8ba..8cdc00d 100644 --- a/CApi/CMakeLists.txt +++ b/CApi/CMakeLists.txt @@ -19,3 +19,8 @@ add_library(CApi SHARED target_link_libraries(CApi PRIVATE Qt${QT_VERSION_MAJOR}::Core QCloudMusicApi) target_compile_definitions(CApi PRIVATE CAPI_LIBRARY) + +set(PUBLIC_HEADERS + capi.h +) +install(FILES ${PUBLIC_HEADERS} DESTINATION ${CMAKE_HEADER_OUTPUT_DIRECTORY}) diff --git a/CMakeLists.txt b/CMakeLists.txt index 06d5427..bf0c6ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,10 +7,19 @@ project(QCloudMusicApiProject VERSION 1.0) # C++标准 set(CMAKE_CXX_STANDARD 17) -# 设置动态库和可执行程序的输出路径为 bin 目录 -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +# set default output path +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/lib) +set(CMAKE_HEADER_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/include) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) + +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}) # 添加子目录 add_subdirectory(QCloudMusicApi) diff --git a/QCloudMusicApi/CMakeLists.txt b/QCloudMusicApi/CMakeLists.txt index 0031054..dd73edc 100644 --- a/QCloudMusicApi/CMakeLists.txt +++ b/QCloudMusicApi/CMakeLists.txt @@ -25,6 +25,8 @@ target_link_libraries(QCloudMusicApi Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_ target_compile_definitions(QCloudMusicApi PRIVATE QCLOUDMUSICAPI_LIBRARY) -set(PUBLIC_HEADERS module.h) +set(PUBLIC_HEADERS + module.h +) install(FILES ${PUBLIC_HEADERS} DESTINATION ${CMAKE_HEADER_OUTPUT_DIRECTORY}) install(DIRECTORY ${OPENSSL_INCLUDE_DIR}/../bin DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../) diff --git a/QCloudMusicApi/request.hpp b/QCloudMusicApi/request.hpp index c936118..5b09e83 100644 --- a/QCloudMusicApi/request.hpp +++ b/QCloudMusicApi/request.hpp @@ -223,9 +223,6 @@ static auto createRequest(QNetworkAccessManager::Operation method, QString urlSt { "cookie", {} } }; - //设置默认超时时间 - reply->manager()->setTransferTimeout(QNetworkRequest::DefaultTransferTimeoutConstant); - // 开启一个局部的事件循环,等待响应结束,退出 QEventLoop eventLoop; QObject::connect(reply->manager(), &QNetworkAccessManager::finished, &eventLoop, &QEventLoop::quit); // 请求结束时退出事件循环 diff --git a/QCloudMusicApi/util/index.h b/QCloudMusicApi/util/index.h index 21c6f30..4ec589c 100644 --- a/QCloudMusicApi/util/index.h +++ b/QCloudMusicApi/util/index.h @@ -48,5 +48,13 @@ QList mapToCookie(QVariantMap &cookie) { } return list; } +QVariantMap mergeMap(const QVariantMap &map0, const QVariantMap &map1) +{ + QVariantMap result = map0; //复制第一个map + for (auto i = map1.constBegin(); i != map1.constEnd(); ++i) { + result.insert(i.key(), i.value()); //插入或覆盖第二个map的键值对 + } + return result; +} } #endif // INDEX_H diff --git a/README.md b/README.md index 1e180ac..e84d696 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ Qt版 网易云音乐 API ## 需求和依赖 本项目需要以下库和工具: -- Qt >= 5.10 +- Qt >= 5.12 - OpenSSL >= 1.1.1 - conan2 diff --git a/Test/mainwindow.cpp b/Test/mainwindow.cpp index 003eb98..58b5197 100644 --- a/Test/mainwindow.cpp +++ b/Test/mainwindow.cpp @@ -30,7 +30,7 @@ void MainWindow::updateCookie(QVariantMap ret) { if (ret["body"].toMap()["token"].isValid()) { map["MUSIC_A"] = ret["body"].toMap()["token"]; } - map.insert(newMap); + Index::mergeMap(map, newMap); cookie = Index::mapToString(map); }