From b9e825faa5851acb7bfc07b288612aeb62da0721 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Mon, 21 Oct 2019 16:38:06 -0600 Subject: [PATCH] ui/frontend: adaptive changes for... ... Vue and Webpack behavioral changes --- src/frontend/rest/assets.rs | 7 ++++--- src/frontend/rest/services/attributes.rs | 8 ++------ src/frontend/ui/mod.rs | 2 +- ui/src/main.js | 8 +++++--- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/frontend/rest/assets.rs b/src/frontend/rest/assets.rs index d019fab..66090c3 100644 --- a/src/frontend/rest/assets.rs +++ b/src/frontend/rest/assets.rs @@ -2,7 +2,8 @@ extern crate mime_guess; -use self::mime_guess::{get_mime_type, octet_stream}; +use self::mime_guess::mime::APPLICATION_OCTET_STREAM; +use self::mime_guess::from_ext; macro_rules! include_files_as_assets { ( $target_match:expr, $( $file_name:expr ),* ) => { @@ -23,9 +24,9 @@ pub fn file_from_string(file_path: &str) -> Option<(String, &'static [u8])> { Some(ext_ptr) => { let ext = &file_path[ext_ptr + 1..]; - get_mime_type(ext) + from_ext(ext).first_or_octet_stream() } - None => octet_stream(), + None => APPLICATION_OCTET_STREAM, }; let string_mime = guessed_mime.to_string(); diff --git a/src/frontend/rest/services/attributes.rs b/src/frontend/rest/services/attributes.rs index 267d1c4..0ef61d9 100644 --- a/src/frontend/rest/services/attributes.rs +++ b/src/frontend/rest/services/attributes.rs @@ -3,7 +3,6 @@ //! The /api/attr call returns an executable script containing session variables. use frontend::rest::services::default_future; -use frontend::rest::services::encapsulate_json; use frontend::rest::services::Future; use frontend::rest::services::Request; use frontend::rest::services::Response; @@ -16,13 +15,10 @@ use logging::LoggingErrors; pub fn handle(service: &WebService, _req: Request) -> Future { let framework = service.get_framework_read(); - let file = encapsulate_json( - "base_attributes", - &framework + let file = framework .base_attributes .to_json_str() - .log_expect("Failed to render JSON representation of config"), - ); + .log_expect("Failed to render JSON representation of config"); default_future( Response::new() diff --git a/src/frontend/ui/mod.rs b/src/frontend/ui/mod.rs index 7750690..ddda882 100644 --- a/src/frontend/ui/mod.rs +++ b/src/frontend/ui/mod.rs @@ -45,7 +45,7 @@ pub fn start_ui(app_name: &str, http_address: &str, is_launcher: bool) { if new_path.to_string_lossy().len() > 0 { let result = serde_json::to_string(&new_path) .log_expect("Unable to serialize response"); - let command = format!("{}({});", callback_name, result); + let command = format!("window.{}({});", callback_name, result); debug!("Injecting response: {}", command); cb_result = wv.eval(&command); } diff --git a/ui/src/main.js b/ui/src/main.js index d0b938f..110eb54 100644 --- a/ui/src/main.js +++ b/ui/src/main.js @@ -81,9 +81,11 @@ axios.get('/api/attrs').then(function (resp) { console.error(err) }) -// function selectFileCallback (name) { -// app.install_location = name -// } +function selectFileCallback (name) { + app.install_location = name +} + +window.selectFileCallback = selectFileCallback var app = new Vue({ router: router,