File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { ImageNode } from "@/core/stage/stageObject/entity/ImageNode" ;
2+ import { dirname , join } from "@tauri-apps/api/path" ;
23import { exists , writeFile } from "@tauri-apps/plugin-fs" ;
34import mime from "mime" ;
45
@@ -20,8 +21,8 @@ export async function exportImagesToProjectDirectory(
2021 let successCount = 0 ;
2122 let failedCount = 0 ;
2223
23- // 获取当前 prg 文件所在目录
24- const projectDir = projectPath . substring ( 0 , projectPath . lastIndexOf ( "/" ) ) ;
24+ // 获取当前 prg 文件所在目录(使用 Tauri 的 dirname 函数,支持跨平台)
25+ const projectDir = await dirname ( projectPath ) ;
2526
2627 for ( let i = 0 ; i < imageNodes . length ; i ++ ) {
2728 const imageNode = imageNodes [ i ] ;
@@ -40,7 +41,7 @@ export async function exportImagesToProjectDirectory(
4041
4142 // 构建文件名:如果是批量导出,添加数字后缀
4243 const finalFileName = isBatch ? `${ fileName } _${ i + 1 } ` : fileName ;
43- const saveFilePath = `${ projectDir } / ${ finalFileName } .${ ext } ` ;
44+ const saveFilePath = await join ( projectDir , `${ finalFileName } .${ ext } ` ) ;
4445
4546 // 检查文件是否已存在
4647 const fileExists = await exists ( saveFilePath ) ;
You can’t perform that action at this time.
0 commit comments