use wrapper function instead of direct access app handle

This commit is contained in:
2025-12-08 19:13:30 +08:00
parent 4f62242517
commit 9c4a407820

View File

@@ -1,13 +1,12 @@
// in app-core/src/state.rs // in app-core/src/state.rs
use crate::{ use crate::{
lock_w, get_app_handle, lock_w,
models::{ models::{
app_config::{AppConfig, AuthConfig}, app_config::{AppConfig, AuthConfig},
app_data::AppData, app_data::AppData,
}, },
remotes::user::UserRemote, remotes::user::UserRemote,
services::auth::{load_auth_pass, AuthPass}, services::auth::{load_auth_pass, AuthPass},
APP_HANDLE,
}; };
use serde_json::json; use serde_json::json;
use std::{ use std::{
@@ -107,10 +106,7 @@ pub async fn init_app_data() {
{ {
let mut guard = lock_w!(FDOLL); let mut guard = lock_w!(FDOLL);
guard.app_data.user = Some(user); guard.app_data.user = Some(user);
APP_HANDLE get_app_handle()
.get()
// TODO: magic constants
.expect("App handle not initialized")
.emit("app-data-refreshed", json!(guard.app_data)) .emit("app-data-refreshed", json!(guard.app_data))
.expect("TODO: handle event emit fail"); .expect("TODO: handle event emit fail");
} }