fix(rust): spawn_blocking 改走 tauri::async_runtime(工程无 tokio 依赖,Windows 构建 E0433)

6 处 tokio::task::spawn_blocking(Git 同步 4 处 + docs/29 资源
命令 2 处)全部换成工程既有写法 tauri::async_runtime::spawn_blocking;
全量核对源码外部 crate 前缀与 Cargo.toml 依赖一致。docs/29 补勘误。
This commit is contained in:
Muse
2026-11-14 18:09:30 +08:00
parent c602573d8e
commit 4fca4b7143
2 changed files with 14 additions and 6 deletions

View File

@@ -258,7 +258,7 @@ fn write_new_file(dir: &Path, file_name: &str, data: &[u8]) -> Result<PathBuf, S
/// 大文件会冻 UI 线程且内存整载(docs/29)。
#[tauri::command]
pub async fn copy_to_assets(source: String, doc_path: String) -> Result<String, String> {
tokio::task::spawn_blocking(move || {
tauri::async_runtime::spawn_blocking(move || {
let src = PathBuf::from(&source);
let name = sanitize_file_name(
&src.file_name()
@@ -287,7 +287,7 @@ pub async fn save_bytes_to_assets(
file_name: String,
base64: String,
) -> Result<String, String> {
tokio::task::spawn_blocking(move || {
tauri::async_runtime::spawn_blocking(move || {
let name = sanitize_file_name(&file_name);
let bytes = base64_decode(&base64)?;
if bytes.len() as u64 > MAX_ASSET_BYTES {
@@ -784,7 +784,7 @@ fn git_status_inner(root: &str) -> GitStatusInfo {
#[tauri::command]
pub async fn git_status(root: String) -> GitStatusInfo {
tokio::task::spawn_blocking(move || git_status_inner(&root))
tauri::async_runtime::spawn_blocking(move || git_status_inner(&root))
.await
.unwrap_or(GitStatusInfo {
is_repo: false,
@@ -799,7 +799,7 @@ pub async fn git_status(root: String) -> GitStatusInfo {
#[tauri::command]
pub async fn git_init_repo(root: String, remote_url: String, branch: String) -> Result<GitStatusInfo, String> {
tokio::task::spawn_blocking(move || {
tauri::async_runtime::spawn_blocking(move || {
let dir = Path::new(&root);
let b = validate_branch(&branch)?;
let url = validate_remote_url(&remote_url)?;
@@ -833,7 +833,7 @@ pub async fn git_init_repo(root: String, remote_url: String, branch: String) ->
#[tauri::command]
pub async fn git_set_remote(root: String, remote_url: String) -> Result<GitStatusInfo, String> {
tokio::task::spawn_blocking(move || {
tauri::async_runtime::spawn_blocking(move || {
let dir = Path::new(&root);
let url_owned = validate_remote_url(&remote_url)?;
let url = url_owned.as_str();
@@ -855,7 +855,7 @@ pub async fn git_set_remote(root: String, remote_url: String) -> Result<GitStatu
#[tauri::command]
pub async fn git_sync_now(root: String, message: String) -> Result<GitSyncOutcome, String> {
tokio::task::spawn_blocking(move || {
tauri::async_runtime::spawn_blocking(move || {
let dir = Path::new(&root);
let st = git_status_inner(&root);
if !st.is_repo {