From b3e53fd9788ff011ff0df54ba7e34e6a22bb5f8c Mon Sep 17 00:00:00 2001 From: VirtualHotBar <96966978+VirtualHotBar@users.noreply.github.com> Date: Wed, 5 Jun 2024 00:22:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=88=9D=E6=AC=A1=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E9=97=AA=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src-tauri/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 9d6e868..588ee03 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -202,12 +202,22 @@ pub fn init() -> anyhow::Result<()> { write_json_file ]) .setup(|app| { + //判断配置目录是否存在,如不存在创建配置目录 + let config_dir = app.app_data_dir(); + if !config_dir.exists() { + std::fs::create_dir_all(&config_dir).expect("创建配置目录失败"); + println!("创建配置目录成功"); + } + + //配置文件 if let Some(file) = File::open(app.app_config_file()).ok() { app.set_app_state(Config(serde_json::from_reader(file)?)) } else { app.write_app_config(Config::default())? }; app.update_app_config()?; + + //开发者工具 #[cfg(debug_assertions)] app.app_main_window().toggle_devtools(Some(true)); Ok(())