Skip to content

Commit

Permalink
fix:初次运行闪退
Browse files Browse the repository at this point in the history
  • Loading branch information
VirtualHotBar committed Jun 4, 2024
1 parent 0678c2c commit b3e53fd
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
Expand Down

0 comments on commit b3e53fd

Please sign in to comment.