1
0
Эх сурвалжийг харах

Feat: use cli-config instead

Jonathan Kelley 6 сар өмнө
parent
commit
04d7553897

+ 4 - 0
packages/cli-config/src/lib.rs

@@ -141,3 +141,7 @@ pub fn format_base_path_meta_element(base_path: &str) -> String {
 pub fn out_dir() -> Option<PathBuf> {
     std::env::var(OUT_DIR).ok().map(PathBuf::from)
 }
+
+pub fn android_asset_hotreload_dir() -> PathBuf {
+    PathBuf::from("/data/local/tmp/dx/")
+}

+ 2 - 2
packages/cli/src/serve/handle.rs

@@ -199,8 +199,8 @@ impl AppHandle {
         // If the emulator is android, we need to copy the asset to the device with `adb push asset /data/local/tmp/dx/assets/filename.ext`
         if self.app.build.build.platform() == Platform::Android {
             if let Some(bundled_name) = bundled_name.as_ref() {
-                let target = format!("/data/local/tmp/dx/{}", bundled_name.display());
-                tracing::debug!("Pushing asset to device: {target}");
+                let target = dioxus_cli_config::android_asset_hotreload_dir().join(bundled_name);
+                tracing::debug!("Pushing asset to device: {}", target.display());
                 let res = tokio::process::Command::new("adb")
                     .arg("push")
                     .arg(changed_file)

+ 1 - 1
packages/desktop/src/protocol.rs

@@ -282,7 +282,7 @@ pub(crate) fn to_java_load_asset(filepath: &str) -> Option<Vec<u8>> {
     // in debug mode, the asset might be under `/data/local/tmp/dx/` - attempt to read it from there if it exists
     #[cfg(debug_assertions)]
     {
-        let path = std::path::PathBuf::from("/data/local/tmp/dx/").join(normalized);
+        let path = dioxus_cli_config::android_asset_hotreload_dir().join(normalized);
         if path.exists() {
             return std::fs::read(path).ok();
         }