push
This commit is contained in:
22
src/main.cpp
22
src/main.cpp
@@ -31,6 +31,7 @@ std::string get_mime_type(const std::string& path) {
|
||||
if (path.ends_with(".jpg") || path.ends_with(".jpeg")) return "image/jpeg";
|
||||
if (path.ends_with(".woff")) return "font/woff";
|
||||
if (path.ends_with(".woff2")) return "font/woff2";
|
||||
if (path.ends_with(".pdf")) return "application/pdf";
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
@@ -136,7 +137,26 @@ int main() {
|
||||
|
||||
shadowrun::initApi(app);
|
||||
|
||||
// Catch-all route for static files and SPA fallback
|
||||
// asssets is not svelte generated
|
||||
CROW_ROUTE(app, "/assets/<path>")
|
||||
([&](const std::string& p) {
|
||||
const filesystem::path assets_dir = "assets/"; // <-- set your build folder
|
||||
filesystem::path file_path = assets_dir / p;
|
||||
|
||||
// If file exists, serve it
|
||||
if (filesystem::exists(file_path)) {
|
||||
auto data = read_file(file_path);
|
||||
auto mime = get_mime_type(file_path.string());
|
||||
return crow::response(200, mime.c_str(), data);
|
||||
}
|
||||
|
||||
// SPA fallback: serve root index.html for unknown routes
|
||||
filesystem::path fallback = build_dir / "index.html";
|
||||
auto data = read_file(fallback);
|
||||
return crow::response(404, "text/html", data);
|
||||
});
|
||||
|
||||
// Catch-all route for static files and SPA fallback
|
||||
CROW_ROUTE(app, "/<path>")
|
||||
([&](const std::string& p) {
|
||||
filesystem::path file_path = build_dir / p;
|
||||
|
||||
@@ -45,6 +45,7 @@ static const vector<string> cSkillParameters = {
|
||||
static const vector<string> cContactsParameters = {
|
||||
"Name",
|
||||
"Loyalty",
|
||||
"Conection"
|
||||
};
|
||||
|
||||
static const vector<string> cRangedWeaponsParameters = {
|
||||
@@ -53,7 +54,8 @@ static const vector<string> cRangedWeaponsParameters = {
|
||||
"AP",
|
||||
"Mode",
|
||||
"RC",
|
||||
"Ammo"
|
||||
"Ammo",
|
||||
"Availability"
|
||||
};
|
||||
|
||||
static const vector<string> cImplantParameters = {
|
||||
|
||||
@@ -16,6 +16,11 @@ namespace shadowrun {
|
||||
Info = 1,
|
||||
Attributes = 2,
|
||||
Skills = 3,
|
||||
Connections = 4,
|
||||
RangedWeapons = 5,
|
||||
MeleeWeapons = 6,
|
||||
Cyberware = 7,
|
||||
Bioware = 8,
|
||||
};
|
||||
|
||||
struct ShadowrunCharacter {
|
||||
|
||||
Reference in New Issue
Block a user