希望能从社区挑选出一些最佳实践,方便工程化上手Tauri #11903
Replies: 1 comment 1 reply
-
First of all, i'd recommend to rewrite your run() function a bit so that tauri isn't spawned in a single threaded tokio runtime. Also, tauri already provides access to its own tokio runtime so you can just use that: #[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let db = tauri::async_runtime::block_on(handle::ConnectionHandle::establish_connection()).unwrap();
tauri::Builder::default()
.plugin(tauri_plugin_shell::init())
.manage(db)
.invoke_handler(tauri::generate_handler![greet,login,getGoodsList,getUserList,getRoleList])
.run(tauri::generate_context!())
.expect("error while running tauri application");
} This will probably not solve the problem but it's still worth a try. If indeed does not help i would look into https://docs.rs/sea-orm/latest/sea_orm/struct.ConnectOptions.html#method.acquire_timeout and https://docs.rs/sea-orm/latest/sea_orm/struct.ConnectOptions.html#method.connect_timeout in case it really is just a timeout. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
由于我的rust学习经验非常浅薄,但是结合可视化界面学习是一种能有成就感的方式,这是我愿意选择Tauri做工程的原因。
但是这个过程中遇到了一些问题,由于很多内容不了解总会走到弯路。
希望有些优秀实践作为我学习过程的指路明灯。
另外留下我学习过程中的一个问题:

我在做 Tauri 结合tokio、sea-orm遇到的问题,启动应用,第一次连接数据库时会连接报错,但是会自动重连,我的数据库工作依然继续,但是这个连接问题还是让我困惑。
`我不确定这是一个bug,还是我实践中的使用有问题。
我不知道是否应该留下仓库地址,但是我真的很需要引导。
Beta Was this translation helpful? Give feedback.
All reactions