From dc48091d5b679003d08cb3668e04610187333401 Mon Sep 17 00:00:00 2001 From: yuanyuanxiang <962914132@qq.com> Date: Sun, 17 May 2026 18:46:21 +0200 Subject: [PATCH] Refactor(Web): Extract embedded HTML to server/web/index.html --- server/2015Remote/2015Remote.rc | Bin 155820 -> 155962 bytes server/2015Remote/WebPage.h | 3559 +----------------------------- server/2015Remote/WebService.cpp | 3 + server/2015Remote/resource.h | 3 +- server/web/index.html | 3474 +++++++++++++++++++++++++++++ 5 files changed, 3493 insertions(+), 3546 deletions(-) create mode 100644 server/web/index.html diff --git a/server/2015Remote/2015Remote.rc b/server/2015Remote/2015Remote.rc index c5e25989197cf1aeb3841ac314ca613122ea2dcc..c11e01480b7bd017ed29db151f51cd42ed90a757 100644 GIT binary patch delta 79 zcmZ2;kaO1|&W0AoEle}qrdPQ#2?%>K_%XOJxH3dA#4~s>gfRFr_)NcO&Ezgy&XCHG g#1I37nGAUhDL`HYgC0W$LkUAJL(cYzZcNfr0Br0N+W-In delta 19 bcmdmWh;z+B&W0AoEle}qwyU`_iAVteQ #include +#include "resource.h" -// Embedded HTML page for web remote control -// Split into parts to avoid MSVC string literal limit (16KB) - +// Embedded HTML page for web remote control. +// Source of truth: server/web/index.html (shared with future Go server). +// Compiled into the binary as RC BINARY resource IDR_WEB_INDEX_HTML. inline std::string GetWebPageHTML() { - std::string html; - - // Part 1: Head and base styles - html += R"HTML( - - - - - SimpleRemoter - - - - - - - - - - - - - -)HTML"; - - // Part 6: HTML body - html += R"HTML( -
- -
-
- -
-
Total: 0
-
Showing: 0
-
-
- -
-
-
- -
-
-
-
-
- Connecting... - - - - -
-
-
- -
-
- - - - -
-
- - - - - - - - - -
-
-
- -
- - - - -
-
100%
- -
- - -
-
- -
-
Terminal
-
Connecting...
-
-
-
- -
- - - - - -
-
- - - - - - -)HTML"; - - // 加载 xterm.js + FitAddon(终端)。放在 app script 前,保证 Terminal/FitAddon 全局可用。 - html += R"HTML( - - -)HTML"; - - // Part 7: JavaScript - State and WebSocket - html += R"HTML( - - -)HTML"; - - return html; + HRSRC hRes = FindResourceA(NULL, MAKEINTRESOURCEA(IDR_WEB_INDEX_HTML), "BINARY"); + if (!hRes) return {}; + DWORD size = SizeofResource(NULL, hRes); + if (!size) return {}; + HGLOBAL hData = LoadResource(NULL, hRes); + if (!hData) return {}; + LPVOID p = LockResource(hData); + if (!p) return {}; + return std::string(static_cast(p), size); } diff --git a/server/2015Remote/WebService.cpp b/server/2015Remote/WebService.cpp index 1c3acaf..b38e38e 100644 --- a/server/2015Remote/WebService.cpp +++ b/server/2015Remote/WebService.cpp @@ -255,6 +255,9 @@ void CWebService::ServerThread(int port) { // Serve static HTML page and file downloads static std::string cachedHtml = GetWebPageHTML(); + // Log loaded size; zero bytes means the RC BINARY resource is missing or + // server/web/index.html was not embedded — check 2015Remote.rc and rebuild. + Mprintf("[WebService] index.html loaded: %zu bytes\n", cachedHtml.size()); std::string payloadsDir = m_PayloadsDir; // Capture for lambda // 静态资源缓存:xterm.js / xterm.css / fit-addon。RC binary 资源加载一次缓存到内存, diff --git a/server/2015Remote/resource.h b/server/2015Remote/resource.h index 5c8d9b8..821ec30 100644 --- a/server/2015Remote/resource.h +++ b/server/2015Remote/resource.h @@ -262,6 +262,7 @@ #define IDR_WEB_XTERM_JS 382 #define IDR_WEB_XTERM_CSS 383 #define IDR_WEB_XTERM_FIT_JS 384 +#define IDR_WEB_INDEX_HTML 385 #define IDC_MESSAGE 1000 #define IDC_ONLINE 1001 #define IDC_STATIC_TIPS 1002 @@ -988,7 +989,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 385 +#define _APS_NEXT_RESOURCE_VALUE 386 #define _APS_NEXT_COMMAND_VALUE 33051 #define _APS_NEXT_CONTROL_VALUE 2542 #define _APS_NEXT_SYMED_VALUE 105 diff --git a/server/web/index.html b/server/web/index.html new file mode 100644 index 0000000..fbd6d96 --- /dev/null +++ b/server/web/index.html @@ -0,0 +1,3474 @@ + + + + + + SimpleRemoter + + + + + + + + + + + + + + +
+ +
+
+ +
+
Total: 0
+
Showing: 0
+
+
+ +
+
+
+ +
+
+
+
+
+ Connecting... + + + + +
+
+
+ +
+
+ + + + +
+
+ + + + + + + + + +
+
+
+ +
+ + + + +
+
100%
+ +
+ + +
+
+ +
+
Terminal
+
Connecting...
+
+
+
+ +
+ + + + + +
+
+ + + + + + + + + + + + + \ No newline at end of file