🐛 修复启动应用
This commit is contained in:
@@ -11,12 +11,23 @@ pub async fn check_is_installed(pkgname: String) -> Result<bool, String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub async fn launch_app(pkgname: String) -> Result<(), String> {
|
pub async fn check_launch_app(pkgname: String) -> Result<bool, String> {
|
||||||
|
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")
|
Command::new("/opt/durapps/spark-store/bin/store-helper/ss-launcher")
|
||||||
|
.arg("launch")
|
||||||
.arg(&pkgname)
|
.arg(&pkgname)
|
||||||
.spawn()
|
.spawn()
|
||||||
.map_err(|e| format!("启动应用失败: {}", e))?;
|
.map_err(|e| format!("启动应用失败: {}", e))?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,8 @@ pub fn run() {
|
|||||||
handlers::download::resume_download,
|
handlers::download::resume_download,
|
||||||
handlers::download::cancel_download,
|
handlers::download::cancel_download,
|
||||||
handlers::deb::check_is_installed,
|
handlers::deb::check_is_installed,
|
||||||
handlers::deb::launch_app,
|
handlers::deb::check_launch_app,
|
||||||
|
handlers::deb::launch_launch_app,
|
||||||
utils::get_user_agent,
|
utils::get_user_agent,
|
||||||
])
|
])
|
||||||
.on_window_event(|window, event| match event {
|
.on_window_event(|window, event| match event {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import { useCollectionStore } from '@/features/collection/store';
|
|||||||
import { useDownloadsStore } from '@/features/downloads/store';
|
import { useDownloadsStore } from '@/features/downloads/store';
|
||||||
import { Progress } from '@/components/ui/progress';
|
import { Progress } from '@/components/ui/progress';
|
||||||
import { X } from 'lucide-solid';
|
import { X } from 'lucide-solid';
|
||||||
import { checkIsInstalled, launchApp } from '@/lib/api/deb';
|
import { checkIsInstalled, checkLaunchApp, launchApp } from '@/lib/api/deb';
|
||||||
|
|
||||||
const AppDetail: Component = () => {
|
const AppDetail: Component = () => {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
@@ -124,10 +124,16 @@ const AppDetail: Component = () => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (downloadTask?.status === 'installed' || isInstalled()) {
|
if (downloadTask?.status === 'installed' || isInstalled()) {
|
||||||
|
const [appCanLaunch, setAppCanLaunch] = createSignal(false);
|
||||||
|
checkLaunchApp(params.pkgname).then(canLaunch => {
|
||||||
|
setAppCanLaunch(canLaunch);
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
size="lg"
|
size="lg"
|
||||||
class='w-full'
|
class='w-full'
|
||||||
|
disabled={!appCanLaunch()}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
launchApp(params.pkgname)
|
launchApp(params.pkgname)
|
||||||
showToast({ description: '正在启动应用...' });
|
showToast({ description: '正在启动应用...' });
|
||||||
|
|||||||
@@ -4,6 +4,10 @@ export async function checkIsInstalled(pkgname: string): Promise<boolean> {
|
|||||||
return await invoke('check_is_installed', { pkgname });
|
return await invoke('check_is_installed', { pkgname });
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function launchApp(pkgname: string) {
|
export async function checkLaunchApp(pkgname: string): Promise<boolean> {
|
||||||
await invoke('launch_app', { pkgname });
|
return await invoke('check_launch_app', { pkgname });
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function launchLaunchApp(pkgname: string) {
|
||||||
|
await invoke('launch_launch_app', { pkgname });
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user