Files
wwjcloud-nest-v1/wwjcloud-nest-v1/wwjcloud/libs/wwjcloud-boot/src/vendor/utils/zip.utils.ts
wanwu 5c1647df7c feat: 完善所有TODO功能
- 实现CloudBuildService.clearBuildTask()方法
- 实现CoreAddonInstallService.handleAddonInstall()方法
- 实现QuartzJobManager动态Job加载机制
- 创建WwjcloudService和CloudBuildService接口和实现
- 实现zip解压功能(ZipUtils)
- 完善addon-service-impl.service.ts中的download和getIndexAddonList方法
- 添加JobProvider接口和注册机制
- 修复所有编译错误,代码编译通过
2025-11-01 21:29:54 +08:00

33 lines
769 B
TypeScript

import * as AdmZip from 'adm-zip';
import * as fs from 'fs';
import * as path from 'path';
/**
* Zip工具类
* 严格对齐Java: cn.hutool.core.util.ZipUtil
*/
export class ZipUtils {
/**
* 解压zip文件
* 严格对齐Java: ZipUtil.unzip(String zipPath, String destDir, Charset charset)
*/
static unzip(zipPath: string, destDir: string): void {
if (!fs.existsSync(zipPath)) {
throw new Error(`Zip文件不存在: ${zipPath}`);
}
// 确保目标目录存在
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir, { recursive: true });
}
try {
const zip = new AdmZip(zipPath);
zip.extractAllTo(destDir, true);
} catch (error) {
throw new Error(`解压zip文件失败: ${error}`);
}
}
}