mirror of
https://github.com/yuzu-emu/liftinstall.git
synced 2025-01-03 16:35:34 +00:00
ui/ux: implement "View Local Files" function...
... for Linux/macOS
This commit is contained in:
parent
ca994e49d3
commit
322f72609f
|
@ -32,6 +32,7 @@ mod static_files;
|
||||||
mod uninstall;
|
mod uninstall;
|
||||||
mod update_updater;
|
mod update_updater;
|
||||||
mod verify_path;
|
mod verify_path;
|
||||||
|
mod view_folder;
|
||||||
|
|
||||||
/// Expected incoming Request format from Hyper.
|
/// Expected incoming Request format from Hyper.
|
||||||
pub type Request = hyper::server::Request;
|
pub type Request = hyper::server::Request;
|
||||||
|
@ -138,6 +139,7 @@ impl Service for WebService {
|
||||||
(Method::Get, "/api/exit") => exit::handle(self, req),
|
(Method::Get, "/api/exit") => exit::handle(self, req),
|
||||||
(Method::Get, "/api/packages") => packages::handle(self, req),
|
(Method::Get, "/api/packages") => packages::handle(self, req),
|
||||||
(Method::Get, "/api/installation-status") => installation_status::handle(self, req),
|
(Method::Get, "/api/installation-status") => installation_status::handle(self, req),
|
||||||
|
(Method::Get, "/api/view-local-folder") => view_folder::handle(self, req),
|
||||||
(Method::Post, "/api/start-install") => install::handle(self, req),
|
(Method::Post, "/api/start-install") => install::handle(self, req),
|
||||||
(Method::Post, "/api/uninstall") => uninstall::handle(self, req),
|
(Method::Post, "/api/uninstall") => uninstall::handle(self, req),
|
||||||
(Method::Post, "/api/update-updater") => update_updater::handle(self, req),
|
(Method::Post, "/api/update-updater") => update_updater::handle(self, req),
|
||||||
|
|
35
src/frontend/rest/services/view_folder.rs
Normal file
35
src/frontend/rest/services/view_folder.rs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
//! frontend/rest/services/view_folder.rs
|
||||||
|
//!
|
||||||
|
//! The /api/view-local-folder returns whether the path exists or not.
|
||||||
|
//! Side-effect: will open the folder in the default file manager if it exists.
|
||||||
|
|
||||||
|
use super::default_future;
|
||||||
|
use crate::frontend::rest::services::Future;
|
||||||
|
use crate::frontend::rest::services::Request;
|
||||||
|
use crate::frontend::rest::services::Response;
|
||||||
|
use crate::frontend::rest::services::WebService;
|
||||||
|
|
||||||
|
use hyper::header::{ContentLength, ContentType};
|
||||||
|
|
||||||
|
use crate::logging::LoggingErrors;
|
||||||
|
use crate::native::open_in_shell;
|
||||||
|
|
||||||
|
pub fn handle(service: &WebService, _: Request) -> Future {
|
||||||
|
let framework = service.get_framework_read();
|
||||||
|
let mut response = false;
|
||||||
|
let path = framework.install_path.clone();
|
||||||
|
if let Some(path) = path {
|
||||||
|
response = true;
|
||||||
|
open_in_shell(path.as_path());
|
||||||
|
}
|
||||||
|
|
||||||
|
let file = serde_json::to_string(&response)
|
||||||
|
.log_expect("Failed to render JSON payload of installation status object");
|
||||||
|
|
||||||
|
default_future(
|
||||||
|
Response::new()
|
||||||
|
.with_header(ContentLength(file.len() as u64))
|
||||||
|
.with_header(ContentType::json())
|
||||||
|
.with_body(file),
|
||||||
|
)
|
||||||
|
}
|
|
@ -103,6 +103,10 @@ mod natives {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn open_in_shell(path: &Path) {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
||||||
/// Cleans up the installer
|
/// Cleans up the installer
|
||||||
pub fn burn_on_exit(app_name: &str) {
|
pub fn burn_on_exit(app_name: &str) {
|
||||||
let current_exe = env::current_exe().log_expect("Current executable could not be found");
|
let current_exe = env::current_exe().log_expect("Current executable could not be found");
|
||||||
|
@ -266,6 +270,8 @@ mod natives {
|
||||||
use slug::slugify;
|
use slug::slugify;
|
||||||
use std::fs::{create_dir_all, File};
|
use std::fs::{create_dir_all, File};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
use std::path::Path;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
pub fn create_shortcut(
|
pub fn create_shortcut(
|
||||||
|
@ -325,6 +331,19 @@ mod natives {
|
||||||
Ok("".to_string())
|
Ok("".to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn open_in_shell(path: &Path) {
|
||||||
|
let shell: &str;
|
||||||
|
if cfg!(target_os = "linux") {
|
||||||
|
shell = "xdg-open";
|
||||||
|
} else if cfg!(target_os = "macos") {
|
||||||
|
shell = "open";
|
||||||
|
} else {
|
||||||
|
warn!("Unsupported platform");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Command::new(shell).arg(path).spawn().ok();
|
||||||
|
}
|
||||||
|
|
||||||
/// Cleans up the installer
|
/// Cleans up the installer
|
||||||
pub fn burn_on_exit(app_name: &str) {
|
pub fn burn_on_exit(app_name: &str) {
|
||||||
let current_exe = env::current_exe().log_expect("Current executable could not be found");
|
let current_exe = env::current_exe().log_expect("Current executable could not be found");
|
||||||
|
|
|
@ -62,7 +62,9 @@ export default {
|
||||||
uninstall: function () {
|
uninstall: function () {
|
||||||
this.$router.push('/install/uninstall')
|
this.$router.push('/install/uninstall')
|
||||||
},
|
},
|
||||||
view_files: function () {}
|
view_files: function () {
|
||||||
|
this.$http.get('/api/view-local-folder')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue