1.ArkTs整改16 整改entry->entryablility 整改entry->pages->model

Signed-off-by: zhoulisheng1 <zhoulisheng1@huawei.com>
This commit is contained in:
zhoulisheng1 2023-09-22 10:19:22 +08:00
parent 268d0ab3e5
commit 92824c62c2
5 changed files with 14 additions and 14 deletions

View File

@ -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 {

View File

@ -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<ImageKnifeOption> = []
@State options:Array<ImageKnifeOption> = new Array
aboutToAppear(){
this.options = this.urls.map((url)=>{
this.options = this.urls.map<ImageKnifeOption>((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 }) // 每行之间的分界线

View File

@ -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<T> implements IDataSource {
private listeners: DataChangeListener[] = [];
public totalCount(): number {
return 0;
}
public getData(index: number): any {
public getData(index: number):T | undefined {
return undefined;
}

View File

@ -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 ='';
}

View File

@ -14,7 +14,7 @@
*/
import {BasicDataSource} from './BasicDataSource'
import { Material } from './Material';
export class TestDataSource extends BasicDataSource {
export class TestDataSource extends BasicDataSource<Material> {
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];
}