Skip to content

Commit

Permalink
fix(adb): adb path reading
Browse files Browse the repository at this point in the history
  • Loading branch information
AkiChase committed May 22, 2024
1 parent b8dbabb commit 30f6d37
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions src-tauri/src/adb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pub struct Adb;
impl Adb {
pub fn cmd_base() -> Command {
let adb_path = share::ADB_PATH.lock().unwrap().clone();
println!("{}", &adb_path);
#[cfg(target_os = "windows")]
{
let mut cmd = Command::new(adb_path);
Expand Down
14 changes: 11 additions & 3 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ fn set_adb_path(adb_path: String, app: tauri::AppHandle) -> Result<(), String> {
let path = std::path::PathBuf::from("store.bin");
let store_res: Result<(), tauri_plugin_store::Error> =
tauri_plugin_store::with_store(app, stores, path, |store| {
store.insert("adbPath".to_string(), serde_json::json!(adb_path))?;
store.insert(
"adbPath".to_string(),
serde_json::Value::String(adb_path.clone()),
)?;
*share::ADB_PATH.lock().unwrap() = adb_path;
Ok(())
});
Expand All @@ -190,9 +193,14 @@ async fn main() {
tauri_plugin_store::with_store(app.app_handle().clone(), stores, path, |store| {
// load adb path
match store.get("adbPath") {
Some(value) => *share::ADB_PATH.lock().unwrap() = value.to_string(),
Some(value) => {
*share::ADB_PATH.lock().unwrap() = value.as_str().unwrap().to_string()
}
None => store
.insert("adbPath".to_string(), serde_json::json!("adb"))
.insert(
"adbPath".to_string(),
serde_json::Value::String("adb".to_string()),
)
.unwrap(),
};

Expand Down
6 changes: 4 additions & 2 deletions src/components/Mask.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,14 @@ onActivated(async () => {
});
onMounted(async () => {
store.checkAdb = checkAdb;
await checkAdb();
await loadLocalStore();
store.checkUpdate = checkUpdate;
store.showInputBox = showInputBox;
if (store.checkUpdateAtStart) checkUpdate();
store.checkAdb = checkAdb;
setTimeout(() => {
checkAdb();
}, 500);
});
let checkAdbMessage: MessageReactive | null = null;
Expand Down

0 comments on commit 30f6d37

Please sign in to comment.