Auto-detect the mobile-web build output directory.
()
| 101 | |
| 102 | /// Auto-detect the mobile-web build output directory. |
| 103 | fn detect_mobile_web_dir() -> Option<String> { |
| 104 | if let Ok(dir) = std::env::var("BITFUN_MOBILE_WEB_DIR") { |
| 105 | let p = std::path::Path::new(&dir); |
| 106 | if p.join("index.html").exists() { |
| 107 | log::info!("Using BITFUN_MOBILE_WEB_DIR: {dir}"); |
| 108 | return Some(dir); |
| 109 | } |
| 110 | log::warn!("BITFUN_MOBILE_WEB_DIR set but index.html not found: {dir}"); |
| 111 | } |
| 112 | |
| 113 | if let Some(resource_path) = MOBILE_WEB_RESOURCE_PATH.get() { |
| 114 | if is_valid_mobile_web_dir(resource_path) { |
| 115 | let dir = resource_path.to_string_lossy().into_owned(); |
| 116 | log::info!("Using Tauri bundled mobile-web: {dir}"); |
| 117 | return Some(dir); |
| 118 | } |
| 119 | log::debug!( |
| 120 | "Tauri resource path registered but not a valid mobile-web dir: {}", |
| 121 | resource_path.display() |
| 122 | ); |
| 123 | } |
| 124 | |
| 125 | if let Some(dir) = detect_from_exe() { |
| 126 | return Some(dir); |
| 127 | } |
| 128 | |
| 129 | if let Some(dir) = detect_from_cwd() { |
| 130 | return Some(dir); |
| 131 | } |
| 132 | |
| 133 | log::warn!("mobile-web dist directory not found; LAN/Ngrok modes will not serve static files"); |
| 134 | None |
| 135 | } |
| 136 | |
| 137 | fn detect_from_exe() -> Option<String> { |
| 138 | let exe = std::env::current_exe().ok()?; |
no test coverage detected