first commit

This commit is contained in:
vitalii.litvinchuk
2026-09-18 09:42:16 +03:00
commit ac827c492f
41 changed files with 7178 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas
View File
+5268
View File
File diff suppressed because it is too large Load Diff
+41
View File
@@ -0,0 +1,41 @@
[package]
name = "tauri-app"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
# The `_lib` suffix may seem redundant but it is necessary
# to make the lib name unique and wouldn't conflict with the bin name.
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
name = "tauri_app_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = ["tray-icon"] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
dirs = "7.0.0"
open = "5.4.4"
windows-icons = "0.4.0"
base64 = "0.23.1"
# Read the optimization guideline for more details: https://tauri.app/concept/size/#cargo-configuration
[profile.release]
codegen-units = 1
lto = true
opt-level = 3
panic = "abort"
strip = true
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
tauri-plugin-autostart = "2"
tauri-plugin-global-shortcut = "2"
+3
View File
@@ -0,0 +1,3 @@
fn main() {
tauri_build::build()
}
+18
View File
@@ -0,0 +1,18 @@
{
"$schema": "../gen/schemas/desktop-schema.json",
"identifier": "default",
"description": "Capability for the main window",
"windows": [
"main"
],
"permissions": [
"core:default",
"opener:default",
"core:window:allow-hide",
"core:window:allow-show",
"core:window:allow-set-focus",
"autostart:allow-enable",
"autostart:allow-disable",
"autostart:allow-is-enabled"
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 777 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1020 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

+7
View File
@@ -0,0 +1,7 @@
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
+205
View File
@@ -0,0 +1,205 @@
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
use std::fs;
use std::path::PathBuf;
use tauri::AppHandle;
use tauri::{
menu::{Menu, MenuItem},
tray::{MouseButton, MouseButtonState, TrayIconBuilder, TrayIconEvent},
Manager,
};
use tauri_plugin_global_shortcut::{Code, GlobalShortcutExt, Modifiers, Shortcut, ShortcutState};
use windows_icons::{get_icon_base64_by_path_with_size, IconSize};
#[derive(serde::Serialize)]
pub struct AppItem {
name: String,
path: String,
source: String,
}
#[tauri::command]
fn get_apps() -> Vec<AppItem> {
let mut apps = Vec::new();
if let Some(mut path) = dirs::data_dir() {
path.push("Microsoft\\Internet Explorer\\Quick Launch\\User Pinned\\TaskBar");
if let Ok(entries) = std::fs::read_dir(&path) {
for entry in entries.flatten() {
let file_path = entry.path();
if file_path.extension().unwrap_or_default() == "lnk" {
let name = file_path
.file_stem()
.unwrap_or_default()
.to_string_lossy()
.to_string();
apps.push(AppItem {
name,
path: file_path.to_string_lossy().to_string(),
source: "Taskbar".to_string(),
});
}
}
}
}
if let Some(mut path) = dirs::data_dir() {
path.push("Microsoft\\Windows\\Start Menu\\Programs");
if let Ok(entries) = std::fs::read_dir(&path) {
for entry in entries.flatten() {
let file_path = entry.path();
if file_path.extension().unwrap_or_default() == "lnk" {
let name = file_path
.file_stem()
.unwrap_or_default()
.to_string_lossy()
.to_string();
apps.push(AppItem {
name,
path: file_path.to_string_lossy().to_string(),
source: "Start Menu".to_string(),
});
}
}
}
}
apps
}
#[tauri::command]
fn launch_app(path: String) -> Result<(), String> {
open::that(path).map_err(|e| e.to_string())
}
fn pinned_file(app: &AppHandle) -> Result<PathBuf, String> {
let dir = app.path().app_data_dir().map_err(|e| e.to_string())?;
fs::create_dir_all(&dir).map_err(|e| e.to_string())?;
Ok(dir.join("pinned.json"))
}
#[tauri::command]
fn get_pinned_apps(app: AppHandle) -> Result<Vec<String>, String> {
let path = pinned_file(&app)?;
if !path.exists() {
return Ok(Vec::new());
}
let data = fs::read_to_string(&path).map_err(|e| e.to_string())?;
serde_json::from_str(&data).map_err(|e| e.to_string())
}
#[tauri::command]
fn set_pinned_apps(app: AppHandle, paths: Vec<String>) -> Result<(), String> {
let path = pinned_file(&app)?;
let data = serde_json::to_string_pretty(&paths).map_err(|e| e.to_string())?;
fs::write(&path, data).map_err(|e| e.to_string())
}
#[tauri::command]
fn get_app_icon(path: String) -> Result<String, String> {
#[cfg(target_os = "windows")]
{
let result = get_icon_base64_by_path_with_size(&path, IconSize::Large)
.or_else(|_| windows_icons::get_icon_base64_by_path(&path));
match result {
Ok(b64) => {
if b64.starts_with("data:") {
Ok(b64)
} else {
Ok(format!("data:image/png;base64,{}", b64))
}
}
Err(_) => Ok(String::new()),
}
}
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![
get_apps,
launch_app,
get_pinned_apps,
set_pinned_apps,
get_app_icon
])
.plugin(
tauri_plugin_autostart::Builder::new()
.args(["--autostart"])
.app_name("App Launcher")
.build(),
)
.plugin(
tauri_plugin_global_shortcut::Builder::new()
.with_handler(|app, shortcut, event| {
if event.state == ShortcutState::Pressed {
if shortcut.matches(Modifiers::ALT, Code::Space) {
if let Some(window) = app.get_webview_window("main") {
let is_visible = window.is_visible().unwrap_or(false);
if is_visible {
window.hide().unwrap();
} else {
window.show().unwrap();
window.set_focus().unwrap();
}
}
}
}
})
.build(),
)
.setup(|app| {
let alt_space = Shortcut::new(Some(Modifiers::ALT), Code::Space);
app.global_shortcut().register(alt_space)?;
let show_i = MenuItem::with_id(app, "show", "Показати/Сховати", true, None::<&str>)?;
let quit_i = MenuItem::with_id(app, "quit", "Вийти", true, None::<&str>)?;
let menu = Menu::with_items(app, &[&show_i, &quit_i])?;
TrayIconBuilder::new()
.icon(app.default_window_icon().unwrap().clone())
.menu(&menu)
.show_menu_on_left_click(false)
.on_tray_icon_event(|tray, event| match event {
TrayIconEvent::Click {
button: MouseButton::Left,
button_state: MouseButtonState::Up,
..
} => {
let app_handle = tray.app_handle();
if let Some(window) = app_handle.get_webview_window("main") {
let is_visible = window.is_visible().unwrap_or(false);
if is_visible {
window.hide().unwrap();
} else {
window.show().unwrap();
window.set_focus().unwrap();
}
}
}
_ => {}
})
.on_menu_event(|app_handle, event| match event.id.as_ref() {
"quit" => std::process::exit(0),
"show" => {
if let Some(window) = app_handle.get_webview_window("main") {
let is_visible = window.is_visible().unwrap_or(false);
if is_visible {
window.hide().unwrap();
} else {
window.show().unwrap();
window.set_focus().unwrap();
}
}
}
_ => {}
})
.build(app)?;
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
+40
View File
@@ -0,0 +1,40 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "tauri-app",
"version": "0.1.0",
"identifier": "com.tauri-app",
"build": {
"beforeDevCommand": "deno task dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "deno task build",
"frontendDist": "../dist"
},
"app": {
"windows": [
{
"title": "Launcher",
"width": 700,
"height": 400,
"visible": false,
"decorations": false,
"transparent": true,
"center": true,
"skipTaskbar": true
}
],
"security": {
"csp": null
}
},
"bundle": {
"active": true,
"targets": "all",
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
]
}
}