添加安装检测和启动应用

This commit is contained in:
柚子
2025-03-07 02:05:30 +08:00
parent f9a6fcbf84
commit 135873a3e7
6 changed files with 111 additions and 50 deletions

View File

@@ -0,0 +1,22 @@
use std::process::Command;
#[tauri::command]
pub async fn check_is_installed(pkgname: String) -> Result<bool, String> {
let output = Command::new("/opt/durapps/spark-store/bin/store-helper/check-is-installed")
.arg(&pkgname)
.output()
.map_err(|e| format!("执行命令失败: {}", e))?;
Ok(output.status.success())
}
#[tauri::command]
pub async fn launch_app(pkgname: String) -> Result<(), String> {
Command::new("/opt/durapps/spark-store/bin/store-helper/ss-launcher")
.arg(&pkgname)
.spawn()
.map_err(|e| format!("启动应用失败: {}", e))?;
Ok(())
}

View File

@@ -4,3 +4,4 @@ pub mod app;
pub mod home;
pub mod file;
pub mod download;
pub mod deb;

View File

@@ -30,6 +30,8 @@ pub fn run() {
handlers::download::pause_download,
handlers::download::resume_download,
handlers::download::cancel_download,
handlers::deb::check_is_installed,
handlers::deb::launch_app,
utils::get_user_agent,
])
.on_window_event(|window, event| match event {