mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-24 17:48:30 +02:00
Remove app-specific menu items
This commit is contained in:
@@ -789,28 +789,16 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_dev() -> bool {
|
fn is_dev() -> bool {
|
||||||
let env = option_env!("YAAK_ENV");
|
#[cfg(dev)] {
|
||||||
env.unwrap_or("production") != "production"
|
return true;
|
||||||
|
}
|
||||||
|
#[cfg(not(dev))] {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_window(handle: &AppHandle<Wry>, url: Option<&str>) -> Window<Wry> {
|
fn create_window(handle: &AppHandle<Wry>, url: Option<&str>) -> Window<Wry> {
|
||||||
let mut app_menu = window_menu::os_default("Yaak".to_string().as_str());
|
let app_menu = window_menu::os_default("Yaak".to_string().as_str());
|
||||||
if is_dev() {
|
|
||||||
let submenu = Submenu::new(
|
|
||||||
"Developer",
|
|
||||||
Menu::new()
|
|
||||||
.add_item(
|
|
||||||
CustomMenuItem::new("refresh".to_string(), "Refresh")
|
|
||||||
.accelerator("CmdOrCtrl + Shift + r"),
|
|
||||||
)
|
|
||||||
.add_item(
|
|
||||||
CustomMenuItem::new("toggle_devtools".to_string(), "Open Devtools")
|
|
||||||
.accelerator("CmdOrCtrl + Option + i"),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
app_menu = app_menu.add_submenu(submenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
let window_num = handle.windows().len();
|
let window_num = handle.windows().len();
|
||||||
let window_id = format!("wnd_{}", window_num);
|
let window_id = format!("wnd_{}", window_num);
|
||||||
let mut win_builder = tauri::WindowBuilder::new(
|
let mut win_builder = tauri::WindowBuilder::new(
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use tauri::{AboutMetadata, CustomMenuItem, Menu, MenuItem, Submenu};
|
use tauri::{AboutMetadata, CustomMenuItem, Menu, MenuItem, Submenu};
|
||||||
|
use crate::is_dev;
|
||||||
|
|
||||||
pub fn os_default(#[allow(unused)] app_name: &str) -> Menu {
|
pub fn os_default(#[allow(unused)] app_name: &str) -> Menu {
|
||||||
let mut menu = Menu::new();
|
let mut menu = Menu::new();
|
||||||
@@ -12,6 +13,11 @@ pub fn os_default(#[allow(unused)] app_name: &str) -> Menu {
|
|||||||
AboutMetadata::default(),
|
AboutMetadata::default(),
|
||||||
))
|
))
|
||||||
.add_native_item(MenuItem::Separator)
|
.add_native_item(MenuItem::Separator)
|
||||||
|
.add_item(
|
||||||
|
CustomMenuItem::new("toggle_settings".to_string(), "Settings")
|
||||||
|
.accelerator("CmdOrCtrl+,"),
|
||||||
|
)
|
||||||
|
.add_native_item(MenuItem::Separator)
|
||||||
.add_native_item(MenuItem::Services)
|
.add_native_item(MenuItem::Services)
|
||||||
.add_native_item(MenuItem::Separator)
|
.add_native_item(MenuItem::Separator)
|
||||||
.add_native_item(MenuItem::Hide)
|
.add_native_item(MenuItem::Hide)
|
||||||
@@ -69,23 +75,23 @@ pub fn os_default(#[allow(unused)] app_name: &str) -> Menu {
|
|||||||
)
|
)
|
||||||
.add_item(
|
.add_item(
|
||||||
CustomMenuItem::new("zoom_out".to_string(), "Zoom Out").accelerator("CmdOrCtrl+-"),
|
CustomMenuItem::new("zoom_out".to_string(), "Zoom Out").accelerator("CmdOrCtrl+-"),
|
||||||
)
|
|
||||||
.add_native_item(MenuItem::Separator)
|
|
||||||
.add_item(
|
|
||||||
CustomMenuItem::new("toggle_sidebar".to_string(), "Toggle Sidebar")
|
|
||||||
.accelerator("CmdOrCtrl+b"),
|
|
||||||
)
|
|
||||||
.add_item(
|
|
||||||
CustomMenuItem::new("focus_sidebar".to_string(), "Focus Sidebar")
|
|
||||||
.accelerator("CmdOrCtrl+1"),
|
|
||||||
)
|
|
||||||
.add_item(
|
|
||||||
CustomMenuItem::new("toggle_settings".to_string(), "Toggle Settings")
|
|
||||||
.accelerator("CmdOrCtrl+,"),
|
|
||||||
)
|
|
||||||
.add_item(
|
|
||||||
CustomMenuItem::new("focus_url".to_string(), "Focus URL").accelerator("CmdOrCtrl+l"),
|
|
||||||
);
|
);
|
||||||
|
// .add_native_item(MenuItem::Separator)
|
||||||
|
// .add_item(
|
||||||
|
// CustomMenuItem::new("toggle_sidebar".to_string(), "Toggle Sidebar")
|
||||||
|
// .accelerator("CmdOrCtrl+b"),
|
||||||
|
// )
|
||||||
|
// .add_item(
|
||||||
|
// CustomMenuItem::new("focus_sidebar".to_string(), "Focus Sidebar")
|
||||||
|
// .accelerator("CmdOrCtrl+1"),
|
||||||
|
// )
|
||||||
|
// .add_item(
|
||||||
|
// CustomMenuItem::new("toggle_settings".to_string(), "Toggle Settings")
|
||||||
|
// .accelerator("CmdOrCtrl+,"),
|
||||||
|
// )
|
||||||
|
// .add_item(
|
||||||
|
// CustomMenuItem::new("focus_url".to_string(), "Focus URL").accelerator("CmdOrCtrl+l"),
|
||||||
|
// );
|
||||||
menu = menu.add_submenu(Submenu::new("View", view_menu));
|
menu = menu.add_submenu(Submenu::new("View", view_menu));
|
||||||
|
|
||||||
let mut window_menu = Menu::new();
|
let mut window_menu = Menu::new();
|
||||||
@@ -98,22 +104,37 @@ pub fn os_default(#[allow(unused)] app_name: &str) -> Menu {
|
|||||||
window_menu = window_menu.add_native_item(MenuItem::CloseWindow);
|
window_menu = window_menu.add_native_item(MenuItem::CloseWindow);
|
||||||
menu = menu.add_submenu(Submenu::new("Window", window_menu));
|
menu = menu.add_submenu(Submenu::new("Window", window_menu));
|
||||||
|
|
||||||
menu = menu.add_submenu(Submenu::new(
|
// menu = menu.add_submenu(Submenu::new(
|
||||||
"Workspace",
|
// "Workspace",
|
||||||
Menu::new()
|
// Menu::new()
|
||||||
.add_item(
|
// .add_item(
|
||||||
CustomMenuItem::new("send_request".to_string(), "Send Request")
|
// CustomMenuItem::new("send_request".to_string(), "Send Request")
|
||||||
.accelerator("CmdOrCtrl+r"),
|
// .accelerator("CmdOrCtrl+r"),
|
||||||
)
|
// )
|
||||||
.add_item(
|
// .add_item(
|
||||||
CustomMenuItem::new("new_request".to_string(), "New Request")
|
// CustomMenuItem::new("new_request".to_string(), "New Request")
|
||||||
.accelerator("CmdOrCtrl+n"),
|
// .accelerator("CmdOrCtrl+n"),
|
||||||
)
|
// )
|
||||||
.add_item(
|
// .add_item(
|
||||||
CustomMenuItem::new("duplicate_request".to_string(), "Duplicate Request")
|
// CustomMenuItem::new("duplicate_request".to_string(), "Duplicate Request")
|
||||||
.accelerator("CmdOrCtrl+d"),
|
// .accelerator("CmdOrCtrl+d"),
|
||||||
),
|
// ),
|
||||||
));
|
// ));
|
||||||
|
|
||||||
|
if is_dev() {
|
||||||
|
menu = menu.add_submenu(Submenu::new(
|
||||||
|
"Developer",
|
||||||
|
Menu::new()
|
||||||
|
.add_item(
|
||||||
|
CustomMenuItem::new("refresh".to_string(), "Refresh")
|
||||||
|
.accelerator("CmdOrCtrl + Shift + r"),
|
||||||
|
)
|
||||||
|
.add_item(
|
||||||
|
CustomMenuItem::new("toggle_devtools".to_string(), "Open Devtools")
|
||||||
|
.accelerator("CmdOrCtrl + Option + i"),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
menu
|
menu
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,12 @@ export type { EditorProps } from './Editor';
|
|||||||
// showing any content
|
// showing any content
|
||||||
// const editor = await import('./Editor');
|
// const editor = await import('./Editor');
|
||||||
|
|
||||||
|
document.addEventListener('keydown', (e) => {
|
||||||
|
console.log('E', e.key);
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
export const Editor = editor.Editor;
|
export const Editor = editor.Editor;
|
||||||
export const graphql = editor.graphql;
|
export const graphql = editor.graphql;
|
||||||
export const getIntrospectionQuery = editor.getIntrospectionQuery;
|
export const getIntrospectionQuery = editor.getIntrospectionQuery;
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ export function fallbackRequestName(r: HttpRequest | null): string {
|
|||||||
return r.name;
|
return r.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r.url.trim() === '') {
|
const withoutVariables = r.url.replace(/\$\{\[[^\]]+]}/g, '');
|
||||||
|
if (withoutVariables.trim() === '') {
|
||||||
return 'New Request';
|
return 'New Request';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user