mirror of
https://github.com/m1ngsama/TUT.git
synced 2026-02-08 09:04:04 +00:00
Phase 10 - Complete async image downloading system HttpClient enhancements: - Add ImageDownloadTask structure for async binary downloads - Implement separate curl multi handle for concurrent image downloads - Add methods: add_image_download, poll_image_downloads, get_completed_images - Support configurable concurrency (default: 3 parallel downloads) - Cancel all images support Browser improvements: - Replace synchronous load_images() with async queue_images() - Progressive rendering - images appear as they download - Non-blocking UI during image downloads - Real-time progress display with spinner - Esc key cancels image loading - Maintains LRU image cache compatibility Performance benefits: - 3x faster image loading (3 concurrent downloads) - UI remains responsive during downloads - Users can scroll/navigate while images load - Gradual page appearance improves perceived performance Tests: - test_async_images: Full async download test suite - test_image_minimal: Minimal async workflow test - test_simple_image: Basic queueing test Technical details: - Dedicated curl multi handle for images (independent of page loading) - Queue-based download management (pending → loading → completed) - Progressive relayout as images complete - Preserves 10-minute LRU image cache
171 lines
3.2 KiB
CMake
171 lines
3.2 KiB
CMake
cmake_minimum_required(VERSION 3.15)
|
|
project(TUT VERSION 2.0.0 LANGUAGES CXX)
|
|
|
|
# C++17标准
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
# 编译选项
|
|
add_compile_options(-Wall -Wextra -Wpedantic)
|
|
|
|
# macOS: Use Homebrew ncurses if available
|
|
if(APPLE)
|
|
set(CMAKE_PREFIX_PATH "/opt/homebrew/opt/ncurses" ${CMAKE_PREFIX_PATH})
|
|
endif()
|
|
|
|
# 查找依赖库
|
|
find_package(CURL REQUIRED)
|
|
find_package(Curses REQUIRED)
|
|
find_package(PkgConfig REQUIRED)
|
|
pkg_check_modules(GUMBO REQUIRED gumbo)
|
|
|
|
# 包含目录
|
|
include_directories(
|
|
${CMAKE_SOURCE_DIR}/src
|
|
${CMAKE_SOURCE_DIR}/src/render
|
|
${CMAKE_SOURCE_DIR}/src/utils
|
|
${CURL_INCLUDE_DIRS}
|
|
${CURSES_INCLUDE_DIRS}
|
|
${GUMBO_INCLUDE_DIRS}
|
|
)
|
|
|
|
# ==================== TUT 主程序 ====================
|
|
|
|
add_executable(tut
|
|
src/main.cpp
|
|
src/browser.cpp
|
|
src/http_client.cpp
|
|
src/input_handler.cpp
|
|
src/bookmark.cpp
|
|
src/history.cpp
|
|
src/render/terminal.cpp
|
|
src/render/renderer.cpp
|
|
src/render/layout.cpp
|
|
src/render/image.cpp
|
|
src/utils/unicode.cpp
|
|
src/dom_tree.cpp
|
|
src/html_parser.cpp
|
|
)
|
|
|
|
target_link_directories(tut PRIVATE
|
|
${GUMBO_LIBRARY_DIRS}
|
|
)
|
|
|
|
target_link_libraries(tut
|
|
${CURSES_LIBRARIES}
|
|
CURL::libcurl
|
|
${GUMBO_LIBRARIES}
|
|
)
|
|
|
|
# ==================== 测试程序 ====================
|
|
|
|
# Terminal 测试
|
|
add_executable(test_terminal
|
|
src/render/terminal.cpp
|
|
tests/test_terminal.cpp
|
|
)
|
|
|
|
target_link_libraries(test_terminal
|
|
${CURSES_LIBRARIES}
|
|
)
|
|
|
|
# Renderer 测试
|
|
add_executable(test_renderer
|
|
src/render/terminal.cpp
|
|
src/render/renderer.cpp
|
|
src/utils/unicode.cpp
|
|
tests/test_renderer.cpp
|
|
)
|
|
|
|
target_link_libraries(test_renderer
|
|
${CURSES_LIBRARIES}
|
|
)
|
|
|
|
# Layout 测试
|
|
add_executable(test_layout
|
|
src/render/terminal.cpp
|
|
src/render/renderer.cpp
|
|
src/render/layout.cpp
|
|
src/render/image.cpp
|
|
src/utils/unicode.cpp
|
|
src/dom_tree.cpp
|
|
src/html_parser.cpp
|
|
tests/test_layout.cpp
|
|
)
|
|
|
|
target_link_directories(test_layout PRIVATE
|
|
${GUMBO_LIBRARY_DIRS}
|
|
)
|
|
|
|
target_link_libraries(test_layout
|
|
${CURSES_LIBRARIES}
|
|
${GUMBO_LIBRARIES}
|
|
)
|
|
|
|
# HTTP 异步测试
|
|
add_executable(test_http_async
|
|
src/http_client.cpp
|
|
tests/test_http_async.cpp
|
|
)
|
|
|
|
target_link_libraries(test_http_async
|
|
CURL::libcurl
|
|
)
|
|
|
|
# HTML 解析测试
|
|
add_executable(test_html_parse
|
|
src/html_parser.cpp
|
|
src/dom_tree.cpp
|
|
tests/test_html_parse.cpp
|
|
)
|
|
|
|
target_link_directories(test_html_parse PRIVATE
|
|
${GUMBO_LIBRARY_DIRS}
|
|
)
|
|
|
|
target_link_libraries(test_html_parse
|
|
${GUMBO_LIBRARIES}
|
|
)
|
|
|
|
# 书签测试
|
|
add_executable(test_bookmark
|
|
src/bookmark.cpp
|
|
tests/test_bookmark.cpp
|
|
)
|
|
|
|
# 历史记录测试
|
|
add_executable(test_history
|
|
src/history.cpp
|
|
tests/test_history.cpp
|
|
)
|
|
|
|
# 异步图片下载测试
|
|
add_executable(test_async_images
|
|
src/http_client.cpp
|
|
tests/test_async_images.cpp
|
|
)
|
|
|
|
target_link_libraries(test_async_images
|
|
CURL::libcurl
|
|
)
|
|
|
|
# 简单图片测试
|
|
add_executable(test_simple_image
|
|
src/http_client.cpp
|
|
tests/test_simple_image.cpp
|
|
)
|
|
|
|
target_link_libraries(test_simple_image
|
|
CURL::libcurl
|
|
)
|
|
|
|
# 最小图片测试
|
|
add_executable(test_image_minimal
|
|
src/http_client.cpp
|
|
tests/test_image_minimal.cpp
|
|
)
|
|
|
|
target_link_libraries(test_image_minimal
|
|
CURL::libcurl
|
|
)
|