aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src-tauri/src/core/modpack.rs
diff options
context:
space:
mode:
author苏向夜 <46275354+fu050409@users.noreply.github.com>2026-03-26 09:02:10 +0800
committerGitHub <noreply@github.com>2026-03-26 09:02:10 +0800
commit94b0d8e208363c802c12b56d8bdbef574dd1fb91 (patch)
treee86c8d46e73262c67c1755aaf4202cbcd1f8f844 /src-tauri/src/core/modpack.rs
parent7d0e92e6d3b172adfe552ffae9b97f8dad6f63ae (diff)
parent3a31d3004b2814cd8a26d49a0f8a96636411dcd2 (diff)
downloadDropOut-94b0d8e208363c802c12b56d8bdbef574dd1fb91.tar.gz
DropOut-94b0d8e208363c802c12b56d8bdbef574dd1fb91.zip
Add game lifecycle management and instance import/export tools (#117)
## Summary by Sourcery Add centralized game process and instance lifecycle management, shared cache-aware path resolution, and instance import/export/repair capabilities across backend and UI. New Features: - Track a single running game process in the backend, expose stop-game control, and emit structured game-exited events with instance and version context. - Introduce instance path resolution that supports shared caches for versions, libraries, and assets, and use it across game start, install, and version management APIs. - Add import, export, and repair operations for instances, including zip-based archive support and automatic recovery of on-disk instances. - Expose new instance lifecycle and repair APIs to the frontend and wire them through the client and instance store. - Add per-instance start/stop controls in the instances view and instance selection in the bottom bar for launching games. Enhancements: - Guard instance operations with per-instance locks and track active operations such as launch, install, delete, and import/export. - Improve handling of Microsoft login errors and polling status, with clearer user feedback and safer interval management. - Simplify config mutation during shared cache migration and centralize instance directory resolution in the backend. - Initialize a game lifecycle listener at app startup to keep UI state in sync with backend game exit events. Build: - Configure the Vite dev server to use a fixed localhost host and port for the UI dev environment.
Diffstat (limited to 'src-tauri/src/core/modpack.rs')
-rw-r--r--src-tauri/src/core/modpack.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src-tauri/src/core/modpack.rs b/src-tauri/src/core/modpack.rs
index 5ac9493..a580000 100644
--- a/src-tauri/src/core/modpack.rs
+++ b/src-tauri/src/core/modpack.rs
@@ -294,7 +294,7 @@ fn parse_multimc(archive: &mut Archive) -> Result<ParsedModpack, String> {
// ── CurseForge API resolution ─────────────────────────────────────────────
-const CURSEFORGE_API_KEY: &str = env!("CURSEFORGE_API_KEY");
+const CURSEFORGE_API_KEY: Option<&str> = option_env!("CURSEFORGE_API_KEY");
async fn resolve_curseforge_files(files: &[ModpackFile]) -> Result<Vec<ModpackFile>, String> {
let file_ids: Vec<u64> = files
@@ -368,9 +368,12 @@ async fn cf_post(
endpoint: &str,
body: &serde_json::Value,
) -> Result<serde_json::Value, String> {
+ let api_key = CURSEFORGE_API_KEY
+ .ok_or("CurseForge modpack support requires CURSEFORGE_API_KEY set at build time")?;
+
let resp = client
.post(format!("https://api.curseforge.com{endpoint}"))
- .header("x-api-key", CURSEFORGE_API_KEY)
+ .header("x-api-key", api_key)
.json(body)
.send()
.await