初次权限状态更新拦截

Signed-off-by: fanchenxuan <fanchenxuan@huawei.com>
This commit is contained in:
fanchenxuan 2023-11-07 15:33:28 +08:00
parent bd392ed0f0
commit 890210dc94
2 changed files with 14 additions and 0 deletions

View File

@ -128,6 +128,7 @@ struct applicationItem {
@State permissionNum: number = Constants.PERMISSION_NUM; // permission num
@State toggleIsOn: boolean[] = []; // toggle switch state array
@State isRisk: boolean[] = [];
@State isFirst: boolean[] = [];
@State applicationList: ApplicationObj[] = []; // application info array
@State searchResult: boolean = true; // search results
@Link polymorphismIsOn: Array<boolean>;
@ -182,6 +183,10 @@ struct applicationItem {
if (item.permission === undefined) {
return;
}
if (this.isFirst[item.index]) {
this.isFirst[item.index] = false;
return;
}
let _this = this;
if (isOn) {
let promises = this.list.map(it => new Promise<number>((resolve) => {
@ -366,6 +371,7 @@ struct applicationItem {
if (Number(access) === Constants.PERMISSION_INDEX) {
if (boole) {
this.toggleIsOn[i] = true;
this.isFirst[i] = true;
}
} else {
if (boole) {
@ -373,6 +379,7 @@ struct applicationItem {
}
boole = false;
this.toggleIsOn[i] = false;
this.isFirst[i] = false;
}
});
}

View File

@ -72,6 +72,7 @@ struct applicationItem {
@State permissionNum: number = Constants.PERMISSION_NUM; // permission num
@State toggleIsOn: boolean[] = []; // toggle switch state array
@State isRisk: boolean[] = [];
@State isFirst: boolean[] = [];
@State applicationList: ApplicationObj[] = []; // application info array
@State searchResult: boolean = true; // search results
@State selectedIndex: number = 0;
@ -113,6 +114,10 @@ struct applicationItem {
if (item.permission === undefined) {
return;
}
if (this.isFirst[item.index]) {
this.isFirst[item.index] = false;
return;
}
if (isOn) {
this.grantUserGrantedPermission(item.accessTokenId, item.permission, item.index);
} else {
@ -200,9 +205,11 @@ struct applicationItem {
// 0: have permission; -1: no permission
if (data === Constants.PERMISSION_INDEX) {
this.toggleIsOn[i] = true;
this.isFirst[i] = true;
this.permissionNum++;
} else {
this.toggleIsOn[i] = false;
this.isFirst[i] = false;
}
})
this.isRisk[i] = false;