ui/frontend: adaptive changes for...

... Vue and Webpack behavioral changes
This commit is contained in:
liushuyu 2019-10-21 16:38:06 -06:00 committed by James
parent 630f2231ab
commit b9e825faa5
4 changed files with 12 additions and 13 deletions

View file

@ -2,7 +2,8 @@
extern crate mime_guess; 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 { macro_rules! include_files_as_assets {
( $target_match:expr, $( $file_name:expr ),* ) => { ( $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) => { Some(ext_ptr) => {
let ext = &file_path[ext_ptr + 1..]; 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(); let string_mime = guessed_mime.to_string();

View file

@ -3,7 +3,6 @@
//! The /api/attr call returns an executable script containing session variables. //! The /api/attr call returns an executable script containing session variables.
use frontend::rest::services::default_future; use frontend::rest::services::default_future;
use frontend::rest::services::encapsulate_json;
use frontend::rest::services::Future; use frontend::rest::services::Future;
use frontend::rest::services::Request; use frontend::rest::services::Request;
use frontend::rest::services::Response; use frontend::rest::services::Response;
@ -16,13 +15,10 @@ use logging::LoggingErrors;
pub fn handle(service: &WebService, _req: Request) -> Future { pub fn handle(service: &WebService, _req: Request) -> Future {
let framework = service.get_framework_read(); let framework = service.get_framework_read();
let file = encapsulate_json( let file = framework
"base_attributes",
&framework
.base_attributes .base_attributes
.to_json_str() .to_json_str()
.log_expect("Failed to render JSON representation of config"), .log_expect("Failed to render JSON representation of config");
);
default_future( default_future(
Response::new() Response::new()

View file

@ -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 { if new_path.to_string_lossy().len() > 0 {
let result = serde_json::to_string(&new_path) let result = serde_json::to_string(&new_path)
.log_expect("Unable to serialize response"); .log_expect("Unable to serialize response");
let command = format!("{}({});", callback_name, result); let command = format!("window.{}({});", callback_name, result);
debug!("Injecting response: {}", command); debug!("Injecting response: {}", command);
cb_result = wv.eval(&command); cb_result = wv.eval(&command);
} }

View file

@ -81,9 +81,11 @@ axios.get('/api/attrs').then(function (resp) {
console.error(err) console.error(err)
}) })
// function selectFileCallback (name) { function selectFileCallback (name) {
// app.install_location = name app.install_location = name
// } }
window.selectFileCallback = selectFileCallback
var app = new Vue({ var app = new Vue({
router: router, router: router,