fix
This commit is contained in:
+20
-8
@@ -1,7 +1,11 @@
|
||||
pub mod apps;
|
||||
pub mod sync;
|
||||
|
||||
use che_tauri::{ApiError, ApiRequest, AppState, AuthTokenResponse, TauriApi};
|
||||
use che_orm::SqliteBackend;
|
||||
use che_tauri::{
|
||||
ApiError, ApiRequest, AppConfig, AppState, AuthTokenResponse, DatabaseConfig, RemoteConfig,
|
||||
TauriApi,
|
||||
};
|
||||
use tauri::Manager;
|
||||
|
||||
use crate::sync::SyncContractsResult;
|
||||
@@ -53,12 +57,9 @@ fn auth_status(api: tauri::State<'_, TauriApi>) -> bool {
|
||||
|
||||
#[tauri::command]
|
||||
async fn current_employee(api: tauri::State<'_, TauriApi>) -> Result<CurrentEmployee, ApiError> {
|
||||
let remote = api
|
||||
.state()
|
||||
.config
|
||||
.remote
|
||||
.as_ref()
|
||||
.ok_or_else(|| ApiError::bad_request("current_employee requires [remote].base_url config"))?;
|
||||
let remote = api.state().config.remote.as_ref().ok_or_else(|| {
|
||||
ApiError::bad_request("current_employee requires [remote].base_url config")
|
||||
})?;
|
||||
|
||||
let token = api
|
||||
.state()
|
||||
@@ -145,7 +146,18 @@ pub fn run() {
|
||||
}
|
||||
|
||||
let api = tauri::async_runtime::block_on(async {
|
||||
let state = AppState::from_config_file("app.toml").await?;
|
||||
// let state = AppState::from_config_file("app.toml").await?;
|
||||
let config = AppConfig {
|
||||
database: DatabaseConfig {
|
||||
url: String::from("sqlite://ewa-mobile.sqlite?mode=rwc"),
|
||||
},
|
||||
remote: Some(RemoteConfig {
|
||||
base_url: String::from("https://ewa-corp.ru/"),
|
||||
auth_path: Some(String::from(" /api-token-auth/")),
|
||||
}),
|
||||
};
|
||||
let db = SqliteBackend::connect(&config.database.url).await?;
|
||||
let state = AppState::new(config, db);
|
||||
TauriApi::new(state)
|
||||
.install(apps::installed_apps())
|
||||
.build()
|
||||
|
||||
Reference in New Issue
Block a user