From 677ea733370b59f51f060903639e71537c0adfff Mon Sep 17 00:00:00 2001 From: zgf Date: Thu, 6 Feb 2025 15:56:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=A4=B1=E8=B4=A5=E5=90=84=E7=A7=8D=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E4=BF=A1=E6=81=AF=E6=A0=B7=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zgf --- .../main/ets/pages/ErrorMessageDownload.ets | 93 +++++++++++++++++++ entry/src/main/ets/pages/Index.ets | 5 + .../main/resources/base/element/string.json | 4 + .../resources/base/profile/main_pages.json | 3 +- .../main/resources/zh_CN/element/string.json | 4 + 5 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 entry/src/main/ets/pages/ErrorMessageDownload.ets diff --git a/entry/src/main/ets/pages/ErrorMessageDownload.ets b/entry/src/main/ets/pages/ErrorMessageDownload.ets new file mode 100644 index 0000000..f8bf15e --- /dev/null +++ b/entry/src/main/ets/pages/ErrorMessageDownload.ets @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2024 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 { ImageKnifeComponent } from '@ohos/libraryimageknife' +@Entry +@Component +struct ErrorMessageDownload { + @State httpCode: string = '' + @State httpError: string = '' + @State storageError: string = '' + @State fileError: string = '' + @State notPic: string = '' + build() { + Column() { + Text(this.httpCode) + ImageKnifeComponent({ + imageKnifeOption:{ + loadSrc:'https://gitee.com/openharmony-tpc/ImageKnife/issues/1111111', + errorholderSrc:$r('app.media.failed'), + onLoadListener:{ + onLoadFailed:(err)=>{ + this.httpCode = err + } + } + } + }).width(100).height(100).margin({bottom:10}) + + Text(this.httpError) + ImageKnifeComponent({ + imageKnifeOption:{ + loadSrc:'https://xx.xx.xx', + errorholderSrc:$r('app.media.failed'), + onLoadListener:{ + onLoadFailed:(err)=>{ + this.httpError = err + } + } + } + }).width(100).height(100).margin({bottom:10}) + + Text(this.storageError) + ImageKnifeComponent({ + imageKnifeOption:{ + loadSrc:'/data/storage/el2/base/haps/entry/cache/a/b', + errorholderSrc:$r('app.media.failed'), + onLoadListener:{ + onLoadFailed:(err)=>{ + this.storageError = err + } + } + } + }).width(100).height(100).margin({bottom:10}) + + Text(this.fileError) + ImageKnifeComponent({ + imageKnifeOption:{ + loadSrc:'file://xx.xx.xx', + errorholderSrc:$r('app.media.failed'), + onLoadListener:{ + onLoadFailed:(err)=>{ + this.fileError = err + } + } + } + }).width(100).height(100).margin({bottom:10}) + + Text(this.notPic) + ImageKnifeComponent({ + imageKnifeOption:{ + loadSrc:'xx.xx.xx', + errorholderSrc:$r('app.media.failed'), + onLoadListener:{ + onLoadFailed:(err)=>{ + this.notPic = err + } + } + } + }).width(100).height(100).margin({bottom:10}) + } + } +} \ No newline at end of file diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets index b3ab212..9707118 100644 --- a/entry/src/main/ets/pages/Index.ets +++ b/entry/src/main/ets/pages/Index.ets @@ -88,6 +88,11 @@ struct Index { }); }) + Button($r('app.string.Error_Message')).margin({top:10}).onClick(()=>{ + router.push({ + uri: 'pages/ErrorMessageDownload', + }); + }) Button($r('app.string.Test_custom_download')).margin({top:10}).onClick(()=>{ router.push({ uri: 'pages/TestSetCustomImagePage', diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 19d4cfc..f2cea47 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -683,6 +683,10 @@ { "name": "Multiple_CallBack", "value": "Multiple image callback" + }, + { + "name": "Error_Message", + "value": "error message" } ] } \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index 54d8b21..d0370e7 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -41,6 +41,7 @@ "pages/AutoImageFit", "pages/SingleImageCallBack", "pages/MultipleImageCallBack", - "pages/LocalImage" + "pages/LocalImage", + "pages/ErrorMessageDownload" ] } \ No newline at end of file diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index d65db7d..6ae55b3 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -675,6 +675,10 @@ { "name": "Multiple_CallBack", "value": "多张图片回调" + }, + { + "name": "Error_Messgae", + "value": "错误信息" } ] } \ No newline at end of file From 996fc5c909fab5493fde8d00ae6124bc9412fcbb Mon Sep 17 00:00:00 2001 From: zgf Date: Thu, 6 Feb 2025 08:16:36 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=A4=B1=E8=B4=A5=E5=90=84=E7=A7=8D=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E4=BF=A1=E6=81=AF=E6=A0=B7=E4=BE=8B=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=9B=BE=E7=89=87=E4=B8=8B=E8=BD=BD=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E5=90=84=E7=A7=8D=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF=E6=A0=B7?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zgf --- entry/src/main/resources/zh_CN/element/string.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entry/src/main/resources/zh_CN/element/string.json b/entry/src/main/resources/zh_CN/element/string.json index 6ae55b3..265b743 100644 --- a/entry/src/main/resources/zh_CN/element/string.json +++ b/entry/src/main/resources/zh_CN/element/string.json @@ -677,7 +677,7 @@ "value": "多张图片回调" }, { - "name": "Error_Messgae", + "name": "Error_Message", "value": "错误信息" } ]