From cd390dcd6bc9913256bccbd07dc459004c131954 Mon Sep 17 00:00:00 2001 From: zhoulisheng1 Date: Thu, 15 Dec 2022 19:23:40 -0800 Subject: [PATCH 1/5] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?=E6=9C=AC=E5=9C=B0=E6=96=87=E4=BB=B6=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoulisheng1 --- .../networkmanage/DownloadClient.ets | 112 +++-------------- .../imageknife/networkmanage/IDataFetch.ets | 2 +- .../networkmanage/LoadLocalFileClient.ets | 33 +++++ .../networkmanage/NetworkDownloadClient.ets | 118 ++++++++++++++++++ 4 files changed, 168 insertions(+), 97 deletions(-) create mode 100644 imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets create mode 100644 imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets index bdc85e0..e94b7cc 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets @@ -17,106 +17,26 @@ import { IDataFetch } from "../networkmanage/IDataFetch" import { RequestOption } from "../RequestOption" import { Md5 } from "../../cache/Md5" import { FileUtils } from "../../cache/FileUtils" +import {NetworkDownloadClient} from'./NetworkDownloadClient' +import {LoadLocalFileClient} from'./LoadLocalFileClient' import loadRequest from '@ohos.request'; +// 数据加载器 export class DownloadClient implements IDataFetch { + private networkClient = new NetworkDownloadClient(); + private localFileClient = new LoadLocalFileClient(); + + loadData(request: RequestOption, onCompleteFunction, onErrorFunction) { - - let filename = Md5.hashStr(request.generateDataKey); - let downloadFolder = request.getFilesPath() + "/" + request.networkCacheFolder; - let allpath = request.getFilesPath() + "/" + request.networkCacheFolder + "/" + filename + ".img"; - - if (!FileUtils.getInstance().existFolder(downloadFolder)) { - FileUtils.getInstance().createFolder(downloadFolder) - } - - if (FileUtils.getInstance().exist(allpath)) { - FileUtils.getInstance().deleteFile(allpath) - } - - let desc = filename + ".img"; - var downloadConfig = { - url: (request.loadSrc as string), - filePath: allpath, - }; - - let loadTask = null; - loadRequest.download(globalThis.ImageKnife.getImageKnifeContext(), downloadConfig).then(downloadTask => { - if (downloadTask) { - loadTask = downloadTask; - - loadTask.on('progress', (receivedSize, totalSize) => { - if(totalSize > 0) { - // 并不是所有服务器都会返回totalSize 当没有文件大小的时候,下载进度没有百分比回调,只能知道目前下载了多少数据量 - let percent = Math.round(((receivedSize * 1.0) / (totalSize * 1.0)) * 100) - if (request.progressFunc) { - request.progressFunc(percent); - } - } - }); - - loadTask.on('complete', () => { - let downloadPath = allpath; - request.downloadFilePath = downloadPath; - let arraybuffer = FileUtils.getInstance().readFilePic(downloadPath) - onCompleteFunction(arraybuffer); - FileUtils.getInstance().deleteFile(downloadPath); - - loadTask.off('complete', () => { - - }) - - loadTask.off('pause', () => { - }) - - loadTask.off('remove', () => { - }) - - loadTask.off('progress', () => { - }) - - loadTask.off('fail', () => { - }) - loadTask = null; - }) - - loadTask.on('pause', () => { - }) - - loadTask.on('remove', () => { - }) - - loadTask.on('fail', (err) => { - onErrorFunction('DownloadClient Download task fail err =' + err) - if (loadTask) { - loadTask.remove().then(result => { - loadTask.off('complete', () => { - }) - - loadTask.off('pause', () => { - }) - - loadTask.off('remove', () => { - }) - - loadTask.off('progress', () => { - }) - - loadTask.off('fail', () => { - }) - loadTask = null - }).catch(err => { - loadTask = null; - console.log('DownloadClient Download task fail err =' + err); - }) - } - }) - - } else { - onErrorFunction('DownloadClient downloadTask dismiss!') + if(typeof request.loadSrc == 'string') { + if (request.loadSrc.startsWith(globalThis.ImageKnife.getImageKnifeContext() + .filesDir) || request.loadSrc.startsWith(globalThis.ImageKnife.getImageKnifeContext().cacheDir)) { + // 本地沙盒 + this.localFileClient.loadLocalFileData(request,onCompleteFunction,onErrorFunction) + }else{ + // 网络下载 + this.networkClient.downloadNetworkData(request,onCompleteFunction,onErrorFunction) + } } - }).catch((err) => { - onErrorFunction(err) - }) } } \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/IDataFetch.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/IDataFetch.ets index cb25d56..4a3340b 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/IDataFetch.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/IDataFetch.ets @@ -15,7 +15,7 @@ import {RequestOption} from "../RequestOption" -// 网络接口 +// 资源加载接口 export interface IDataFetch { loadData(request: RequestOption, onCompleteFunction, onErrorFunction); } \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets new file mode 100644 index 0000000..0218b77 --- /dev/null +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { IDataFetch } from "../networkmanage/IDataFetch" +import { RequestOption } from "../RequestOption" +import { Md5 } from "../../cache/Md5" +import { FileUtils } from "../../cache/FileUtils" +import loadRequest from '@ohos.request'; + +export class LoadLocalFileClient { + loadLocalFileData(request: RequestOption, onCompleteFunction, onErrorFunction) { + if(typeof request.loadSrc == 'string') { + let fileBuffer = FileUtils.getInstance().readFilePic(request.loadSrc) + if(fileBuffer == null || fileBuffer.byteLength <=0){ + onErrorFunction('LoadLocalFileClient loadLocalFileData The File Does Not Exist!Check The File!') + }else{ + onCompleteFunction(fileBuffer); + } + } + } +} \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets new file mode 100644 index 0000000..a848e56 --- /dev/null +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { IDataFetch } from "../networkmanage/IDataFetch" +import { RequestOption } from "../RequestOption" +import { Md5 } from "../../cache/Md5" +import { FileUtils } from "../../cache/FileUtils" +import loadRequest from '@ohos.request'; + +// 数据加载器 +export class NetworkDownloadClient { + downloadNetworkData(request: RequestOption, onCompleteFunction, onErrorFunction) { + let filename = Md5.hashStr(request.generateDataKey); + let downloadFolder = request.getFilesPath() + "/" + request.networkCacheFolder; + let allpath = request.getFilesPath() + "/" + request.networkCacheFolder + "/" + filename + ".img"; + if (!FileUtils.getInstance().existFolder(downloadFolder)) { + FileUtils.getInstance().createFolder(downloadFolder) + } + if (FileUtils.getInstance().exist(allpath)) { + FileUtils.getInstance().deleteFile(allpath) + } + let desc = filename + ".img"; + var downloadConfig = { + url: (request.loadSrc as string), + filePath: allpath, + }; + let loadTask = null; + loadRequest.download(globalThis.ImageKnife.getImageKnifeContext(), downloadConfig).then(downloadTask => { + if (downloadTask) { + loadTask = downloadTask; + + loadTask.on('progress', (receivedSize, totalSize) => { + if(totalSize > 0) { + // 并不是所有服务器都会返回totalSize 当没有文件大小的时候,下载进度没有百分比回调,只能知道目前下载了多少数据量 + let percent = Math.round(((receivedSize * 1.0) / (totalSize * 1.0)) * 100) + if (request.progressFunc) { + request.progressFunc(percent); + } + } + }); + + loadTask.on('complete', () => { + let downloadPath = allpath; + request.downloadFilePath = downloadPath; + let arraybuffer = FileUtils.getInstance().readFilePic(downloadPath) + onCompleteFunction(arraybuffer); + FileUtils.getInstance().deleteFile(downloadPath); + + loadTask.off('complete', () => { + + }) + + loadTask.off('pause', () => { + }) + + loadTask.off('remove', () => { + }) + + loadTask.off('progress', () => { + }) + + loadTask.off('fail', () => { + }) + loadTask = null; + }) + + loadTask.on('pause', () => { + }) + + loadTask.on('remove', () => { + }) + + loadTask.on('fail', (err) => { + onErrorFunction('NetworkDownloadClient Download task fail err =' + err) + if (loadTask) { + loadTask.remove().then(result => { + loadTask.off('complete', () => { + }) + + loadTask.off('pause', () => { + }) + + loadTask.off('remove', () => { + }) + + loadTask.off('progress', () => { + }) + + loadTask.off('fail', () => { + }) + loadTask = null + }).catch(err => { + loadTask = null; + console.log('NetworkDownloadClient Download task fail err =' + err); + }) + } + }) + + } else { + onErrorFunction('NetworkDownloadClient downloadTask dismiss!') + } + }).catch((err) => { + onErrorFunction(err) + }) + } +} \ No newline at end of file From 619103145cde4cc6bff3e7f02d897e04e2269ff8 Mon Sep 17 00:00:00 2001 From: zhoulisheng1 Date: Tue, 20 Dec 2022 00:32:48 -0800 Subject: [PATCH 2/5] 1.update README.md Signed-off-by: zhoulisheng1 --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a9f03fd..15d70fb 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ struct Index { build() { Scroll() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 }) + ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption1 }) .width(300) // 自定义组件支持通用属性链式调用,可以直接设置宽高 .height(300) } @@ -107,7 +107,7 @@ struct IndexFunctionDemo { Scroll() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { Text("简单示例:加载一张gif图片").fontSize(15) - ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption }) + ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption }) .width(300) // 自定义组件支持通用属性链式调用,可以直接设置宽高 .height(300) } @@ -254,7 +254,7 @@ struct Index { build() { Scroll() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { - ImageKnifeComponent({ imageKnifeOption: $imageKnifeOption1 }) + ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption1 }) } } .width('100%') From 921a61132c85e73c00a6f6f0a3c1bf3b71f2aba5 Mon Sep 17 00:00:00 2001 From: zhoulisheng1 Date: Thu, 5 Jan 2023 00:33:17 -0800 Subject: [PATCH 3/5] =?UTF-8?q?1.networkmanage=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=E4=B8=8B=E7=9A=84=E4=BB=A3=E7=A0=81=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=BA=86=E6=A0=BC=E5=BC=8F=E5=8C=96=202.=E5=B0=86IDataFetch?= =?UTF-8?q?=E4=B8=AD=E7=9A=84loadData=E6=8E=A5=E5=8F=A3=E7=9A=84=20onCompl?= =?UTF-8?q?ete=20onError=20=E5=A3=B0=E6=98=8E=E4=BA=86=E5=AF=B9=E8=B1=A1?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoulisheng1 --- .../networkmanage/DownloadClient.ets | 31 +++++++++---------- .../imageknife/networkmanage/IDataFetch.ets | 4 +-- .../networkmanage/LoadLocalFileClient.ets | 22 ++++++------- .../networkmanage/NetworkDownloadClient.ets | 25 ++++++++------- .../requestmanage/RequestManager.ets | 5 ++- 5 files changed, 45 insertions(+), 42 deletions(-) diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets index e94b7cc..485f1b3 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/DownloadClient.ets @@ -13,12 +13,12 @@ * limitations under the License. */ -import { IDataFetch } from "../networkmanage/IDataFetch" -import { RequestOption } from "../RequestOption" -import { Md5 } from "../../cache/Md5" -import { FileUtils } from "../../cache/FileUtils" -import {NetworkDownloadClient} from'./NetworkDownloadClient' -import {LoadLocalFileClient} from'./LoadLocalFileClient' +import { IDataFetch } from '../networkmanage/IDataFetch' +import { RequestOption } from '../RequestOption' +import { Md5 } from '../../cache/Md5' +import { FileUtils } from '../../cache/FileUtils' +import { NetworkDownloadClient } from './NetworkDownloadClient' +import { LoadLocalFileClient } from './LoadLocalFileClient' import loadRequest from '@ohos.request'; // 数据加载器 @@ -26,17 +26,16 @@ export class DownloadClient implements IDataFetch { private networkClient = new NetworkDownloadClient(); private localFileClient = new LoadLocalFileClient(); - loadData(request: RequestOption, onCompleteFunction, onErrorFunction) { - if(typeof request.loadSrc == 'string') { - if (request.loadSrc.startsWith(globalThis.ImageKnife.getImageKnifeContext() - .filesDir) || request.loadSrc.startsWith(globalThis.ImageKnife.getImageKnifeContext().cacheDir)) { - // 本地沙盒 - this.localFileClient.loadLocalFileData(request,onCompleteFunction,onErrorFunction) - }else{ - // 网络下载 - this.networkClient.downloadNetworkData(request,onCompleteFunction,onErrorFunction) - } + if (typeof request.loadSrc == 'string') { + if (request.loadSrc.startsWith(globalThis.ImageKnife.getImageKnifeContext() + .filesDir) || request.loadSrc.startsWith(globalThis.ImageKnife.getImageKnifeContext().cacheDir)) { + // 本地沙盒 + this.localFileClient.loadData(request, onCompleteFunction, onErrorFunction) + } else { + // 网络下载 + this.networkClient.loadData(request, onCompleteFunction, onErrorFunction) } + } } } \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/IDataFetch.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/IDataFetch.ets index 4a3340b..019d763 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/IDataFetch.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/IDataFetch.ets @@ -13,9 +13,9 @@ * limitations under the License. */ -import {RequestOption} from "../RequestOption" +import { RequestOption } from '../RequestOption' // 资源加载接口 export interface IDataFetch { - loadData(request: RequestOption, onCompleteFunction, onErrorFunction); + loadData(request: RequestOption, onComplete: (img: ArrayBuffer) => void, onError: (err: string) => void); } \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets index 0218b77..4998b72 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/LoadLocalFileClient.ets @@ -13,20 +13,20 @@ * limitations under the License. */ -import { IDataFetch } from "../networkmanage/IDataFetch" -import { RequestOption } from "../RequestOption" -import { Md5 } from "../../cache/Md5" -import { FileUtils } from "../../cache/FileUtils" +import { IDataFetch } from '../networkmanage/IDataFetch' +import { RequestOption } from '../RequestOption' +import { Md5 } from '../../cache/Md5' +import { FileUtils } from '../../cache/FileUtils' import loadRequest from '@ohos.request'; export class LoadLocalFileClient { - loadLocalFileData(request: RequestOption, onCompleteFunction, onErrorFunction) { - if(typeof request.loadSrc == 'string') { - let fileBuffer = FileUtils.getInstance().readFilePic(request.loadSrc) - if(fileBuffer == null || fileBuffer.byteLength <=0){ - onErrorFunction('LoadLocalFileClient loadLocalFileData The File Does Not Exist!Check The File!') - }else{ - onCompleteFunction(fileBuffer); + loadData(request: RequestOption, onComplete: (img: ArrayBuffer) => void, onError: (err: string) => void) { + if (typeof request.loadSrc == 'string') { + let fileBuffer = FileUtils.getInstance().readFilePic(request.loadSrc) + if (fileBuffer == null || fileBuffer.byteLength <= 0) { + onError('LoadLocalFileClient loadLocalFileData The File Does Not Exist!Check The File!') + } else { + onComplete(fileBuffer); } } } diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets index a848e56..d7b33c5 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets @@ -13,15 +13,15 @@ * limitations under the License. */ -import { IDataFetch } from "../networkmanage/IDataFetch" -import { RequestOption } from "../RequestOption" -import { Md5 } from "../../cache/Md5" -import { FileUtils } from "../../cache/FileUtils" +import { IDataFetch } from '../networkmanage/IDataFetch' +import { RequestOption } from '../RequestOption' +import { Md5 } from '../../cache/Md5' +import { FileUtils } from '../../cache/FileUtils' import loadRequest from '@ohos.request'; // 数据加载器 -export class NetworkDownloadClient { - downloadNetworkData(request: RequestOption, onCompleteFunction, onErrorFunction) { +export class NetworkDownloadClient { + loadData(request: RequestOption, onComplete: (img: ArrayBuffer) => void, onError: (err: string) => void) { let filename = Md5.hashStr(request.generateDataKey); let downloadFolder = request.getFilesPath() + "/" + request.networkCacheFolder; let allpath = request.getFilesPath() + "/" + request.networkCacheFolder + "/" + filename + ".img"; @@ -42,7 +42,7 @@ export class NetworkDownloadClient { loadTask = downloadTask; loadTask.on('progress', (receivedSize, totalSize) => { - if(totalSize > 0) { + if (totalSize > 0) { // 并不是所有服务器都会返回totalSize 当没有文件大小的时候,下载进度没有百分比回调,只能知道目前下载了多少数据量 let percent = Math.round(((receivedSize * 1.0) / (totalSize * 1.0)) * 100) if (request.progressFunc) { @@ -55,7 +55,7 @@ export class NetworkDownloadClient { let downloadPath = allpath; request.downloadFilePath = downloadPath; let arraybuffer = FileUtils.getInstance().readFilePic(downloadPath) - onCompleteFunction(arraybuffer); + onComplete(arraybuffer); FileUtils.getInstance().deleteFile(downloadPath); loadTask.off('complete', () => { @@ -83,7 +83,7 @@ export class NetworkDownloadClient { }) loadTask.on('fail', (err) => { - onErrorFunction('NetworkDownloadClient Download task fail err =' + err) + onError('NetworkDownloadClient Download task fail err =' + err) if (loadTask) { loadTask.remove().then(result => { loadTask.off('complete', () => { @@ -109,10 +109,11 @@ export class NetworkDownloadClient { }) } else { - onErrorFunction('NetworkDownloadClient downloadTask dismiss!') + onError('NetworkDownloadClient downloadTask dismiss!') } - }).catch((err) => { - onErrorFunction(err) + }) + .catch((err) => { + onError("下载子系统download错误捕获,error="+err.message); }) } } \ No newline at end of file diff --git a/imageknife/src/main/ets/components/imageknife/requestmanage/RequestManager.ets b/imageknife/src/main/ets/components/imageknife/requestmanage/RequestManager.ets index 0a9a3a8..5ffb29d 100644 --- a/imageknife/src/main/ets/components/imageknife/requestmanage/RequestManager.ets +++ b/imageknife/src/main/ets/components/imageknife/requestmanage/RequestManager.ets @@ -190,7 +190,10 @@ export class RequestManager { let success = (arraybuffer) => { this.downloadSuccess(arraybuffer, onComplete, onError) } - this.mIDataFetch.loadData(request, success, onError); + let error = (errorMsg:string) =>{ + onError(errorMsg) + } + this.mIDataFetch.loadData(request, success, error); } // 加载本地资源 From dc9dd9790321d072c5df9fe8cd737f0bd2f5b4a1 Mon Sep 17 00:00:00 2001 From: zhoulisheng1 Date: Tue, 10 Jan 2023 00:05:10 -0800 Subject: [PATCH 4/5] =?UTF-8?q?1.=E6=9B=BF=E6=8D=A2=E6=9C=89=E7=89=88?= =?UTF-8?q?=E6=9D=83=E5=9B=BE=E7=89=87url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoulisheng1 --- entry/src/main/ets/pages/index.ets | 2 +- entry/src/main/ets/pages/testGifDontAnimatePage.ets | 4 ++-- .../main/ets/pages/testImageKnifeOptionChangedPage.ets | 2 +- entry/src/main/ets/pages/testPreloadPage.ets | 8 ++++---- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/entry/src/main/ets/pages/index.ets b/entry/src/main/ets/pages/index.ets index d3a0cc4..9a3b3f5 100644 --- a/entry/src/main/ets/pages/index.ets +++ b/entry/src/main/ets/pages/index.ets @@ -61,7 +61,7 @@ struct IndexFunctionDemo { Button("加载GIF") .onClick(() => { this.imageKnifeOption2 = { - loadSrc: 'https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700', + loadSrc: 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658', placeholderSrc: $r('app.media.icon_loading'), errorholderSrc: $r('app.media.icon_failed'), diff --git a/entry/src/main/ets/pages/testGifDontAnimatePage.ets b/entry/src/main/ets/pages/testGifDontAnimatePage.ets index b9ec490..551dffc 100644 --- a/entry/src/main/ets/pages/testGifDontAnimatePage.ets +++ b/entry/src/main/ets/pages/testGifDontAnimatePage.ets @@ -58,7 +58,7 @@ struct TestGifDontAnimatePage { Button('网络资源gif') .onClick(()=>{ this.imageKnifeOption1 = { - loadSrc: 'https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700', + loadSrc: 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658', placeholderSrc: $r('app.media.icon_loading'), errorholderSrc: $r('app.media.icon_failed'), }; @@ -66,7 +66,7 @@ struct TestGifDontAnimatePage { Button('网络资源gif静态') .onClick(()=>{ this.imageKnifeOption1 = { - loadSrc: 'https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700', + loadSrc: 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658', placeholderSrc: $r('app.media.icon_loading'), errorholderSrc: $r('app.media.icon_failed'), dontAnimateFlag:true diff --git a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets index a0a31b3..3ca6d1e 100644 --- a/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets +++ b/entry/src/main/ets/pages/testImageKnifeOptionChangedPage.ets @@ -150,7 +150,7 @@ struct TestImageKnifeOptionChangedPage { Button('gif') .onClick(()=>{ this.imageKnifeOption1 = { - loadSrc: 'https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700', + loadSrc: 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658', placeholderSrc: $r('app.media.icon_loading'), errorholderSrc: $r('app.media.icon_failed') diff --git a/entry/src/main/ets/pages/testPreloadPage.ets b/entry/src/main/ets/pages/testPreloadPage.ets index b7cf66d..eb8ca3d 100644 --- a/entry/src/main/ets/pages/testPreloadPage.ets +++ b/entry/src/main/ets/pages/testPreloadPage.ets @@ -148,7 +148,7 @@ struct TestPreloadPage { Button('预加载网络资源gif') .onClick(() => { let request = new RequestOption(); - request.load('https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700') + request.load('https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658') .setImageViewSize({ width: 300, height: 300 }) .addListener((err, data) => { if (err && err.length > 0) { @@ -166,7 +166,7 @@ struct TestPreloadPage { Button('网络资源gif') .onClick(() => { this.imageKnifeOption1 = { - loadSrc: 'https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700', + loadSrc: 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658', placeholderSrc: $r('app.media.icon_loading'), errorholderSrc: $r('app.media.icon_failed'), @@ -179,7 +179,7 @@ struct TestPreloadPage { Button('预加载网络资源gif静态') .onClick(() => { let request = new RequestOption(); - request.load('https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700') + request.load('https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658') .setImageViewSize({ width: 300, height: 300 }) .dontAnimate() .addListener((err, data) => { @@ -198,7 +198,7 @@ struct TestPreloadPage { Button('网络资源gif静态') .onClick(() => { this.imageKnifeOption1 = { - loadSrc: 'https://pic.ibaotu.com/gif/18/17/16/51u888piCtqj.gif!fwpaa70/fw/700', + loadSrc: 'https://gd-hbimg.huaban.com/e0a25a7cab0d7c2431978726971d61720732728a315ae-57EskW_fw658', placeholderSrc: $r('app.media.icon_loading'), errorholderSrc: $r('app.media.icon_failed'), From 5c3e35da4ef96b6a57f36480abf3ca3903ecea6a Mon Sep 17 00:00:00 2001 From: zhoulisheng1 Date: Sun, 15 Jan 2023 17:39:59 -0800 Subject: [PATCH 5/5] 1.delete unused params "desc" Signed-off-by: zhoulisheng1 --- .../imageknife/networkmanage/NetworkDownloadClient.ets | 1 - 1 file changed, 1 deletion(-) diff --git a/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets b/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets index d7b33c5..e001c50 100644 --- a/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets +++ b/imageknife/src/main/ets/components/imageknife/networkmanage/NetworkDownloadClient.ets @@ -31,7 +31,6 @@ export class NetworkDownloadClient { if (FileUtils.getInstance().exist(allpath)) { FileUtils.getInstance().deleteFile(allpath) } - let desc = filename + ".img"; var downloadConfig = { url: (request.loadSrc as string), filePath: allpath,