mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-29 17:15:38 +08:00
fix: replace tokio::runtime::Handle with tauri::async_runtime::handle
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user