mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-14 08:04:52 +01:00
open with cwd, restore akebi option stuff
This commit is contained in:
@@ -34,6 +34,7 @@ fn main() {
|
|||||||
get_theme_list,
|
get_theme_list,
|
||||||
system_helpers::run_command,
|
system_helpers::run_command,
|
||||||
system_helpers::run_program,
|
system_helpers::run_program,
|
||||||
|
system_helpers::run_program_relative,
|
||||||
system_helpers::run_jar,
|
system_helpers::run_jar,
|
||||||
system_helpers::open_in_browser,
|
system_helpers::open_in_browser,
|
||||||
system_helpers::install_location,
|
system_helpers::install_location,
|
||||||
|
|||||||
@@ -9,6 +9,25 @@ pub fn run_program(path: String) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub fn run_program_relative(path: String) {
|
||||||
|
// Save the current working directory
|
||||||
|
let cwd = std::env::current_dir().unwrap();
|
||||||
|
|
||||||
|
// Set the new working directory to the path before the executable
|
||||||
|
let mut path_buf = std::path::PathBuf::from(&path);
|
||||||
|
path_buf.pop();
|
||||||
|
|
||||||
|
// Open in new thread to prevent blocking.
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
// Without unwrap_or, this can crash when UAC prompt is denied
|
||||||
|
open::that(&path).unwrap_or(());
|
||||||
|
});
|
||||||
|
|
||||||
|
// Restore the original working directory
|
||||||
|
std::env::set_current_dir(&cwd).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn run_command(program: &str, args: Vec<&str>) {
|
pub fn run_command(program: &str, args: Vec<&str>) {
|
||||||
cmd(program, args).run().expect("Failed to run command");
|
cmd(program, args).run().expect("Failed to run command");
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ export default class ServerLaunchSection extends React.Component<{}, IState> {
|
|||||||
path: exe || config.game_install_path,
|
path: exe || config.game_install_path,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (gameExists) await invoke('run_program', { path: exe || config.game_install_path })
|
if (gameExists) await invoke('run_program_relative', { path: exe || config.game_install_path })
|
||||||
else alert('Game not found! At: ' + (exe || config.game_install_path))
|
else alert('Game not found! At: ' + (exe || config.game_install_path))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -308,6 +308,9 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
<div className="OptionLabel" id="menuOptionsLabelAkebi">
|
<div className="OptionLabel" id="menuOptionsLabelAkebi">
|
||||||
<Tr text="swag.akebi" />
|
<Tr text="swag.akebi" />
|
||||||
</div>
|
</div>
|
||||||
|
<div className="OptionValue" id="menuOptionsDirMigoto">
|
||||||
|
<DirInput onChange={this.setAkebi} value={this.state?.akebi_path} extensions={['exe']} />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|||||||
Reference in New Issue
Block a user