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 b36a63961a462ec454531336bf6f3964d1297c83..505cbe045c4592c580f42a1c6aeb3b71317aa36a 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 @@ -150,15 +150,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(() => {