From 1f4f15757de1015cf7563f7022599eef58cc93d7 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Sun, 20 Oct 2024 03:00:55 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/layout/components/menu/index.tsx | 24 ++------------ .../src/layout/layout-framework.vue | 31 ++++++++++++++++--- .../src/router/source/framework.ts | 3 +- .../src/router/source/modules/certd.ts | 3 +- .../src/store/modules/resource.ts | 22 ++++++++----- packages/ui/certd-client/src/utils/index.ts | 4 ++- .../ui/certd-client/src/utils/util.router.ts | 25 +++++++++++++++ 7 files changed, 75 insertions(+), 37 deletions(-) create mode 100644 packages/ui/certd-client/src/utils/util.router.ts diff --git a/packages/ui/certd-client/src/layout/components/menu/index.tsx b/packages/ui/certd-client/src/layout/components/menu/index.tsx index e88e4395..4c128b18 100644 --- a/packages/ui/certd-client/src/layout/components/menu/index.tsx +++ b/packages/ui/certd-client/src/layout/components/menu/index.tsx @@ -4,6 +4,7 @@ import _ from "lodash-es"; import BScroll from "better-scroll"; import "./index.less"; import { utils } from "@fast-crud/fast-crud"; +import { routerUtils } from "/@/utils/util.router"; function useBetterScroll(enabled = true) { const bsRef = ref(null); @@ -70,27 +71,8 @@ export default defineComponent({ scroll: {} }, setup(props, ctx) { - async function open(path: any) { - if (path == null) { - return; - } - if (path.startsWith("http://") || path.startsWith("https://")) { - window.open(path); - return; - } - try { - const navigationResult = await router.push(path); - if (navigationResult) { - // 导航被阻止 - } else { - // 导航成功 (包括重新导航的情况) - } - } catch (e) { - console.error("导航失败", e); - } - } - function onSelect(item: any) { - open(item.key); + async function onSelect(item: any) { + await routerUtils.open(item.key); } const fsIcon = resolveComponent("FsIcon"); diff --git a/packages/ui/certd-client/src/layout/layout-framework.vue b/packages/ui/certd-client/src/layout/layout-framework.vue index 2e18a935..3e17c568 100644 --- a/packages/ui/certd-client/src/layout/layout-framework.vue +++ b/packages/ui/certd-client/src/layout/layout-framework.vue @@ -17,7 +17,17 @@ - + +
+ + {{ menu.title }} +
@@ -32,7 +42,7 @@ { @@ -150,6 +162,13 @@ const siteInfo = computed(() => { onMounted(async () => { await settingStore.checkUrlBound(); }); + +function menuClick(menu) { + routerUtils.open(menu.path); +} + +const { useToken } = theme; +const { token } = useToken();