program opening command

This commit is contained in:
SpikeHD
2022-05-08 21:54:17 -07:00
parent 6d7a077b48
commit aa8979d165
4 changed files with 29 additions and 4 deletions

13
src-tauri/Cargo.lock generated
View File

@@ -258,7 +258,9 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
dependencies = [
"lazy_static",
"memchr",
"regex-automata",
]
[[package]]
@@ -640,6 +642,7 @@ name = "cultivation"
version = "0.1.0"
dependencies = [
"hudsucker",
"opener",
"rustls-pemfile",
"serde",
"serde_json",
@@ -2165,6 +2168,16 @@ dependencies = [
"winapi",
]
[[package]]
name = "opener"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ea3ebcd72a54701f56345f16785a6d3ac2df7e986d273eb4395c0b01db17952"
dependencies = [
"bstr",
"winapi",
]
[[package]]
name = "openssl"
version = "0.10.40"

View File

@@ -18,7 +18,7 @@ tauri-build = { version = "1.0.0-rc.8", features = [] }
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.0-rc.9", features = ["api-all"] }
opener = "0.5.0"
hudsucker = "0.17.2"
tracing = "0.1.34"
tokio-rustls = "0.23.4"

View File

@@ -8,13 +8,20 @@ mod proxy;
use tauri::{
command
};
use opener;
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![run_program])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
#[tauri::command]
fn run_program(path: String) {
opener::open(path.clone());
}
#[tauri::command]
fn connect() {

View File

@@ -1,17 +1,22 @@
import React from 'react'
import logo from './logo.svg'
import { invoke } from '@tauri-apps/api/tauri'
import './App.css'
import './custom.css'
// Config
import { getConfigOption, getConfig, saveConfig, setConfigOption } from '../utils/configuration'
import { getConfig } from '../utils/configuration'
// Major Components
import Topbar from './components/TopBar'
import BigButton from './components/common/BigButton'
function playGame() {
async function playGame() {
const config = await getConfig()
if (!config.game_path) return
// Launch the program
await invoke('run_program', { path: config.game_path })
}
function App() {