display setup errors
This commit is contained in:
parent
913148a75a
commit
871dedf0a3
@ -17,7 +17,7 @@ tauri-build = { version = "1.0.4", features = [] }
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
tauri = { version = "1.0.5", features = ["api-all", "system-tray"] }
|
tauri = { version = "1.0.5", features = ["api-all", "dialog", "system-tray"] }
|
||||||
sodiumoxide = "0.2.7"
|
sodiumoxide = "0.2.7"
|
||||||
tokio = { version = ">=1.19", features = ["full"] }
|
tokio = { version = ">=1.19", features = ["full"] }
|
||||||
sqlx = { version = "0.6.2", features = ["sqlite", "runtime-tokio-rustls"] }
|
sqlx = { version = "0.6.2", features = ["sqlite", "runtime-tokio-rustls"] }
|
||||||
@ -37,10 +37,10 @@ dirs = "5.0"
|
|||||||
[features]
|
[features]
|
||||||
# by default Tauri runs in production mode
|
# by default Tauri runs in production mode
|
||||||
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
# when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
|
||||||
default = [ "custom-protocol" ]
|
default = ["custom-protocol"]
|
||||||
# this feature is used used for production builds where `devPath` points to the filesystem
|
# this feature is used used for production builds where `devPath` points to the filesystem
|
||||||
# DO NOT remove this
|
# DO NOT remove this
|
||||||
custom-protocol = [ "tauri/custom-protocol" ]
|
custom-protocol = ["tauri/custom-protocol"]
|
||||||
|
|
||||||
# [profile.dev.build-override]
|
# [profile.dev.build-override]
|
||||||
# opt-level = 3
|
# opt-level = 3
|
||||||
|
@ -90,6 +90,7 @@ pub fn set_auto_launch(is_configured: bool) -> Result<(), SetupError> {
|
|||||||
|
|
||||||
|
|
||||||
pub fn get_or_create_db_path() -> Result<PathBuf, DataDirError> {
|
pub fn get_or_create_db_path() -> Result<PathBuf, DataDirError> {
|
||||||
|
// debug_assertions doesn't always mean we are running in dev
|
||||||
if cfg!(debug_assertions) && std::env::var("HOME").is_ok() {
|
if cfg!(debug_assertions) && std::env::var("HOME").is_ok() {
|
||||||
return Ok(PathBuf::from("./creddy.db"));
|
return Ok(PathBuf::from("./creddy.db"));
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
windows_subsystem = "windows"
|
windows_subsystem = "windows"
|
||||||
)]
|
)]
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
use std::sync::mpsc::channel;
|
||||||
|
|
||||||
|
use once_cell::sync::OnceCell;
|
||||||
use sqlx::{
|
use sqlx::{
|
||||||
SqlitePool,
|
SqlitePool,
|
||||||
sqlite::SqlitePoolOptions,
|
sqlite::SqlitePoolOptions,
|
||||||
@ -15,7 +17,10 @@ use tauri::{
|
|||||||
Manager,
|
Manager,
|
||||||
async_runtime as rt,
|
async_runtime as rt,
|
||||||
};
|
};
|
||||||
use once_cell::sync::OnceCell;
|
use tauri::api::dialog::{
|
||||||
|
MessageDialogBuilder,
|
||||||
|
MessageDialogKind,
|
||||||
|
};
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod errors;
|
mod errors;
|
||||||
@ -61,7 +66,7 @@ async fn setup(app: &mut App) -> Result<(), Box<dyn Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn run() -> tauri::Result<()> {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
.system_tray(tray::create())
|
.system_tray(tray::create())
|
||||||
.on_system_tray_event(tray::handle_event)
|
.on_system_tray_event(tray::handle_event)
|
||||||
@ -74,8 +79,7 @@ fn main() {
|
|||||||
ipc::save_config,
|
ipc::save_config,
|
||||||
])
|
])
|
||||||
.setup(|app| rt::block_on(setup(app)))
|
.setup(|app| rt::block_on(setup(app)))
|
||||||
.build(tauri::generate_context!())
|
.build(tauri::generate_context!())?
|
||||||
.expect("error while running tauri application")
|
|
||||||
.run(|app, run_event| match run_event {
|
.run(|app, run_event| match run_event {
|
||||||
tauri::RunEvent::WindowEvent { label, event, .. } => match event {
|
tauri::RunEvent::WindowEvent { label, event, .. } => match event {
|
||||||
tauri::WindowEvent::CloseRequested { api, .. } => {
|
tauri::WindowEvent::CloseRequested { api, .. } => {
|
||||||
@ -85,7 +89,23 @@ fn main() {
|
|||||||
_ => ()
|
_ => ()
|
||||||
}
|
}
|
||||||
_ => ()
|
_ => ()
|
||||||
})
|
});
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
if let Err(e) = run() {
|
||||||
|
let (tx, rx) = channel();
|
||||||
|
MessageDialogBuilder::new(
|
||||||
|
"Creddy failed to start",
|
||||||
|
format!("{e}")
|
||||||
|
)
|
||||||
|
.kind(MessageDialogKind::Error)
|
||||||
|
.show(move |_| tx.send(true).unwrap());
|
||||||
|
rx.recv().unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,10 +29,7 @@
|
|||||||
if (alt && !event.altKey) return;
|
if (alt && !event.altKey) return;
|
||||||
if (shift && !event.shiftKey) return;
|
if (shift && !event.shiftKey) return;
|
||||||
|
|
||||||
if (event.code === hotkey) {
|
if (event.key === hotkey) {
|
||||||
click();
|
|
||||||
}
|
|
||||||
else if (hotkey === 'Enter' && event.code === 'NumpadEnter') {
|
|
||||||
click();
|
click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -41,6 +38,6 @@
|
|||||||
|
|
||||||
<svelte:window on:keydown={handleHotkey} />
|
<svelte:window on:keydown={handleHotkey} />
|
||||||
|
|
||||||
<a href="#" on:click="{click}" class={classes}>
|
<a href="/{target}" on:click|preventDefault="{click}" class={classes}>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</a>
|
</a>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import { invoke } from '@tauri-apps/api/tauri';
|
import { invoke } from '@tauri-apps/api/tauri';
|
||||||
|
import { type } from '@tauri-apps/api/os';
|
||||||
|
|
||||||
import { appState } from '../lib/state.js';
|
import { appState } from '../lib/state.js';
|
||||||
import Nav from '../ui/Nav.svelte';
|
import Nav from '../ui/Nav.svelte';
|
||||||
@ -21,6 +22,9 @@
|
|||||||
$appState.config = await invoke('get_config');
|
$appState.config = await invoke('get_config');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let osType = '';
|
||||||
|
type().then(t => osType = t);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +56,12 @@
|
|||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</NumericSetting>
|
</NumericSetting>
|
||||||
|
|
||||||
<NumericSetting title="Listen port" bind:value={$appState.config.listen_port} min=1 on:update={save}>
|
<NumericSetting
|
||||||
|
title="Listen port"
|
||||||
|
bind:value={$appState.config.listen_port}
|
||||||
|
min={osType === 'Windows_NT' ? 1 : 0}
|
||||||
|
on:update={save}
|
||||||
|
>
|
||||||
<svelte:fragment slot="description">
|
<svelte:fragment slot="description">
|
||||||
Listen for credentials requests on this port.
|
Listen for credentials requests on this port.
|
||||||
(Should be used with <code>$AWS_CONTAINER_CREDENTIALS_FULL_URI</code>)
|
(Should be used with <code>$AWS_CONTAINER_CREDENTIALS_FULL_URI</code>)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user