Skip to content

Commit

Permalink
fix: add global menu
Browse files Browse the repository at this point in the history
Signed-off-by: seven <[email protected]>
  • Loading branch information
Blankll committed Jun 17, 2024
1 parent 0c7638f commit 7fb91b6
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Prevents additional console window on Windows in release, DO NOT REMOVE!!
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
mod menu;

use std::collections::HashMap;
use std::env;
Expand Down Expand Up @@ -457,6 +458,7 @@ fn main() {
Ok(())
})
.invoke_handler(tauri::generate_handler![create_openai_client,fetch_api,find_assistant, modify_assistant, create_assistant,chat_assistant])
.menu(menu::create_menu())
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
37 changes: 37 additions & 0 deletions src-tauri/src/menu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use serde_json::Value::String;
use tauri::{AboutMetadata, CustomMenuItem, Submenu};
use tauri::Menu;
use tauri::MenuItem;

pub fn create_menu() -> Menu {
let about_menu = Submenu::new("DocKit", Menu::new().add_native_item(MenuItem::About("DocKit".into(), AboutMetadata::default())).add_native_item(MenuItem::Separator)
.add_native_item(MenuItem::Services)
.add_native_item(MenuItem::Separator)
.add_native_item(MenuItem::Hide)
.add_native_item(MenuItem::HideOthers)
.add_native_item(MenuItem::ShowAll)
.add_native_item(MenuItem::Separator)
.add_native_item(MenuItem::Quit));
let file_menu = Submenu::new("File", Menu::new().add_item(CustomMenuItem::new("save".to_string(), "Save")));
let edit_menu = Submenu::new("Edit", Menu::new().add_native_item(MenuItem::Undo)
.add_native_item(MenuItem::Redo)
.add_native_item(MenuItem::Separator)
.add_native_item(MenuItem::Cut)
.add_native_item(MenuItem::Copy)
.add_native_item(MenuItem::Paste)
.add_native_item(MenuItem::SelectAll));
let window_menu = Submenu::new("Window", Menu::new().add_native_item(MenuItem::Minimize)
.add_native_item(MenuItem::EnterFullScreen)
.add_native_item(MenuItem::CloseWindow)
.add_native_item(MenuItem::Separator)
.add_item(CustomMenuItem::new("front".to_string(), "Front")));

let developer_menu = Submenu::new("Developer", Menu::new().add_item(CustomMenuItem::new("toggle_dev_tools".to_string(), "Toggle Developer Tools")));

Menu::new()
.add_submenu(about_menu)
.add_submenu(file_menu)
.add_submenu(edit_menu)
.add_submenu(window_menu)
.add_submenu(developer_menu)
}

0 comments on commit 7fb91b6

Please sign in to comment.