Skip to content

Commit 7e6b031

Browse files
SWangHashSWangHash
authored andcommitted
!112 merge fix/ohos-browser-fallback into main
fix(ohos): fall back to system browser when haitai browser is not installed Created-by: qq_60134168 Commit-by: yujiangtao Merged-by: SWangHash Description: ## Summary <!-- Briefly describe what changed. --> Fixes # 修复浏览器跳转异常 ## Type and Areas Type: <!-- Feature / bug fix / regression fix / refactor / UI/UX / docs / test / CI / dependency / other. --> Areas: <!-- Rust core, desktop/Tauri, web UI, mobile web, server/relay, AI adapters, installer, docs, etc. --> ## Motivation / Impact <!-- What problem does this solve, and what changes for users or developers? Write "No direct user-facing change" if applicable. --> ## Verification <!-- List exact commands, manual checks, and outcomes. For docs-only or template-only changes, use the lightest relevant checks or explain why runtime checks were skipped. --> ## Reviewer Notes <!-- Optional: screenshots, architecture notes, compatibility risks, migration notes, or rollback guidance. --> ## Checklist - [ ] This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts. - [ ] Relevant verification is recorded above, or skipped checks are explained. - [ ] User-facing strings, docs, and locales are updated where applicable. See merge request: OpenHarmonyPCDeveloper/BitFun!112
2 parents ae04807 + 1015cfa commit 7e6b031

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

‎src/apps/ohos/entry/src/main/ets/entryability/EntryAbility.ets‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,21 @@ export default class EntryAbility extends RustAbility {
270270
"uri": url
271271
}
272272
if (/^https?:\/\//i.test(url)) {
273-
want.bundleName = 'com.haitai.htbrowser';
274-
want.moduleName = 'pc_entry';
275-
want.abilityName = 'EntryAbility';
273+
try {
274+
want.bundleName = 'com.haitai.htbrowser';
275+
want.moduleName = 'pc_entry';
276+
want.abilityName = 'EntryAbility';
277+
await this.context.startAbility(want);
278+
hilog.info(201, 'vnext', `open url succeed (haitai): ${url}`);
279+
return `start ability succeed with ${url}`;
280+
} catch (haitaiError) {
281+
hilog.info(201, 'vnext', `haitai browser unavailable, falling back to system browser: ${haitaiError.code}`);
282+
want = {
283+
"action": "ohos.want.action.viewData",
284+
"entities": ["entity.system.browsable"],
285+
"uri": url
286+
};
287+
}
276288
}
277289
await this.context.startAbility(want);
278290
hilog.info(201, 'vnext', `open url succeed: ${url}`);

0 commit comments

Comments
 (0)