npm i --save nativescript-zip
- 版本:4.0.2
- GitHub:
- NPM: https://npmjs.net.cn/package/nativescript-zip
- 下载
- 昨天: 2
- 上周: 13
- 上个月: 137
NativeScript Zip
安装
NativeScript 4x
tns plugin add nativescript-zip
NativeScript 2x & 3x
tns plugin add [email protected]
用法
压缩
import { Zip } from "nativescript-zip";
import * as fs from "tns-core-modules/file-system";
let path = fs.path.join(fs.knownFolders.temp().path, "stuff");
let dest = fs.path.join(fs.knownFolders.documents().path, "/assets");
Zip.zip({
folder: path,
destination: dest
});
进度
import { Zip } from "nativescript-zip";
import * as fs from "tns-core-modules/file-system";
let path = fs.path.join(fs.knownFolders.temp().path, "stuff");
let dest = fs.path.join(fs.knownFolders.documents().path, "/assets");
Zip.zip({
folder: path,
destination: dest,
onProgress: onZipProgress
});
function onZipProgress(percent: number) {
console.log(`unzip progress: ${percent}`);
}
解压缩
import { Zip } from "nativescript-zip";
import * as fs from "tns-core-modules/file-system";
let zipPath = fs.path.join(fs.knownFolders.temp().path, "stuff.zip");
let dest = fs.path.join(fs.knownFolders.documents().path, "/assets");
Zip.unzip({
archive: zipPath,
destination: dest
});
进度
import { Zip } from "nativescript-zip";
import * as fs from "tns-core-modules/file-system";
let zipPath = fs.path.join(fs.knownFolders.temp().path, "stuff.zip");
let dest = fs.path.join(fs.knownFolders.documennts().path, "/assets");
Zip.unzip({
archive: zipPath,
destination: dest,
onProgress: onUnZipProgress
});
function onUnZipProgress(percent: number) {
console.log(`unzip progress: ${percent}`);
}
待办事项
- [x] 压缩方法
- [x] 进度