mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 08:04:52 +01:00
remove thread stuff, set cwd properly when openening migoto
This commit is contained in:
@@ -2,11 +2,8 @@ use duct::cmd;
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn run_program(path: String) {
|
pub fn run_program(path: String) {
|
||||||
// Open in new thread to prevent blocking.
|
// Without unwrap_or, this can crash when UAC prompt is denied
|
||||||
std::thread::spawn(move || {
|
open::that(&path).unwrap_or(());
|
||||||
// Without unwrap_or, this can crash when UAC prompt is denied
|
|
||||||
open::that(&path).unwrap_or(());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -18,11 +15,11 @@ pub fn run_program_relative(path: String) {
|
|||||||
let mut path_buf = std::path::PathBuf::from(&path);
|
let mut path_buf = std::path::PathBuf::from(&path);
|
||||||
path_buf.pop();
|
path_buf.pop();
|
||||||
|
|
||||||
// Open in new thread to prevent blocking.
|
// Set new working directory
|
||||||
std::thread::spawn(move || {
|
std::env::set_current_dir(&path_buf).unwrap();
|
||||||
// Without unwrap_or, this can crash when UAC prompt is denied
|
|
||||||
open::that(&path).unwrap_or(());
|
// Without unwrap_or, this can crash when UAC prompt is denied
|
||||||
});
|
open::that(&path).unwrap_or(());
|
||||||
|
|
||||||
// Restore the original working directory
|
// Restore the original working directory
|
||||||
std::env::set_current_dir(&cwd).unwrap();
|
std::env::set_current_dir(&cwd).unwrap();
|
||||||
|
|||||||
@@ -202,11 +202,15 @@ export default class ServerLaunchSection extends React.Component<{}, IState> {
|
|||||||
async launchMigoto() {
|
async launchMigoto() {
|
||||||
const config = await getConfig()
|
const config = await getConfig()
|
||||||
|
|
||||||
// Get game exe from game path, so we can watch it
|
if (!config.migoto_path) return alert('Migoto not installed or set!')
|
||||||
const pathArr = config.game_install_path.replace(/\\/g, '/').split('/')
|
|
||||||
const gameExec = pathArr[pathArr.length - 1]
|
|
||||||
|
|
||||||
await this.playGame(config.migoto_path, gameExec)
|
// Get game exe from game path, so we can watch it
|
||||||
|
const pathArr = config.migoto_path.replace(/\\/g, '/').split('/')
|
||||||
|
const migotoExec = pathArr[pathArr.length - 1]
|
||||||
|
|
||||||
|
await invoke('run_program_relative', { path: config.migoto_path })
|
||||||
|
|
||||||
|
await this.playGame()
|
||||||
}
|
}
|
||||||
|
|
||||||
setIp(text: string) {
|
setIp(text: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user