Skip to content

Commit cda75db

Browse files
committed
重构:统一 HTTP 为 cpr,接口与常量集中管理
1 parent 9c4f8c8 commit cda75db

24 files changed

Lines changed: 697 additions & 1140 deletions

CMakeLists.txt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,20 @@ add_executable(${PROJECT_NAME}
8484
"${CMAKE_SOURCE_DIR}/src/UI/WindowGeeTest.cpp"
8585
"${CMAKE_SOURCE_DIR}/src/Core/CryptoKit.cpp"
8686
"${CMAKE_SOURCE_DIR}/src/Core/CryptoKit.h"
87-
"${CMAKE_SOURCE_DIR}/src/Core/HttpClient.cpp"
88-
"${CMAKE_SOURCE_DIR}/src/Core/HttpClient.h"
8987
"${CMAKE_SOURCE_DIR}/src/Core/LiveStreamLink.cpp"
9088
"${CMAKE_SOURCE_DIR}/src/Core/LiveStreamLink.h"
91-
"${CMAKE_SOURCE_DIR}/src/Core/Mihoyosdk.cpp"
92-
"${CMAKE_SOURCE_DIR}/src/Core/Mihoyosdk.h"
9389
"${CMAKE_SOURCE_DIR}/src/Core/QRScanner.cpp"
9490
"${CMAKE_SOURCE_DIR}/src/Core/QRScanner.h"
9591
"${CMAKE_SOURCE_DIR}/src/Core/ScreenScan.cpp"
9692
"${CMAKE_SOURCE_DIR}/src/Core/ScreenScan.h"
9793
"${CMAKE_SOURCE_DIR}/src/Core/ConfigDate.cpp"
9894
"${CMAKE_SOURCE_DIR}/src/Core/ConfigDate.h"
99-
"${CMAKE_SOURCE_DIR}/src/Core/BH3Api.hpp"
95+
"${CMAKE_SOURCE_DIR}/src/Core/BSGameSDK.hpp"
10096
"${CMAKE_SOURCE_DIR}/src/Core/CookieParser.hpp"
10197
"${CMAKE_SOURCE_DIR}/src/Core/CreateUUID.hpp"
10298
"${CMAKE_SOURCE_DIR}/src/Core/ScannerBase.hpp"
99+
"${CMAKE_SOURCE_DIR}/src/Core/compile_string.hpp"
100+
"${CMAKE_SOURCE_DIR}/src/Core/ApiDefs.hpp"
103101
)
104102

105103
if(NOT DEV)

src/Core/ApiDefs.hpp

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#pragma once
2+
3+
#include <string_view>
4+
5+
#include "compile_string.hpp"
6+
7+
enum class ServerType : uint8_t
8+
{
9+
UNKNOW [[deprecated]] = 0,
10+
Official = 1,
11+
BH3_BiliBili = 2
12+
};
13+
14+
enum class GameType
15+
{
16+
UNKNOW = 0,
17+
Honkai3 = 1,
18+
TearsOfThemis = 2,
19+
Genshin = 4,
20+
PlatformApp = 5,
21+
Honkai2 = 7,
22+
HonkaiStarRail = 8,
23+
CloudGame = 9,
24+
_3NNN = 10,
25+
PJSH = 11,
26+
ZenlessZoneZero = 12,
27+
HYG = 13,
28+
Honkai3_BiliBili = 10000
29+
};
30+
31+
enum class ScanRet
32+
{
33+
UNKNOW = 0,
34+
SUCCESS = 1,
35+
FAILURE_1 = 3,
36+
FAILURE_2 = 4,
37+
LIVESTOP = 5,
38+
STREAMERROR = 6
39+
};
40+
41+
enum class LoginQRCodeState
42+
{
43+
Init = 0,
44+
Scanned = 1,
45+
Confirmed = 2,
46+
Expired = 3
47+
};
48+
49+
struct GeetestData
50+
{
51+
std::string action_type{};
52+
std::string session_id{};
53+
int mmt_type{};
54+
std::string gt{};
55+
std::string challenge{};
56+
ServerType GeeTestType{};
57+
};
58+
59+
constinit const std::string_view mihoyobbs_version{ "2.75.2" };
60+
constinit const std::string_view mihoyobbs_salt{ "oqrJbPCoFhWhFBNDvVRuldbrbiVxyWsP" };
61+
constinit const std::string_view mihoyobbs_salt_web{ "zZDfHqEcwTqvvKDmqRcHyqqurxGgLfBV" };
62+
63+
constinit const std::string_view mihoyobbs_salt_x4{ "xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs" };
64+
constinit const std::string_view mihoyobbs_salt_x6{ "t0qEgfub6cvueAPgR5m9aQWWVciEer7v" };
65+
66+
namespace api::mhy
67+
{
68+
69+
constexpr compile_string api_sdk{ "https://api-sdk.mihoyo.com" };
70+
71+
namespace bh3
72+
{
73+
constexpr auto base = api_sdk + compile_string{ "/bh3_cn" };
74+
constexpr auto v2_login = base + compile_string{ "/combo/granter/login/v2/login" };
75+
constexpr auto qrcode_scan = base + compile_string{ "/combo/panda/qrcode/scan" };
76+
constexpr auto qrcode_confirm = base + compile_string{ "/combo/panda/qrcode/confirm" };
77+
78+
constexpr compile_string version{ "https://bh3-launcher-static.mihoyo.com/bh3_cn/mdk/launcher/api/resource?launcher_id=4" };
79+
}
80+
81+
namespace hk4e
82+
{
83+
constexpr auto base = api_sdk + compile_string{ "/hk4e_cn" };
84+
constexpr auto qrcode_scan = base + compile_string{ "/combo/panda/qrcode/scan" };
85+
constexpr auto qrcode_confirm = base + compile_string{ "/combo/panda/qrcode/confirm" };
86+
87+
constexpr compile_string sdk_base{ "https://hk4e-sdk.mihoyo.com/hk4e_cn" };
88+
constexpr auto qrcode_fetch = sdk_base + compile_string{ "/combo/panda/qrcode/fetch" };
89+
constexpr auto qrcode_query = sdk_base + compile_string{ "/combo/panda/qrcode/query" };
90+
}
91+
92+
namespace hkrpg
93+
{
94+
constexpr auto base = api_sdk + compile_string{ "/hkrpg_cn" };
95+
constexpr auto qrcode_scan = base + compile_string{ "/combo/panda/qrcode/scan" };
96+
constexpr auto qrcode_confirm = base + compile_string{ "/combo/panda/qrcode/confirm" };
97+
}
98+
99+
namespace nap
100+
{
101+
constexpr auto base = api_sdk + compile_string{ "/nap_cn" };
102+
constexpr auto qrcode_scan = base + compile_string{ "/combo/panda/qrcode/scan" };
103+
constexpr auto qrcode_confirm = base + compile_string{ "/combo/panda/qrcode/confirm" };
104+
}
105+
106+
namespace takumi
107+
{
108+
constexpr compile_string base{ "https://api-takumi.mihoyo.com" };
109+
constexpr auto multi_token = base + compile_string{ "/auth/api/getMultiTokenByLoginTicket" };
110+
constexpr auto game_token = base + compile_string{ "/auth/api/getGameToken" };
111+
constexpr auto game_token_stoken = base + compile_string{ "/account/ma-cn-session/app/getTokenByGameToken" };
112+
}
113+
114+
namespace passport
115+
{
116+
constexpr compile_string base{ "https://passport-api.mihoyo.com" };
117+
constexpr auto create_captcha = base + compile_string{ "/account/ma-cn-verifier/verifier/createLoginCaptcha" };
118+
constexpr auto login_by_mobile_captcha = base + compile_string{ "/account/ma-cn-passport/app/loginByMobileCaptcha" };
119+
}
120+
121+
namespace mys
122+
{
123+
constexpr compile_string base{ "https://bbs-api.miyoushe.com" };
124+
constexpr auto userinfo = base + compile_string{ "/user/api/getUserFullInfo" };
125+
}
126+
127+
}
128+
129+
namespace api::game
130+
{
131+
132+
namespace bili
133+
{
134+
constexpr compile_string base{ "https://line1-sdk-center-login-sh.biligame.net" };
135+
constexpr auto userinfo = base + compile_string{ "/api/client/user.info" };
136+
constexpr auto start_captcha = base + compile_string{ "/api/client/start_captcha" };
137+
constexpr auto login = base + compile_string{ "/api/client/login" };
138+
constexpr auto rsa = base + compile_string{ "/api/client/rsa" };
139+
}
140+
141+
}
142+
143+
namespace api::live
144+
{
145+
146+
namespace bili
147+
{
148+
constexpr compile_string base{ "https://api.live.bilibili.com" };
149+
constexpr auto room_init = base + compile_string{ "/room/v1/Room/room_init" };
150+
// constexpr auto v1_play_url = base + compile_string{ "/xlive/web-room/v1/playUrl/playUrl" }; // 弃用
151+
constexpr auto v2_play_info = base + compile_string{ "/xlive/web-room/v2/index/getRoomPlayInfo" };
152+
}
153+
154+
namespace douyin
155+
{
156+
constexpr compile_string base{ "https://live.douyin.com" };
157+
constexpr auto room = base + compile_string{ "/webcast/room/web/enter/?" };
158+
}
159+
160+
}

0 commit comments

Comments
 (0)