From 140819b55ed7d2326c29e88eef5fdf1a94fdc823 Mon Sep 17 00:00:00 2001 From: xintaofei Date: Thu, 26 Mar 2026 00:42:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dgithub=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/web/mod.rs | 15 +++++++-------- src-tauri/tauri.conf.json | 5 ++++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src-tauri/src/web/mod.rs b/src-tauri/src/web/mod.rs index e2c44ae..6a93ec1 100644 --- a/src-tauri/src/web/mod.rs +++ b/src-tauri/src/web/mod.rs @@ -45,20 +45,19 @@ pub(crate) fn generate_random_token() -> String { } pub(crate) fn find_static_dir(app: &tauri::AppHandle) -> PathBuf { - // 1. Production: Tauri bundles frontendDist into the resource directory. + // 1. Production: bundle.resources copies out/ → web/ inside the resource directory. let resource = app.path().resource_dir().ok(); if let Some(ref dir) = resource { - // In production builds, the HTML files are at the resource root. + let web = dir.join("web"); + if web.join("index.html").exists() { + eprintln!("[WEB] Serving static files from resource/web: {}", web.display()); + return web; + } + // Fallback: files at resource root. if dir.join("index.html").exists() { eprintln!("[WEB] Serving static files from resource dir: {}", dir.display()); return dir.clone(); } - // Or possibly in an "out" subdirectory. - let out = dir.join("out"); - if out.join("index.html").exists() { - eprintln!("[WEB] Serving static files from resource/out: {}", out.display()); - return out; - } } // 2. Dev mode: "out/" is at the project root, which is one level above src-tauri/. diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 956ae48..20cf9ec 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -25,7 +25,10 @@ "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico" - ] + ], + "resources": { + "../out": "web/" + } }, "plugins": { "updater": {