diff --git a/CHANGES.md b/CHANGES.md
index 94fa7ba..7925023 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -1,5 +1,5 @@
# Changelog
-## 2023.1.15
+## 23.1.15 (2023.01.15)
-初始化f-t
+第一个版本, 完成基本功能
diff --git a/index.html b/index.html
index 11603f8..26b31b6 100644
--- a/index.html
+++ b/index.html
@@ -4,7 +4,7 @@
-
Vite App
+ f-t
diff --git a/package.json b/package.json
index f5474e4..c9deb31 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "f-t",
"private": true,
- "version": "2023.1.15",
+ "version": "23.1.15",
"author": {
"name": "lly ke",
"email": "2720851545@qq.com"
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 9806a7b..810d655 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -563,7 +563,7 @@ dependencies = [
[[package]]
name = "f-t"
-version = "2023.1.15"
+version = "23.1.15"
dependencies = [
"serde",
"serde_json",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index d5ca440..76ff649 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "f-t"
-version = "2023.1.15"
+version = "23.1.15"
description = "A Tauri App"
authors = ["lly ke"]
license = "MIT"
diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs
new file mode 100644
index 0000000..1242acc
--- /dev/null
+++ b/src-tauri/src/commands.rs
@@ -0,0 +1,10 @@
+use crate::setup::set_window_vibrancy;
+
+#[tauri::command]
+pub fn backend_add(number: i32) -> i32 {
+ // Note: these commands block the main thread and hang the UI until they return.
+ // If you need to run a long-running task, use async command instead.
+ println!("Backend was called with an argument: {}", number);
+ // set_window_vibrancy();
+ number + 2
+}
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 626ded4..5a11400 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -3,83 +3,13 @@
windows_subsystem = "windows"
)]
-use tauri::utils::assets::EmbeddedAssets;
-use tauri::api::shell;
-use tauri::{App, CustomMenuItem, GlobalShortcutManager, Manager, Menu, MenuItem, Submenu, Wry, Context, AboutMetadata};
mod setup;
-
-#[tauri::command]
-fn backend_add(number: i32) -> i32 {
- // Note: these commands block the main thread and hang the UI until they return.
- // If you need to run a long-running task, use async command instead.
- println!("Backend was called with an argument: {}", number);
- number + 2
-}
-
-// fn register_shortcut(app: &App) {
-// let mut short_cut = app.global_shortcut_manager(); //获取快捷键管理实例
-// let app_handler = app.handle();
-// let result = short_cut.register("command+w", move || {
-// let window = app_handler.get_window("main").unwrap();
-// window.close();
-// });
-// if let Err(err) = result {
-// println!("{}", err);
-// }
-// }
-
-pub fn init(context: &Context) -> Menu {
- // 应用名称
- let name = &context.package_info().name;
- // tauri::Menu::os_default(name)
- // 应用主菜单
- let app_menu = Submenu::new(
- "",
- // MenuItem::About 为原生菜单
- Menu::new().add_native_item(MenuItem::About(name.into(), AboutMetadata::new())),
- );
- // 文件菜单(自定义菜单)
- let file_menu = Submenu::new(
- "File",
- Menu::new()
- .add_item(CustomMenuItem::new("new_file".to_string(), "New File"))
- .add_item(CustomMenuItem::new("edit_file".to_string(), "Edit File")),
- );
- // 编辑菜单(自定义菜单)
- let edit_menu = Submenu::new(
- "Edit",
- Menu::new()
- .add_item(CustomMenuItem::new("undo".to_string(), "Undo"))
- .add_item(CustomMenuItem::new("redo".to_string(), "Redo")),
- );
-
- Menu::new()
- .add_submenu(app_menu)
- .add_submenu(file_menu)
- .add_submenu(edit_menu)
-}
+mod commands;
fn main() {
let ctx = tauri::generate_context!();
tauri::Builder::default()
- .invoke_handler(tauri::generate_handler![backend_add])
- // .menu(Menu::with_items([
- // MenuItem::SelectAll.into(),
- // MenuItem::Redo.into(),
- // CustomMenuItem::new("toggle", "Toggle visibility").into(),
- // Submenu::new("View", Menu::new()).into(),
- // ]))
- .menu(init(&ctx))
- .on_menu_event(|event| {
- let event_name = event.menu_item_id();
- match event_name {
- "Online Documentation" => {
- let url = "https://github.com/Uninen/tauri-vue-template".to_string();
- shell::open(&event.window().shell_scope(), url, None).unwrap();
- }
- _ => {}
- }
- })
+ .invoke_handler(tauri::generate_handler![commands::backend_add])
.setup(setup::init)
.run(ctx)
.expect("error while running tauri application");
diff --git a/src-tauri/src/setup.rs b/src-tauri/src/setup.rs
index 92c3c0b..32ab423 100644
--- a/src-tauri/src/setup.rs
+++ b/src-tauri/src/setup.rs
@@ -1,24 +1,29 @@
-use tauri::{App, Manager};
+use tauri::{App, Manager, Window};
use window_vibrancy::{self, NSVisualEffectMaterial, NSVisualEffectState};
/// setup
pub fn init(app: &mut App) -> std::result::Result<(), Box> {
let win = app.get_window("main").unwrap();
+ set_window_vibrancy(win);
+ Ok(())
+}
+pub fn set_window_vibrancy(win: Window) {
// 仅在 macOS 下执行
#[cfg(target_os = "macos")]
window_vibrancy::apply_vibrancy(
&win,
NSVisualEffectMaterial::FullScreenUI,
Some(NSVisualEffectState::FollowsWindowActiveState),
- Some(12.1)
+ Some(12.1),
)
.expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");
// 仅在 windows 下执行
#[cfg(target_os = "windows")]
- window_vibrancy::apply_blur(&win, Some((18, 18, 18, 125)))
- .expect("Unsupported platform! 'apply_blur' is only supported on Windows");
-
- Ok(())
+ // 支持win10和win11
+ window_vibrancy::apply_acrylic(&win, Some((18, 18, 18, 125)))
+ .expect("Unsupported platform! 'apply_acrylic' is only supported on Windows");
+ // 只支持win11
+ // window_vibrancy::apply_mica(&win);
}
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 5a6db6b..243da46 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -1,7 +1,7 @@
{
"package": {
"productName": "f-t",
- "version": "2023.1.15"
+ "version": "23.1.15"
},
"build": {
"distDir": "../dist",