npm i --save @nativescript/zip
- 版本:6.0.0
- GitHub: https://github.com/NativeScript/plugins
- NPM: https://npmjs.net.cn/package/%40nativescript%2Fzip
- 下载
- 昨天:1
- 上周:79
- 上个月:440
@nativescript/zip
npm install @nativescript/zip
用法
压缩
查看 ZipOptions
import { Zip } from '@nativescript/zip';
import { path, knownFolders } from '@nativescript/core';
let zipPath = path.join(knownFolders.temp().path, 'stuff.zip');
let dest = path.join(knownFolders.documents().path, '/assets');
Zip.zip({
directory: dest,
archive: zipPath
});
进度
import { Zip } from '@nativescript/zip';
import { path, knownFolders } from '@nativescript/core';
let zipPath = path.join(knownFolders.temp().path, 'stuff.zip');
let dest = path.join(knownFolders.documents().path, '/assets');
Zip.zip({
function onZipProgress(percent: number) {
console.log(`unzip progress: ${percent}`);
directory: dest,
archive: zipPath,
onProgress: onZipProgress
});
解压缩
查看 UnzipOptions
import { Zip } from '@nativescript/zip';
import { path, knownFolders } from '@nativescript/core';
let zipPath = path.join(knownFolders.temp().path, 'stuff.zip');
let dest = path.join(knownFolders.documents().path, '/assets');
Zip.unzip({
archive: zipPath,
directory: dest,
});
进度
import { Zip } from '@nativescript/zip';
import { path, knownFolders } from '@nativescript/core';
let zipPath = path.join(knownFolders.temp().path, 'stuff.zip');
let dest = path.join(knownFolders.documents().path, '/assets');
Zip.unzip({
archive: zipPath,
directory: dest,
onProgress: onUnZipProgress,
});
function onUnZipProgress(percent: number) {
console.log(`unzip progress: ${percent}`);
}
许可证
Apache 许可证版本 2.0