3 个文件变更+54-2
@@ -669,7 +669,7 @@ export struct TrustedEvidence {
669 Stack({ alignContent: Alignment.TopEnd }) {669 Stack({ alignContent: Alignment.TopEnd }) {
670 Scroll(this.sysCaScroller) {670 Scroll(this.sysCaScroller) {
671 List() {671 List() {
672- ForEach(this.mShowSysCaPresenter.certList, (item: CertAbstractVo) => {672+ LazyForEach(this.mShowSysCaPresenter.certDataSource, (item: CertAbstractVo) => {
673 ListItem() {673 ListItem() {
674 ComponentSystem({674 ComponentSystem({
675 certAlias: item.certAlias,675 certAlias: item.certAlias,
@@ -681,8 +681,9 @@ export struct TrustedEvidence {
681 } : undefined681 } : undefined
682 })682 })
683 }683 }
684- }, (item: CertAbstractVo) => JSON.stringify(item))684+ }, (item: CertAbstractVo) => item.uri)
685 }685 }
686+ .cachedCount(10)
686 .borderRadius($r('sys.float.padding_level10'))687 .borderRadius($r('sys.float.padding_level10'))
687 .backgroundColor($r('sys.color.ohos_id_color_card_bg'))688 .backgroundColor($r('sys.color.ohos_id_color_card_bg'))
688 .scrollBar(BarState.Off)689 .scrollBar(BarState.Off)
@@ -0,0 +1,48 @@
1+/**
2+ * Copyright (c) 2025-2025 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+import { CertAbstractVo } from '../model/CertManagerVo/CertAbstractVo';
16+ 
17+export class CmCertDataSource implements IDataSource {
18+ private listeners: DataChangeListener[] = [];
19+ public originDataArray: CertAbstractVo[] = [];
20+ 
21+ public totalCount(): number {
22+ return this.originDataArray.length;
23+ }
24+ 
25+ public getData(index: number): CertAbstractVo {
26+ return this.originDataArray[index];
27+ }
28+ 
29+ registerDataChangeListener(listener: DataChangeListener): void {
30+ if (this.listeners.indexOf(listener) < 0) {
31+ this.listeners.push(listener);
32+ }
33+ }
34+ 
35+ unregisterDataChangeListener(listener: DataChangeListener): void {
36+ const pos = this.listeners.indexOf(listener);
37+ if (pos >= 0) {
38+ this.listeners.splice(pos, 1);
39+ }
40+ }
41+ 
42+ reloadData(certList: CertAbstractVo[]) {
43+ this.originDataArray = certList;
44+ this.listeners.forEach((listener) => {
45+ listener.onDataReloaded();
46+ })
47+ }
48+}
@@ -17,6 +17,7 @@ import certManagerModel from '../model/CertMangerModel';
17import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel';17import { CMModelErrorCode, CMModelOptType } from '../model/CertMangerModel';
18import { CertAbstractVo } from '../model/CertManagerVo/CertAbstractVo';18import { CertAbstractVo } from '../model/CertManagerVo/CertAbstractVo';
19import { CertInfoVo } from '../model/CertManagerVo/CertInfoVo';19import { CertInfoVo } from '../model/CertManagerVo/CertInfoVo';
20+import { CmCertDataSource } from './CmCertDataSource';
20 21 
21const TAG = 'CMShowSysCa Presenter: ';22const TAG = 'CMShowSysCa Presenter: ';
22 23 
@@ -25,6 +26,7 @@ export default class CmShowSysCaPresenter {
25 public certList: CertAbstractVo[] = [];26 public certList: CertAbstractVo[] = [];
26 public certInfo: CertInfoVo = new CertInfoVo('', '', false, '', '', '', '', '', '',27 public certInfo: CertInfoVo = new CertInfoVo('', '', false, '', '', '', '', '', '',
27 new Uint8Array(), new Map(), new Map(), new Map());28 new Uint8Array(), new Map(), new Map(), new Map());
29+ public certDataSource: CmCertDataSource = new CmCertDataSource();
28 30 
29 public static getInstance(): CmShowSysCaPresenter {31 public static getInstance(): CmShowSysCaPresenter {
30 if (CmShowSysCaPresenter.sInstance == null) {32 if (CmShowSysCaPresenter.sInstance == null) {
@@ -57,6 +59,7 @@ export default class CmShowSysCaPresenter {
57 }59 }
58 });60 });
59 this.certList = certList;61 this.certList = certList;
62+ this.certDataSource.reloadData(this.certList);
60 } else {63 } else {
61 console.error(TAG + 'updateSystemTrustedCertificateList fail,errCode is' + errCode);64 console.error(TAG + 'updateSystemTrustedCertificateList fail,errCode is' + errCode);
62 this.certList = [];65 this.certList = [];