Toggle navigation
Toggle navigation
This project
Loading...
Sign in
developOne
/
harmonyPool
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
chenjun
2024-08-09 18:24:52 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
58dc0f0cf16ce9703737824d8dcec4bd75e11b57
58dc0f0c
1 parent
31548e02
未授权不提示失败
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
1 deletions
sight_harmony/features/wdComponent/src/main/ets/components/ImageDownloadComponent.ets
sight_harmony/features/wdComponent/src/main/ets/components/ImageDownloadComponent.ets
View file @
58dc0f0
...
...
@@ -53,8 +53,11 @@ export struct ImageDownloadComponent {
} catch (error) {
const err: BusinessError = error as BusinessError;
//console.info(`Failed to save photo. Code is ${err.code}, message is ${err.message}`);
if (this.isGranted) {
promptAction.showToast({ message: '保存图片失败!' });
}
}
}
})
}
...
...
@@ -161,11 +164,12 @@ export struct ImageDownloadComponent {
* @returns
*/
async saveImage(buffer: ArrayBuffer | string): Promise<void> {
//console.info(`cj2024 saveImage buffer ${buffer}`)
//console.info(`cj2024 saveImage buffer ${buffer}
isGranted = ${this.isGranted}
`)
if (!this.isGranted) {
//跳转权限设置
// const permissionUtil = new PermissionUtil();
PermissionUtil.reqPermissionsFromUser(['ohos.permission.READ_MEDIA'], this).then((res) => {
//console.info(`cj2024 saveImage res ${res}`)
this.isGranted = res;
});
} else {
...
...
@@ -192,7 +196,10 @@ export struct ImageDownloadComponent {
await asset.close(fd);
promptAction.showToast({ message: '已保存至相册!' });
} else {
if (this.isGranted) {
promptAction.showToast({ message: '保存图片失败!' });
}
throw new Error('Failed to create asset');
}
}
...
...
Please
register
or
login
to post a comment