separate dev and production instances and add visual indicators of dev mode
This commit is contained in:
@ -15,7 +15,7 @@ use tauri::{
|
||||
RunEvent,
|
||||
WindowEvent,
|
||||
};
|
||||
use tauri::menu::MenuItem;
|
||||
use creddy_cli::GlobalArgs;
|
||||
|
||||
use crate::{
|
||||
config::{self, AppConfig},
|
||||
@ -32,12 +32,13 @@ use crate::{
|
||||
pub static APP: OnceCell<AppHandle> = OnceCell::new();
|
||||
|
||||
|
||||
pub fn run() -> tauri::Result<()> {
|
||||
pub fn run(global_args: GlobalArgs) -> tauri::Result<()> {
|
||||
if let Ok(_) = creddy_cli::show_window(global_args) {
|
||||
// app is already running, so terminate
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_single_instance::init(|app, _argv, _cwd| {
|
||||
show_main_window(app)
|
||||
.error_popup("Failed to show main window")
|
||||
}))
|
||||
.plugin(tauri_plugin_global_shortcut::Builder::default().build())
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
@ -58,6 +59,7 @@ pub fn run() -> tauri::Result<()> {
|
||||
ipc::save_config,
|
||||
ipc::launch_terminal,
|
||||
ipc::get_setup_errors,
|
||||
ipc::get_devmode,
|
||||
ipc::exit,
|
||||
])
|
||||
.setup(|app| rt::block_on(setup(app)))
|
||||
@ -158,8 +160,8 @@ fn start_auto_locker(app: AppHandle) {
|
||||
pub fn show_main_window(app: &AppHandle) -> Result<(), WindowError> {
|
||||
let w = app.get_webview_window("main").ok_or(WindowError::NoMainWindow)?;
|
||||
w.show()?;
|
||||
let show_hide = app.state::<MenuItem<tauri::Wry>>();
|
||||
show_hide.set_text("Hide")?;
|
||||
let menu = app.state::<tray::MenuItems>();
|
||||
menu.after_show()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@ -167,8 +169,8 @@ pub fn show_main_window(app: &AppHandle) -> Result<(), WindowError> {
|
||||
pub fn hide_main_window(app: &AppHandle) -> Result<(), WindowError> {
|
||||
let w = app.get_webview_window("main").ok_or(WindowError::NoMainWindow)?;
|
||||
w.hide()?;
|
||||
let show_hide = app.state::<MenuItem<tauri::Wry>>();
|
||||
show_hide.set_text("Show")?;
|
||||
let menu = app.state::<tray::MenuItems>();
|
||||
menu.after_hide()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user