diff --git a/packages/url_launcher/url_launcher_ohos/ohos/src/main/ets/components/plugin/UrlLauncher.ets b/packages/url_launcher/url_launcher_ohos/ohos/src/main/ets/components/plugin/UrlLauncher.ets index a2ad29ee560874410a5a48cebef05c0ad865928e..d1d21f2f4c645bb49bd6f0bad61211a0a915db6d 100644 --- a/packages/url_launcher/url_launcher_ohos/ohos/src/main/ets/components/plugin/UrlLauncher.ets +++ b/packages/url_launcher/url_launcher_ohos/ohos/src/main/ets/components/plugin/UrlLauncher.ets @@ -161,15 +161,15 @@ export class UrlLauncher implements UrlLauncherApi { // 只支持沙箱路径 launchFile(url: string): boolean { let fileUrl = this.parseUrl(url, UrlLauncher.LAUNCH_TYPE_FILE + '://'); - let filePath = this.context.filesDir + fileUrl; // 将沙箱路径转换为uri - let uriFromPath = fileuri.getUriFromPath(filePath); + let uriFromPath = fileuri.getUriFromPath(fileUrl); + let decodedPath = decodeURIComponent(uriFromPath); Log.d(TAG, 'launchFile:' + fileUrl + ' uriFromPath:' + uriFromPath); let want: Want = { flags: wantConstant.Flags.FLAG_AUTH_WRITE_URI_PERMISSION | wantConstant.Flags.FLAG_AUTH_READ_URI_PERMISSION, // 配置分享应用的隐式拉起规则 action: 'ohos.want.action.viewData', - uri: uriFromPath, + uri: decodedPath, } this.context.startAbility(want) .then(() => {