38 lines
1.2 KiB
Rust
38 lines
1.2 KiB
Rust
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
|
pub mod commands;
|
|
pub mod models;
|
|
pub mod services;
|
|
|
|
use services::db::create_db_pool;
|
|
use services::s3::{S3Client, S3Config};
|
|
use tauri::Manager;
|
|
|
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
|
pub fn run() {
|
|
tauri::Builder::default()
|
|
.plugin(tauri_plugin_opener::init())
|
|
.setup(|app| {
|
|
// 初始化数据库连接池
|
|
let pool = tauri::async_runtime::block_on(async {
|
|
create_db_pool().await.expect("连接Mysql数据库出错!")
|
|
});
|
|
app.manage(pool);
|
|
|
|
// 初始化S3客户端
|
|
let s3_cfg = S3Config::from().expect("读取S3配置失败!");
|
|
let s3_client = tauri::async_runtime::block_on(S3Client::new(&s3_cfg));
|
|
|
|
app.manage(s3_client);
|
|
Ok(())
|
|
})
|
|
.invoke_handler(tauri::generate_handler![
|
|
commands::user::login,
|
|
commands::user::get_user_page,
|
|
commands::user::register,
|
|
commands::user::del_user,
|
|
commands::user::update_user
|
|
])
|
|
.run(tauri::generate_context!())
|
|
.expect("error while running tauri application");
|
|
}
|