mirror of
https://gitee.com/openharmony/applications_app_samples
synced 2024-11-23 16:40:08 +00:00
fix Flashback
Signed-off-by: xinking129 <xinxin13@huawei.com>
This commit is contained in:
parent
e0a2e1a672
commit
cbbfb66616
@ -145,7 +145,6 @@ struct CompressFilesPage {
|
|||||||
bottom: '11%'
|
bottom: '11%'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await fileList.put('fileNames', JSON.stringify(this.files.fileData));
|
await fileList.put('fileNames', JSON.stringify(this.files.fileData));
|
||||||
await fileList.flush();
|
await fileList.flush();
|
||||||
}
|
}
|
||||||
@ -222,9 +221,9 @@ struct CompressFilesPage {
|
|||||||
this.slectFileName.push(item);
|
this.slectFileName.push(item);
|
||||||
} else {
|
} else {
|
||||||
this.isSelect = false;
|
this.isSelect = false;
|
||||||
let index = this.slectFileName.indexOf(item)
|
let index = this.slectFileName.indexOf(item);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
this.slectFileName.splice(index, 1)
|
this.slectFileName.splice(index, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -53,10 +53,15 @@ struct ZLibInterfaceListPage {
|
|||||||
checksum.crc32(0, arrayBufferIn);
|
checksum.crc32(0, arrayBufferIn);
|
||||||
try {
|
try {
|
||||||
// 压缩数据
|
// 压缩数据
|
||||||
await zip.deflate({ nextIn: arrayBufferIn, availableIn: BUFFER_SIZE, nextOut: arrayBufferOut,
|
await zip.deflate({
|
||||||
availableOut: BUFFER_SIZE }, zlib.CompressFlushMode.FINISH).then((data) => {
|
nextIn: arrayBufferIn,
|
||||||
|
availableIn: BUFFER_SIZE,
|
||||||
|
nextOut: arrayBufferOut,
|
||||||
|
availableOut: BUFFER_SIZE
|
||||||
|
}, zlib.CompressFlushMode.FINISH).then((data) => {
|
||||||
// 将压缩后的buffer写入zlibDeflateFile.txt文件中
|
// 将压缩后的buffer写入zlibDeflateFile.txt文件中
|
||||||
let zlibDeflateFile = fileIo.openSync(pathDir + '/zlibDeflateFile.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE);
|
let zlibDeflateFile =
|
||||||
|
fileIo.openSync(pathDir + '/zlibDeflateFile.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE);
|
||||||
fileIo.writeSync(zlibDeflateFile.fd, arrayBufferOut);
|
fileIo.writeSync(zlibDeflateFile.fd, arrayBufferOut);
|
||||||
fileIo.closeSync(zlibDeflateFile);
|
fileIo.closeSync(zlibDeflateFile);
|
||||||
promptAction.showToast({
|
promptAction.showToast({
|
||||||
@ -80,15 +85,20 @@ struct ZLibInterfaceListPage {
|
|||||||
checksum.crc32(0, arrayBufferOut);
|
checksum.crc32(0, arrayBufferOut);
|
||||||
try {
|
try {
|
||||||
// 解压数据
|
// 解压数据
|
||||||
await zip.inflate({ nextIn: arrayBufferOut, availableIn: BUFFER_SIZE, nextOut: inflateArrayBufferOut,
|
await zip.inflate({
|
||||||
availableOut: BUFFER_SIZE }, zlib.CompressFlushMode.NO_FLUSH).then((data) => {
|
nextIn: arrayBufferOut,
|
||||||
|
availableIn: BUFFER_SIZE,
|
||||||
|
nextOut: inflateArrayBufferOut,
|
||||||
|
availableOut: BUFFER_SIZE
|
||||||
|
}, zlib.CompressFlushMode.NO_FLUSH).then((data) => {
|
||||||
let array = new Uint8Array(inflateArrayBufferOut);
|
let array = new Uint8Array(inflateArrayBufferOut);
|
||||||
let dataString = '';
|
let dataString = '';
|
||||||
for (let i = 0; i < array.length; i++) {
|
for (let i = 0; i < array.length; i++) {
|
||||||
dataString += String.fromCharCode(array[i]);
|
dataString += String.fromCharCode(array[i]);
|
||||||
}
|
}
|
||||||
// 将解压后的数据写入zlibInflateFile.txt文件中
|
// 将解压后的数据写入zlibInflateFile.txt文件中
|
||||||
let zlibInflateFile = fileIo.openSync(pathDir + '/zlibInflateFile.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE);
|
let zlibInflateFile =
|
||||||
|
fileIo.openSync(pathDir + '/zlibInflateFile.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE);
|
||||||
fileIo.writeSync(zlibInflateFile.fd, dataString);
|
fileIo.writeSync(zlibInflateFile.fd, dataString);
|
||||||
fileIo.closeSync(zlibInflateFile);
|
fileIo.closeSync(zlibInflateFile);
|
||||||
// 验证压缩与解压的数据是否一致
|
// 验证压缩与解压的数据是否一致
|
||||||
@ -121,7 +131,7 @@ struct ZLibInterfaceListPage {
|
|||||||
// 创建gzip对象
|
// 创建gzip对象
|
||||||
let gzip = zlib.createGZipSync();
|
let gzip = zlib.createGZipSync();
|
||||||
// 打开.gz文件,对文件进行写操作
|
// 打开.gz文件,对文件进行写操作
|
||||||
gzip.gzopen(path, 'wb');
|
await gzip.gzopen(path, 'wb');
|
||||||
let str = STRING_DATA;
|
let str = STRING_DATA;
|
||||||
let arrayBufferIn = new ArrayBuffer(BUFFER_SIZE);
|
let arrayBufferIn = new ArrayBuffer(BUFFER_SIZE);
|
||||||
let byteArray = new Uint8Array(arrayBufferIn);
|
let byteArray = new Uint8Array(arrayBufferIn);
|
||||||
@ -130,7 +140,7 @@ struct ZLibInterfaceListPage {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// 将bufferWithData压缩并写入文件
|
// 将bufferWithData压缩并写入文件
|
||||||
gzip.gzfwrite(arrayBufferIn, 8, 2).then((data) => {
|
await gzip.gzfwrite(arrayBufferIn, 8, 2).then((data) => {
|
||||||
promptAction.showToast({
|
promptAction.showToast({
|
||||||
message: $r('app.string.gzip_compress_success', str),
|
message: $r('app.string.gzip_compress_success', str),
|
||||||
bottom: '11%'
|
bottom: '11%'
|
||||||
@ -142,16 +152,16 @@ struct ZLibInterfaceListPage {
|
|||||||
bottom: '11%'
|
bottom: '11%'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
gzip.gzflush(0);
|
await gzip.gzflush(0);
|
||||||
gzip.gzclose();
|
await gzip.gzclose();
|
||||||
|
|
||||||
await sleep(SLEEP_TIME);
|
await sleep(SLEEP_TIME);
|
||||||
// 打开.gz文件,对文件进行读操作
|
// 打开.gz文件,对文件进行读操作
|
||||||
gzip.gzopen(path, 'rb');
|
await gzip.gzopen(path, 'rb');
|
||||||
try {
|
try {
|
||||||
let bufferWithDataOut = new ArrayBuffer(BUFFER_SIZE);
|
let bufferWithDataOut = new ArrayBuffer(BUFFER_SIZE);
|
||||||
// 从.gz文件中读取和解压数据
|
// 从.gz文件中读取和解压数据
|
||||||
gzip.gzfread(bufferWithDataOut, 8, 2).then((data) => {
|
await gzip.gzfread(bufferWithDataOut, 8, 2).then((data) => {
|
||||||
let array = new Uint8Array(bufferWithDataOut);
|
let array = new Uint8Array(bufferWithDataOut);
|
||||||
let dataString = '';
|
let dataString = '';
|
||||||
for (let i = 0; i < array.length; i++) {
|
for (let i = 0; i < array.length; i++) {
|
||||||
@ -162,7 +172,8 @@ struct ZLibInterfaceListPage {
|
|||||||
message: $r('app.string.gzip_uncompress_success', dataString),
|
message: $r('app.string.gzip_uncompress_success', dataString),
|
||||||
bottom: '11%'
|
bottom: '11%'
|
||||||
});
|
});
|
||||||
let gzipFile = fileIo.openSync(pathDir + '/gzipTest.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE);
|
let gzipFile =
|
||||||
|
fileIo.openSync(pathDir + '/gzipTest.txt', fileIo.OpenMode.READ_WRITE | fileIo.OpenMode.CREATE);
|
||||||
fileIo.writeSync(gzipFile.fd, dataString);
|
fileIo.writeSync(gzipFile.fd, dataString);
|
||||||
fileIo.closeSync(gzipFile);
|
fileIo.closeSync(gzipFile);
|
||||||
}
|
}
|
||||||
@ -173,7 +184,7 @@ struct ZLibInterfaceListPage {
|
|||||||
bottom: '11%'
|
bottom: '11%'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
gzip.gzclose();
|
await gzip.gzclose();
|
||||||
hilog.info(DOMAIN, TAG, BUNDLE + `gzipDecompression end`);
|
hilog.info(DOMAIN, TAG, BUNDLE + `gzipDecompression end`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,8 +21,7 @@
|
|||||||
"mainElement": "EntryAbility",
|
"mainElement": "EntryAbility",
|
||||||
"deviceTypes": [
|
"deviceTypes": [
|
||||||
"default",
|
"default",
|
||||||
"tablet",
|
"tablet"
|
||||||
"2in1"
|
|
||||||
],
|
],
|
||||||
"deliveryWithInstall": true,
|
"deliveryWithInstall": true,
|
||||||
"installationFree": false,
|
"installationFree": false,
|
||||||
|
Loading…
Reference in New Issue
Block a user