From eaec740be2d03a7f9348f910761ee7d451da2d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=9A=E5=AD=90?= <40852301+uiYzzi@users.noreply.github.com> Date: Fri, 7 Mar 2025 02:17:03 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=BA=94=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/handlers/deb.rs | 17 ++++++++++++++--- src-tauri/src/lib.rs | 3 ++- src/features/app-detail/AppDetail.tsx | 8 +++++++- src/lib/api/deb.ts | 8 ++++++-- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/handlers/deb.rs b/src-tauri/src/handlers/deb.rs index 9ecc5ef..650206a 100644 --- a/src-tauri/src/handlers/deb.rs +++ b/src-tauri/src/handlers/deb.rs @@ -11,12 +11,23 @@ pub async fn check_is_installed(pkgname: String) -> Result { } #[tauri::command] -pub async fn launch_app(pkgname: String) -> Result<(), String> { +pub async fn check_launch_app(pkgname: String) -> Result { + let output = Command::new("/opt/durapps/spark-store/bin/store-helper/ss-launcher") + .arg("check") + .arg(&pkgname) + .output() + .map_err(|e| format!("启动应用失败: {}", e))?; + + Ok(output.status.success()) +} + +#[tauri::command] +pub async fn launch_launch_app(pkgname: String) -> Result<(), String> { Command::new("/opt/durapps/spark-store/bin/store-helper/ss-launcher") + .arg("launch") .arg(&pkgname) .spawn() .map_err(|e| format!("启动应用失败: {}", e))?; Ok(()) -} - +} \ No newline at end of file diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 2dd03e6..e5f800a 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -31,7 +31,8 @@ pub fn run() { handlers::download::resume_download, handlers::download::cancel_download, handlers::deb::check_is_installed, - handlers::deb::launch_app, + handlers::deb::check_launch_app, + handlers::deb::launch_launch_app, utils::get_user_agent, ]) .on_window_event(|window, event| match event { diff --git a/src/features/app-detail/AppDetail.tsx b/src/features/app-detail/AppDetail.tsx index 05f9879..ef282b9 100644 --- a/src/features/app-detail/AppDetail.tsx +++ b/src/features/app-detail/AppDetail.tsx @@ -16,7 +16,7 @@ import { useCollectionStore } from '@/features/collection/store'; import { useDownloadsStore } from '@/features/downloads/store'; import { Progress } from '@/components/ui/progress'; import { X } from 'lucide-solid'; -import { checkIsInstalled, launchApp } from '@/lib/api/deb'; +import { checkIsInstalled, checkLaunchApp, launchApp } from '@/lib/api/deb'; const AppDetail: Component = () => { const params = useParams(); @@ -124,10 +124,16 @@ const AppDetail: Component = () => { ); if (downloadTask?.status === 'installed' || isInstalled()) { + const [appCanLaunch, setAppCanLaunch] = createSignal(false); + checkLaunchApp(params.pkgname).then(canLaunch => { + setAppCanLaunch(canLaunch); + }); + return (