From 92824c62c2b3e6178fd9cbb7286d4b752308c549 Mon Sep 17 00:00:00 2001 From: zhoulisheng1 Date: Fri, 22 Sep 2023 10:19:22 +0800 Subject: [PATCH] =?UTF-8?q?1.ArkTs=E6=95=B4=E6=94=B916=20=E6=95=B4?= =?UTF-8?q?=E6=94=B9entry->entryablility=20=E6=95=B4=E6=94=B9entry->pages-?= =?UTF-8?q?>model?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhoulisheng1 --- .../src/main/ets/entryability/CustomEngineKeyImpl.ets | 4 ++-- .../src/main/ets/pages/basicTestFeatureAbilityPage.ets | 10 +++++----- entry/src/main/ets/pages/model/BasicDataSource.ets | 4 ++-- entry/src/main/ets/pages/model/Material.ets | 6 +++--- entry/src/main/ets/pages/model/TestDataSource.ets | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/entry/src/main/ets/entryability/CustomEngineKeyImpl.ets b/entry/src/main/ets/entryability/CustomEngineKeyImpl.ets index a32b51f..58006f4 100644 --- a/entry/src/main/ets/entryability/CustomEngineKeyImpl.ets +++ b/entry/src/main/ets/entryability/CustomEngineKeyImpl.ets @@ -19,7 +19,7 @@ export class CustomEngineKeyImpl implements EngineKeyInterface { addOtherInfo: string = "Version=1.0.0;" constructor() { - this.redefineUrl = this.urlNeedClearToken.bind(this); + this.redefineUrl = this.urlNeedClearToken; } // request只读 generateMemoryCacheKey(loadSrc: string, size: string, transformed: string, dontAnimate: boolean): string { @@ -36,7 +36,7 @@ export class CustomEngineKeyImpl implements EngineKeyInterface { // 需求场景: 请求图片可能 请求中存在token需要清除, 可以把输入的url清除token后作为key的一部分,这样token发生变化也能命中缓存。 - urlNeedClearToken(url: string): string { + urlNeedClearToken = (url: string)=>{ if (this.isHttpRequest(url)) { return this.clearToken(url) } else { diff --git a/entry/src/main/ets/pages/basicTestFeatureAbilityPage.ets b/entry/src/main/ets/pages/basicTestFeatureAbilityPage.ets index ee87e56..fb31384 100644 --- a/entry/src/main/ets/pages/basicTestFeatureAbilityPage.ets +++ b/entry/src/main/ets/pages/basicTestFeatureAbilityPage.ets @@ -22,7 +22,7 @@ struct BasicTestFeatureAbilityPage { watchPathChange() { console.log("watchPathChange") } - urls=[ + urls:string[]=[ "http://e.hiphotos.baidu.com/image/pic/item/a1ec08fa513d2697e542494057fbb2fb4316d81e.jpg", "http://c.hiphotos.baidu.com/image/pic/item/30adcbef76094b36de8a2fe5a1cc7cd98d109d99.jpg", "http://h.hiphotos.baidu.com/image/pic/item/7c1ed21b0ef41bd5f2c2a9e953da81cb39db3d1d.jpg", @@ -45,10 +45,10 @@ struct BasicTestFeatureAbilityPage { "http://g.hiphotos.baidu.com/image/pic/item/6d81800a19d8bc3e770bd00d868ba61ea9d345f2.jpg", ] - @State options:Array = [] + @State options:Array = new Array aboutToAppear(){ - this.options = this.urls.map((url)=>{ + this.options = this.urls.map((url:string)=>{ return { loadSrc:url } @@ -60,11 +60,11 @@ struct BasicTestFeatureAbilityPage { Stack({ alignContent: Alignment.TopStart }) { Column() { List({ space: 20, initialIndex: 0 }) { - ForEach(this.options, (item) => { + ForEach(this.options, (item:ImageKnifeOption) => { ListItem() { ImageKnifeComponent({imageKnifeOption:item}).width(300).height(300) } - }, item => item.loadSrc) + }, (item:ImageKnifeOption )=> item.loadSrc as string) } .listDirection(Axis.Vertical) // 排列方向 .divider({ strokeWidth: 2, color: 0xFFFFFF, startMargin: 20, endMargin: 20 }) // 每行之间的分界线 diff --git a/entry/src/main/ets/pages/model/BasicDataSource.ets b/entry/src/main/ets/pages/model/BasicDataSource.ets index b6a972d..cc31787 100644 --- a/entry/src/main/ets/pages/model/BasicDataSource.ets +++ b/entry/src/main/ets/pages/model/BasicDataSource.ets @@ -12,14 +12,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -export class BasicDataSource implements IDataSource { +export class BasicDataSource implements IDataSource { private listeners: DataChangeListener[] = []; public totalCount(): number { return 0; } - public getData(index: number): any { + public getData(index: number):T | undefined { return undefined; } diff --git a/entry/src/main/ets/pages/model/Material.ets b/entry/src/main/ets/pages/model/Material.ets index ffaa7f7..dc344c5 100644 --- a/entry/src/main/ets/pages/model/Material.ets +++ b/entry/src/main/ets/pages/model/Material.ets @@ -13,7 +13,7 @@ * limitations under the License. */ export class Material{ - material_id: string; - thumbnail: string; - name: string; + material_id: string =''; + thumbnail: string = ''; + name: string =''; } \ No newline at end of file diff --git a/entry/src/main/ets/pages/model/TestDataSource.ets b/entry/src/main/ets/pages/model/TestDataSource.ets index e3c9ba4..587302e 100644 --- a/entry/src/main/ets/pages/model/TestDataSource.ets +++ b/entry/src/main/ets/pages/model/TestDataSource.ets @@ -14,7 +14,7 @@ */ import {BasicDataSource} from './BasicDataSource' import { Material } from './Material'; -export class TestDataSource extends BasicDataSource { +export class TestDataSource extends BasicDataSource { private dataArray: Material[] = [ {name:"测试CBC",thumbnail:"https://xxtool-release.zone1.meitudata.com/xxtool-pre/material/R9aT7lpEEVxawo4.jpeg!thumb-w321-webp75",material_id:"5060118818"}, {name:"通用天空1像素测试",thumbnail:"https://xxtool-release.zone1.meitudata.com/xxtool-pre/material/1V6c63lKLGPlKVo.png!thumb-w321-webp75",material_id:"506009997"}, @@ -574,7 +574,7 @@ export class TestDataSource extends BasicDataSource { return this.dataArray.length; } - public getData(index: number): any { + public getData(index: number): Material | undefined { return this.dataArray[index]; }