fix: replace tokio::runtime::Handle with tauri::async_runtime::handle

This commit is contained in:
Tunglies
2025-08-28 04:58:24 +08:00
parent d23d1d9a1d
commit 53688f332f
2 changed files with 6 additions and 7 deletions

View File

@@ -742,7 +742,7 @@ use crate::config::Config;
pub async fn profiles_append_item_safe(item: PrfItem) -> Result<()> { pub async fn profiles_append_item_safe(item: PrfItem) -> Result<()> {
AsyncHandler::spawn_blocking(move || { AsyncHandler::spawn_blocking(move || {
tokio::runtime::Handle::current().block_on(async { AsyncHandler::handle().block_on(async {
let profiles = Config::profiles().await; let profiles = Config::profiles().await;
let mut profiles_guard = profiles.data_mut(); let mut profiles_guard = profiles.data_mut();
profiles_guard.append_item(item).await profiles_guard.append_item(item).await
@@ -754,7 +754,7 @@ pub async fn profiles_append_item_safe(item: PrfItem) -> Result<()> {
pub async fn profiles_patch_item_safe(index: String, item: PrfItem) -> Result<()> { pub async fn profiles_patch_item_safe(index: String, item: PrfItem) -> Result<()> {
AsyncHandler::spawn_blocking(move || { AsyncHandler::spawn_blocking(move || {
tokio::runtime::Handle::current().block_on(async { AsyncHandler::handle().block_on(async {
let profiles = Config::profiles().await; let profiles = Config::profiles().await;
let mut profiles_guard = profiles.data_mut(); let mut profiles_guard = profiles.data_mut();
profiles_guard.patch_item(index, item).await profiles_guard.patch_item(index, item).await
@@ -766,7 +766,7 @@ pub async fn profiles_patch_item_safe(index: String, item: PrfItem) -> Result<()
pub async fn profiles_delete_item_safe(index: String) -> Result<bool> { pub async fn profiles_delete_item_safe(index: String) -> Result<bool> {
AsyncHandler::spawn_blocking(move || { AsyncHandler::spawn_blocking(move || {
tokio::runtime::Handle::current().block_on(async { AsyncHandler::handle().block_on(async {
let profiles = Config::profiles().await; let profiles = Config::profiles().await;
let mut profiles_guard = profiles.data_mut(); let mut profiles_guard = profiles.data_mut();
profiles_guard.delete_item(index).await profiles_guard.delete_item(index).await
@@ -778,7 +778,7 @@ pub async fn profiles_delete_item_safe(index: String) -> Result<bool> {
pub async fn profiles_reorder_safe(active_id: String, over_id: String) -> Result<()> { pub async fn profiles_reorder_safe(active_id: String, over_id: String) -> Result<()> {
AsyncHandler::spawn_blocking(move || { AsyncHandler::spawn_blocking(move || {
tokio::runtime::Handle::current().block_on(async { AsyncHandler::handle().block_on(async {
let profiles = Config::profiles().await; let profiles = Config::profiles().await;
let mut profiles_guard = profiles.data_mut(); let mut profiles_guard = profiles.data_mut();
profiles_guard.reorder(active_id, over_id).await profiles_guard.reorder(active_id, over_id).await
@@ -790,7 +790,7 @@ pub async fn profiles_reorder_safe(active_id: String, over_id: String) -> Result
pub async fn profiles_save_file_safe() -> Result<()> { pub async fn profiles_save_file_safe() -> Result<()> {
AsyncHandler::spawn_blocking(move || { AsyncHandler::spawn_blocking(move || {
tokio::runtime::Handle::current().block_on(async { AsyncHandler::handle().block_on(async {
let profiles = Config::profiles().await; let profiles = Config::profiles().await;
let profiles_guard = profiles.data_mut(); let profiles_guard = profiles.data_mut();
profiles_guard.save_file().await profiles_guard.save_file().await
@@ -802,7 +802,7 @@ pub async fn profiles_save_file_safe() -> Result<()> {
pub async fn profiles_draft_update_item_safe(index: String, item: PrfItem) -> Result<()> { pub async fn profiles_draft_update_item_safe(index: String, item: PrfItem) -> Result<()> {
AsyncHandler::spawn_blocking(move || { AsyncHandler::spawn_blocking(move || {
tokio::runtime::Handle::current().block_on(async { AsyncHandler::handle().block_on(async {
let profiles = Config::profiles().await; let profiles = Config::profiles().await;
let mut profiles_guard = profiles.draft_mut(); let mut profiles_guard = profiles.draft_mut();
profiles_guard.update_item(index, item).await profiles_guard.update_item(index, item).await

View File

@@ -8,7 +8,6 @@ use tauri::{async_runtime, async_runtime::JoinHandle};
pub struct AsyncHandler; pub struct AsyncHandler;
impl AsyncHandler { impl AsyncHandler {
#[allow(dead_code)]
pub fn handle() -> async_runtime::RuntimeHandle { pub fn handle() -> async_runtime::RuntimeHandle {
async_runtime::handle() async_runtime::handle()
} }