From 90364a2cf50b0666a64a7f69fc146b41784fac19 Mon Sep 17 00:00:00 2001 From: duke Date: Mon, 20 May 2024 23:14:00 +0800 Subject: [PATCH 1/2] =?UTF-8?q?doc:=20=E5=AE=8C=E5=96=84=E5=BC=80=E6=BA=90?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E9=83=A8=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/CHANGELOG.md | 5 +++- library/src/main/ets/GlobalContext.ts | 14 ----------- library/src/main/ets/hrouter.ts | 27 +++++++++------------- library/src/main/ets/interceptorService.ts | 14 ----------- library/src/main/ets/navigationCallback.ts | 15 ------------ library/src/main/ets/postcard.ts | 15 ------------ library/src/main/ets/pretreatmenService.ts | 15 ------------ 7 files changed, 15 insertions(+), 90 deletions(-) diff --git a/library/CHANGELOG.md b/library/CHANGELOG.md index 788df84..b8871e0 100644 --- a/library/CHANGELOG.md +++ b/library/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog ## [v1.1.0] 2024.05 -- 第一版正式可用版本 \ No newline at end of file +- 第一版正式可用版本 + +## [v1.1.1] 2024.05 +- 修复因找不到路由映射地址而导致的崩溃问题 \ No newline at end of file diff --git a/library/src/main/ets/GlobalContext.ts b/library/src/main/ets/GlobalContext.ts index 4bf9cc1..8f838a3 100644 --- a/library/src/main/ets/GlobalContext.ts +++ b/library/src/main/ets/GlobalContext.ts @@ -1,17 +1,3 @@ -/* - * Copyright (C) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ // 构造单例对象 export class GlobalContext { private constructor() {} diff --git a/library/src/main/ets/hrouter.ts b/library/src/main/ets/hrouter.ts index 51697e8..18d4b20 100644 --- a/library/src/main/ets/hrouter.ts +++ b/library/src/main/ets/hrouter.ts @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - import { Postcard } from './postcard'; import { navigationWithInterceptor } from "./interceptorService" import { PretreatmentService } from './pretreatmenService' @@ -43,7 +28,13 @@ export class HRouter { } inject(postcard: Postcard) { - let rawUri = globalThis.hRouterModule.resource.getStringByNameSync("hrouter_1_"+postcard.getUri().replace(/\//g, "_1_")) + let rawUri + try { + rawUri = globalThis.hRouterModule.resource.getStringByNameSync("hrouter_1_"+postcard.getUri().replace(/\//g, "_1_")) + } catch (e) { + + } + if (rawUri) { postcard._setRawUri(rawUri) postcard.getNavigationCallback()?.onFound(postcard) @@ -60,6 +51,10 @@ export class HRouter { _navigation(postcard: Postcard) { this.inject(postcard); + if(!postcard._getRawUri()){ + postcard.getNavigationCallback()?.onLast(postcard) + return + } if (postcard.getFlags()) { router.replaceUrl({ url: postcard._getRawUri() || '', diff --git a/library/src/main/ets/interceptorService.ts b/library/src/main/ets/interceptorService.ts index 3c210b4..c9c416d 100644 --- a/library/src/main/ets/interceptorService.ts +++ b/library/src/main/ets/interceptorService.ts @@ -1,17 +1,3 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ import { Postcard } from './postcard'; import { HRouter } from "./hrouter"; import { GlobalContext } from './GlobalContext'; diff --git a/library/src/main/ets/navigationCallback.ts b/library/src/main/ets/navigationCallback.ts index 08fa7f4..6232a1d 100644 --- a/library/src/main/ets/navigationCallback.ts +++ b/library/src/main/ets/navigationCallback.ts @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - import { Postcard } from './postcard' export interface NavigationCallback { diff --git a/library/src/main/ets/postcard.ts b/library/src/main/ets/postcard.ts index cc400de..d363e87 100644 --- a/library/src/main/ets/postcard.ts +++ b/library/src/main/ets/postcard.ts @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - import { NavigationCallback } from './navigationCallback' import { PretreatmentService } from './pretreatmenService'; import { HRouter } from "./hrouter"; diff --git a/library/src/main/ets/pretreatmenService.ts b/library/src/main/ets/pretreatmenService.ts index aa3563d..4669642 100644 --- a/library/src/main/ets/pretreatmenService.ts +++ b/library/src/main/ets/pretreatmenService.ts @@ -1,18 +1,3 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - import { Postcard } from './postcard' export interface PretreatmentService { onPretreatment:(postcard:Postcard)=>boolean; -- Gitee From 875b1a88460bd3ad8fdf5a6b6d82f733bf899633 Mon Sep 17 00:00:00 2001 From: duke Date: Wed, 22 May 2024 13:40:37 +0800 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=E4=BE=9D=E8=B5=96=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=AF=BC=E8=87=B4=E8=B7=B3=E8=BD=AC=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- entry/oh-package.json5 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 index ef1b0d1..d626deb 100644 --- a/entry/oh-package.json5 +++ b/entry/oh-package.json5 @@ -6,7 +6,8 @@ "author": "", "license": "", "dependencies": { - "hrouter": "file:../library" + "hrouter": "file:../library", + "examples": "file:../examples" } } -- Gitee