fix: appflowy session name

This commit is contained in:
appflowy 2023-03-13 16:09:11 +08:00
parent 34cb2b2a09
commit 88e0f6a32c
3 changed files with 22 additions and 18 deletions

View File

@ -1,22 +1,22 @@
use flowy_core::{get_client_server_configuration, AppFlowyCore, AppFlowyCoreConfig};
use flowy_core::{get_client_server_configuration, AppFlowyCore, AppFlowyCoreConfig, DEFAULT_NAME};
pub fn init_flowy_core() -> AppFlowyCore {
let config_json = include_str!("../tauri.conf.json");
let config: tauri_utils::config::Config = serde_json::from_str(config_json).unwrap();
let config_json = include_str!("../tauri.conf.json");
let config: tauri_utils::config::Config = serde_json::from_str(config_json).unwrap();
let mut data_path = tauri::api::path::app_local_data_dir(&config).unwrap();
if cfg!(debug_assertions) {
data_path.push("dev");
}
data_path.push("data");
let mut data_path = tauri::api::path::app_local_data_dir(&config).unwrap();
if cfg!(debug_assertions) {
data_path.push("dev");
}
data_path.push("data");
std::env::set_var("RUST_LOG", "debug");
let server_config = get_client_server_configuration().unwrap();
let config = AppFlowyCoreConfig::new(
data_path.to_str().unwrap(),
"AppFlowy".to_string(),
server_config,
)
.log_filter("trace", vec!["appflowy_tauri".to_string()]);
AppFlowyCore::new(config)
std::env::set_var("RUST_LOG", "debug");
let server_config = get_client_server_configuration().unwrap();
let config = AppFlowyCoreConfig::new(
data_path.to_str().unwrap(),
DEFAULT_NAME.to_string(),
server_config,
)
.log_filter("trace", vec!["appflowy_tauri".to_string()]);
AppFlowyCore::new(config)
}

View File

@ -30,7 +30,7 @@ pub extern "C" fn init_sdk(path: *mut c_char) -> i64 {
let server_config = get_client_server_configuration().unwrap();
let log_crates = vec!["flowy-ffi".to_string()];
let config = AppFlowyCoreConfig::new(path, "appflowy".to_string(), server_config)
let config = AppFlowyCoreConfig::new(path, DEFAULT_NAME.to_string(), server_config)
.log_filter("info", log_crates);
*APPFLOWY_CORE.write() = Some(AppFlowyCore::new(config));

View File

@ -33,6 +33,10 @@ use user_model::UserProfile;
static INIT_LOG: AtomicBool = AtomicBool::new(false);
/// This name will be used as to identify the current [AppFlowyCore] instance.
/// Don't change this.
pub const DEFAULT_NAME: &str = "appflowy";
#[derive(Clone)]
pub struct AppFlowyCoreConfig {
/// Different `AppFlowyCoreConfig` instance should have different name