diff --git a/index.html b/index.html index 116a633..e308fa2 100644 --- a/index.html +++ b/index.html @@ -2,9 +2,9 @@ - + - Tauri + Svelte + TS + Проект J.A.R.V.I.S. diff --git a/public/media/app-icon.png b/public/media/app-icon.png deleted file mode 100644 index a55b393..0000000 Binary files a/public/media/app-icon.png and /dev/null differ diff --git a/public/media/app-logo.png b/public/media/app-logo.png deleted file mode 100644 index 2ca037b..0000000 Binary files a/public/media/app-logo.png and /dev/null differ diff --git a/public/media/header-logo.png b/public/media/header-logo.png new file mode 100644 index 0000000..ddc6d4e Binary files /dev/null and b/public/media/header-logo.png differ diff --git a/public/media/icons/github-logo.png b/public/media/icons/github-logo.png new file mode 100644 index 0000000..2318c8f Binary files /dev/null and b/public/media/icons/github-logo.png differ diff --git a/public/media/icons/howdy-logo.png b/public/media/icons/howdy-logo.png new file mode 100644 index 0000000..b71474b Binary files /dev/null and b/public/media/icons/howdy-logo.png differ diff --git a/src-tauri/Makefile.toml b/src-tauri/Makefile.toml deleted file mode 100644 index 51b17af..0000000 --- a/src-tauri/Makefile.toml +++ /dev/null @@ -1,45 +0,0 @@ -[tasks.format] -install_crate = "rustfmt" -command = "cargo" -args = ["fmt", "--", "--emit=files"] - -[tasks.clean] -command = "cargo" -args = ["clean"] - -[tasks.build_debug] -command = "cargo" -args = ["build"] - -[tasks.run] -command = "cargo" -args = ["run"] - -[tasks.build_release] -command = "cargo" -args = ["build", "--release"] -dependencies = ["clean"] - -[tasks.test] -command = "cargo" -args = ["test"] -# dependencies = ["clean"] - -[tasks.vosk] -script_runner = "python" -script_extension = "py" -script = { file = "vosk_build.py" } - -[tasks.debug] -dependencies = [ - "format", - "build_debug", - "vosk" -] - -[tasks.release] -dependencies = [ - "format", - "build_release", - "vosk" -] \ No newline at end of file diff --git a/src-tauri/commands/calculator/command.yaml b/src-tauri/commands/calculator/command.yaml index 06a346b..9eb8772 100644 --- a/src-tauri/commands/calculator/command.yaml +++ b/src-tauri/commands/calculator/command.yaml @@ -28,4 +28,5 @@ list: phrases: - закрой калькулятор - отключи калькулятор - - выключи калькулятор \ No newline at end of file + - выключи калькулятор + - убери калькулятор \ No newline at end of file diff --git a/src-tauri/src/config.rs b/src-tauri/src/config.rs index d6a68cf..c481bc5 100644 --- a/src-tauri/src/config.rs +++ b/src-tauri/src/config.rs @@ -1,3 +1,7 @@ +use std::iter::Once; + +use once_cell::sync::OnceCell; + // use const_concat::const_concat; // pub const IS_DEV: bool = cfg!(debug_assertions);// cfg!(debug_assertions); @@ -22,6 +26,8 @@ pub const LOG_FILE_NAME: &str = "log.txt"; pub const APP_VERSION: Option<&str> = option_env!("CARGO_PKG_VERSION"); pub const AUTHOR_NAME: Option<&str> = option_env!("CARGO_PKG_AUTHORS"); pub const REPOSITORY_LINK: Option<&str> = option_env!("CARGO_PKG_REPOSITORY"); +pub const TG_OFFICIAL_LINK: Option<&str> = Some("https://t.me/howdyho_official"); +pub const FEEDBACK_LINK: Option<&str> = Some("https://t.me/jarvis_feedback_bot"); // RUSPOTTER pub const RUSPOTTER_MIN_SCORE: f32 = 0.62; @@ -38,10 +44,11 @@ pub const VOSK_MIN_RATIO: f64 = 70.0; // ETC pub const CMD_RATIO_THRESHOLD: f64 = 60f64; -pub const CMS_WAIT_DELAY: std::time::Duration = std::time::Duration::from_secs(10); +pub const CMS_WAIT_DELAY: std::time::Duration = std::time::Duration::from_secs(15); pub const ASSISTANT_GREET_PHRASES: [&str; 3] = ["greet1", "greet2", "greet3"]; -pub const ASSISTANT_PHRASES_TBR: [&str; 16] = [ +pub const ASSISTANT_PHRASES_TBR: [&str; 17] = [ + "джарвис", "сэр", "слушаю сэр", "всегда к услугам", diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 80d5fe9..a4f48ff 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -78,7 +78,7 @@ fn main() { // log to file let log_file_path = format!("{}/{}", APP_LOG_DIR.lock().unwrap(), config::LOG_FILE_NAME); println!("!!!===============!!!\nLOGGING TO {}\n!!!===============!!!\n", &log_file_path); - simple_logging::log_to_file(log_file_path, LevelFilter::max()).expect("Failed to start logger ... is directory writable?"); + simple_logging::log_to_file(&log_file_path, LevelFilter::max()).expect("Failed to start logger ... is directory writable?"); Ok(()) }) @@ -100,10 +100,15 @@ fn main() { tauri_commands::get_cpu_usage, // sound commands tauri_commands::play_sound, + // fs commands + tauri_commands::show_in_folder, // etc commands tauri_commands::get_app_version, tauri_commands::get_author_name, - tauri_commands::get_repository_link + tauri_commands::get_repository_link, + tauri_commands::get_tg_official_link, + tauri_commands::get_feedback_link, + tauri_commands::get_log_file_path ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); diff --git a/src-tauri/src/tauri_commands.rs b/src-tauri/src/tauri_commands.rs index 250928d..bda0cb7 100644 --- a/src-tauri/src/tauri_commands.rs +++ b/src-tauri/src/tauri_commands.rs @@ -18,6 +18,10 @@ pub use sys::*; mod voice; pub use voice::*; +// import FS commands +mod fs; +pub use fs::*; + // import ETC commands mod etc; pub use etc::*; diff --git a/src-tauri/src/tauri_commands/etc.rs b/src-tauri/src/tauri_commands/etc.rs index 73bffc5..f8c4ad0 100644 --- a/src-tauri/src/tauri_commands/etc.rs +++ b/src-tauri/src/tauri_commands/etc.rs @@ -1,13 +1,12 @@ -use crate::config::APP_VERSION; -use crate::config::AUTHOR_NAME; -use crate::config::REPOSITORY_LINK; +use crate::config; +use crate::APP_LOG_DIR; // Learn more about Tauri commands at https://tauri.app/v1/guides/features/command #[tauri::command] pub fn get_app_version() -> String { - if let Some(ver) = APP_VERSION { - ver.to_string() + if let Some(res) = config::APP_VERSION { + res.to_string() } else { String::from("error") } @@ -15,8 +14,8 @@ pub fn get_app_version() -> String { #[tauri::command] pub fn get_author_name() -> String { - if let Some(ver) = AUTHOR_NAME { - ver.to_string() + if let Some(res) = config::AUTHOR_NAME { + res.to_string() } else { String::from("error") } @@ -24,9 +23,32 @@ pub fn get_author_name() -> String { #[tauri::command] pub fn get_repository_link() -> String { - if let Some(ver) = REPOSITORY_LINK { + if let Some(res) = config::REPOSITORY_LINK { + res.to_string() + } else { + String::from("error") + } +} + +#[tauri::command] +pub fn get_tg_official_link() -> String { + if let Some(ver) = config::TG_OFFICIAL_LINK { ver.to_string() } else { String::from("error") } } + +#[tauri::command] +pub fn get_feedback_link() -> String { + if let Some(res) = config::FEEDBACK_LINK { + res.to_string() + } else { + String::from("error") + } +} + +#[tauri::command] +pub fn get_log_file_path() -> String { + format!("{}", APP_LOG_DIR.lock().unwrap()) +} \ No newline at end of file diff --git a/src-tauri/src/tauri_commands/fs.rs b/src-tauri/src/tauri_commands/fs.rs new file mode 100644 index 0000000..b91e48d --- /dev/null +++ b/src-tauri/src/tauri_commands/fs.rs @@ -0,0 +1,47 @@ +use std::process::Command; + +// taken from https://github.com/tauri-apps/tauri/issues/4062#issuecomment-1338048169 +#[tauri::command] +pub fn show_in_folder(path: String) { + #[cfg(target_os = "windows")] + { + Command::new("explorer") + .args(["/select,", &path]) // The comma after select is not a typo + .spawn() + .unwrap(); + } + + #[cfg(target_os = "linux")] + { + if path.contains(",") { + // see https://gitlab.freedesktop.org/dbus/dbus/-/issues/76 + let new_path = match metadata(&path).unwrap().is_dir() { + true => path, + false => { + let mut path2 = PathBuf::from(path); + path2.pop(); + path2.into_os_string().into_string().unwrap() + } + }; + Command::new("xdg-open") + .arg(&new_path) + .spawn() + .unwrap(); + } else { + Command::new("dbus-send") + .args(["--session", "--dest=org.freedesktop.FileManager1", "--type=method_call", + "/org/freedesktop/FileManager1", "org.freedesktop.FileManager1.ShowItems", + format!("array:string:\"file://{path}\"").as_str(), "string:\"\""]) + .spawn() + .unwrap(); + } + } + + #[cfg(target_os = "macos")] + { + Command::new("open") + .args(["-R", &path]) + .spawn() + .unwrap(); + } +} \ No newline at end of file diff --git a/src-tauri/src/tauri_commands/listener.rs b/src-tauri/src/tauri_commands/listener.rs index e95198c..944fc7f 100644 --- a/src-tauri/src/tauri_commands/listener.rs +++ b/src-tauri/src/tauri_commands/listener.rs @@ -134,6 +134,7 @@ fn keyword_callback(_keyword_index: i32) { for tbr in config::ASSISTANT_PHRASES_TBR { test = test.replace(tbr, ""); } + test = test.trim().into(); // infer command if let Some((cmd_path, cmd_config)) = diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 3ec137c..6bfd6d4 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -60,8 +60,8 @@ "fullscreen": false, "resizable": false, "title": "Jarvis Voice Assistant", - "width": 550, - "height": 820 + "width": 500, + "height": 700 } ] } diff --git a/src-tauri/vosk_build.py b/src-tauri/vosk_build.py deleted file mode 100644 index 5a87fb2..0000000 --- a/src-tauri/vosk_build.py +++ /dev/null @@ -1,36 +0,0 @@ -# Simple python script used to -# copy Vosk libraries to the "target" directory -# after Rust build - -# Note that Rust build should be run via "cargo make " command -# in order to automate all the compile process - -import os -from pathlib import Path -import shutil - -# some config vars -VOSK_LIBRARIES_PATH = "D:/Rust/vosk" -TARGET_DIRS = ( - os.getcwd() + "/target/debug", - os.getcwd() + "/target/release" -) - -for tdir in TARGET_DIRS: - if not Path(tdir).is_dir(): - continue - - vosk_lib_testfile = Path(tdir + "/libvosk.dll") - - if vosk_lib_testfile.is_file(): - # skip - print("[Vosk] library files already exist in " + tdir) - else: - # copy lib files - src_files = os.listdir(VOSK_LIBRARIES_PATH) - for file_name in src_files: - full_file_name = os.path.join(VOSK_LIBRARIES_PATH, file_name) - if os.path.isfile(full_file_name): - shutil.copy(full_file_name, tdir) - - print("[Vosk] library files was copied to " + tdir) \ No newline at end of file diff --git a/src/components/Footer.svelte b/src/components/Footer.svelte index a4923b0..dc46f0e 100644 --- a/src/components/Footer.svelte +++ b/src/components/Footer.svelte @@ -1,13 +1,14 @@