@@ -129,16 +129,40 @@ const doUpload = async () => {
129129const doDownload = async () => {
130130 const path = await window .$mapi .file .openDirectory ()
131131 if (path ) {
132- const files = checkedFileOnlyRecords .value
132+ const files = checkedFileRecords .value
133133 Dialog .loadingOn (t (' 正在下载' ))
134134 for (let f of files ) {
135- await window .$mapi .adb .filePull (device .value .id , filePath .value + ' /' + f .name , path + ' /' + f .name )
135+ const sourcePath = filePath .value + ' /' + f .name
136+ const targetPath = path + ' /' + f .name
137+ if (f .isDirectory ) {
138+ await downloadDirectory (device .value .id , sourcePath , targetPath )
139+ } else {
140+ await window .$mapi .adb .filePull (device .value .id , sourcePath , targetPath )
141+ }
136142 }
137143 Dialog .loadingOff ()
138144 Dialog .tipSuccess (t (' 下载成功' ))
139145 }
140146}
141147
148+ const downloadDirectory = async (deviceId : string , sourcePath : string , targetPath : string ) => {
149+ // 创建目标文件夹
150+ await window .$mapi .file .mkdir (targetPath , { isFullPath: true });
151+ // 获取源文件夹内容
152+ const files = await window .$mapi .adb .fileList (deviceId , sourcePath );
153+ for (let f of files ) {
154+ const newSourcePath = sourcePath + ' /' + f .name ;
155+ const newTargetPath = targetPath + ' /' + f .name ;
156+ if (f .type === ' directory' ) {
157+ console .log (' download directory:' , sourcePath , targetPath );
158+ await downloadDirectory (deviceId , newSourcePath , newTargetPath );
159+ } else {
160+ console .log (' download file:' , sourcePath , targetPath );
161+ await window .$mapi .adb .filePull (deviceId , newSourcePath , newTargetPath );
162+ }
163+ }
164+ }
165+
142166defineExpose ({
143167 show
144168})
@@ -217,8 +241,7 @@ const toggleSortByModifiedTime = () => {
217241 {{ $t('上传') }}
218242 </a-button >
219243 <a-button class =" mr-1"
220- @click =" doDownload"
221- :disabled =" checkedFileOnlyRecords.length===0" >
244+ @click =" doDownload" >
222245 <template #icon >
223246 <icon-download />
224247 </template >
0 commit comments