mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 16:14:48 +01:00
launch grasscutter properly
This commit is contained in:
@@ -3,7 +3,6 @@ all(not(debug_assertions), target_os = "windows"),
|
|||||||
windows_subsystem = "windows"
|
windows_subsystem = "windows"
|
||||||
)]
|
)]
|
||||||
|
|
||||||
use std::process::Command;
|
|
||||||
use open;
|
use open;
|
||||||
|
|
||||||
mod downloader;
|
mod downloader;
|
||||||
@@ -53,10 +52,10 @@ fn run_program(path: String) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
fn run_jar(path: String) {
|
fn run_jar(path: String, execute_in: String) {
|
||||||
// Open the program from the specified path.
|
// Open the program from the specified path.
|
||||||
match open::with("/k java -jar ".to_string() + &path, "C:\\Windows\\System32\\cmd.exe") {
|
match open::with(format!("/k cd /D \"{}\" & java -jar {}", &execute_in, &path).to_string(), "C:\\Windows\\System32\\cmd.exe") {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) => println!("Failed to open jar ({}): {}", &path, e),
|
Err(e) => println!("Failed to open jar ({} from {}): {}", &path, &execute_in, e),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -67,8 +67,21 @@ export default class ServerLaunchSection extends React.Component<IProps, IState>
|
|||||||
|
|
||||||
if (!config.grasscutter_path) return
|
if (!config.grasscutter_path) return
|
||||||
|
|
||||||
|
let jarFolder = config.grasscutter_path
|
||||||
|
|
||||||
|
if (jarFolder.includes('/')) {
|
||||||
|
jarFolder = jarFolder.substring(0, config.grasscutter_path.lastIndexOf('/'))
|
||||||
|
} else {
|
||||||
|
jarFolder = jarFolder.substring(0, config.grasscutter_path.lastIndexOf('\\'))
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(jarFolder)
|
||||||
|
|
||||||
// Launch the jar
|
// Launch the jar
|
||||||
await invoke('run_jar', { path: config.grasscutter_path })
|
await invoke('run_jar', {
|
||||||
|
path: config.grasscutter_path,
|
||||||
|
executeIn: jarFolder
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|||||||
Reference in New Issue
Block a user