From baafc2a29de4f0c5bcd748fffcc71e66be46ce85 Mon Sep 17 00:00:00 2001 From: Zengtudor Date: Sat, 10 May 2025 18:46:52 +0800 Subject: [PATCH] update --- .gitignore | 3 +- CMakeLists.txt | 12 +++- src/html_string.hpp.in | 5 ++ src/index.html | 125 +++++++++++++++++++++++++++++++++++++++++ src/main.cpp | 70 +++++++++++++++++++++-- 5 files changed, 209 insertions(+), 6 deletions(-) create mode 100644 src/html_string.hpp.in create mode 100644 src/index.html diff --git a/.gitignore b/.gitignore index e050ba0..c8cde91 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /build -/.cache \ No newline at end of file +/.cache +/src/html_string.hpp \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 75c7c8a..08ecd0f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,9 +3,19 @@ cmake_minimum_required(VERSION 3.10) project(eew CXX) find_package(webview REQUIRED) +find_package(Threads REQUIRED) + +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) file(GLOB_RECURSE SRC_CPP CONFIGURE_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/src/*.cpp) +file(READ "${CMAKE_CURRENT_LIST_DIR}/src/index.html" HTML_CONTENT CONFIGURE_DEPENDS) +configure_file( + ${CMAKE_CURRENT_LIST_DIR}/src/html_string.hpp.in + ${CMAKE_CURRENT_LIST_DIR}/src/html_string.hpp +) add_executable(${PROJECT_NAME} ${SRC_CPP}) -target_link_libraries(${PROJECT_NAME} PRIVATE webview::core) \ No newline at end of file +target_link_libraries(${PROJECT_NAME} PRIVATE webview::core Threads::Threads) \ No newline at end of file diff --git a/src/html_string.hpp.in b/src/html_string.hpp.in new file mode 100644 index 0000000..d5408b5 --- /dev/null +++ b/src/html_string.hpp.in @@ -0,0 +1,5 @@ +#pragma once + +constexpr const char* html = R"( +@HTML_CONTENT@ +)"; \ No newline at end of file diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..03c003d --- /dev/null +++ b/src/index.html @@ -0,0 +1,125 @@ + + + + + + Environment Variables Table + + + +

Environment Variables

+ + + + + + + + + + +
KeyValue
+ + + + \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 610b75c..d09a577 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,9 +1,71 @@ +#include "html_string.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include +extern char** environ; -int main(){ - webview::webview wv(false,nullptr); - wv.navigate("https://www.baidu.com"); - wv.run(); +using vpss_t = std::vector>; +vpss_t getEnvKv(){ + vpss_t result; + for(char **env = environ; *env != nullptr; env++){ + const std::string thisEnv = *env; + const size_t idx = thisEnv.find('='); + if (idx == std::string::npos) { + throw std::logic_error("cannot parse env"); + } + result.emplace_back(thisEnv.substr(0,idx),thisEnv.substr(idx+1)); + } + return result; +} + +template +std::ostream&operator<<(std::ostream &os,const std::pair &p){ + os<<"{ "< +std::ostream&operator<<(std::ostream &os,const std::vector &v){ + os<<"[ "; + if(v.size()==1){ + os<std::string { + std::stringstream oss; + oss<