Skip to content

Commit 266cd7d

Browse files
author
李杰
committed
唤醒问题
1 parent e0dd90d commit 266cd7d

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

src-tauri/src/modules/wakeup_gateway.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,43 @@ fn official_antigravity_info_plist_path() -> Option<std::path::PathBuf> {
640640
}
641641
}
642642

643+
fn read_json_string_field(path: &std::path::Path, key: &str) -> Option<String> {
644+
let content = std::fs::read_to_string(path).ok()?;
645+
let value = serde_json::from_str::<serde_json::Value>(&content).ok()?;
646+
value
647+
.get(key)
648+
.and_then(serde_json::Value::as_str)
649+
.map(str::trim)
650+
.filter(|v| !v.is_empty())
651+
.map(str::to_string)
652+
}
653+
654+
fn official_antigravity_product_json_path() -> Option<std::path::PathBuf> {
655+
let root = official_antigravity_root_for_version()?;
656+
#[cfg(target_os = "macos")]
657+
let candidates = [
658+
root.join("Contents")
659+
.join("Resources")
660+
.join("app")
661+
.join("product.json"),
662+
root.join("resources").join("app").join("product.json"),
663+
root.join("app").join("product.json"),
664+
];
665+
#[cfg(not(target_os = "macos"))]
666+
let candidates = [
667+
root.join("resources").join("app").join("product.json"),
668+
root.join("app").join("product.json"),
669+
];
670+
671+
for path in candidates {
672+
if path.exists() {
673+
return Some(path);
674+
}
675+
}
676+
677+
None
678+
}
679+
643680
fn parse_version_from_plutil_output(text: &str) -> Option<String> {
644681
for line in text.lines() {
645682
let line = line.trim();
@@ -684,6 +721,14 @@ pub(crate) fn official_antigravity_app_version() -> String {
684721
}
685722
}
686723

724+
if let Some(product_json_path) = official_antigravity_product_json_path() {
725+
if let Some(version) = read_json_string_field(&product_json_path, "ideVersion")
726+
.or_else(|| read_json_string_field(&product_json_path, "version"))
727+
{
728+
return version;
729+
}
730+
}
731+
687732
let plist_path = official_antigravity_info_plist_path();
688733
if let Some(plist_path) = plist_path {
689734
let output = std::process::Command::new("plutil")

0 commit comments

Comments
 (0)