Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore(frontend): performance optimization (part.3) (#12717)
Liu Jiaff494189300
diff --git a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.tsindex 25c0a3d3f1..8bd71239df 100644--- a/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts+++ b/frontend/src/components/AdvancedSearch/useCommonSearchScopeOptions.ts@@ -55,8 +55,8 @@ export const useCommonSearchScopeOptions = (// fullScopeOptions provides full search scopes and options.// we need this as the source of truth.const fullScopeOptions = computed((): ScopeOption[] => {- const scopes: ScopeOption[] = [- {+ const scopeCreators = {+ project: () => ({id: "project",title: t("issue.advanced-search.scope.project.title"),description: t("issue.advanced-search.scope.project.description"),@@ -76,8 +76,8 @@ export const useCommonSearchScopeOptions = (},};}),- },- {+ }),+ instance: () => ({id: "instance",title: t("issue.advanced-search.scope.instance.title"),description: t("issue.advanced-search.scope.instance.description"),@@ -104,8 +104,8 @@ export const useCommonSearchScopeOptions = (},};}),- },- {+ }),+ database: () => ({id: "database",title: t("issue.advanced-search.scope.database.title"),description: t("issue.advanced-search.scope.database.description"),@@ -133,8 +133,8 @@ export const useCommonSearchScopeOptions = (},};}),- },- {+ }),+ environment: () => ({id: "environment",title: t("issue.advanced-search.scope.environment.title"),description: t("issue.advanced-search.scope.environment.description"),@@ -149,8 +149,8 @@ export const useCommonSearchScopeOptions = (}),};}),- },- {+ }),+ ["project-assigned"]: () => ({id: "project-assigned",title: t("issue.advanced-search.scope.project-assigned.title"),description: t(@@ -174,11 +174,17 @@ export const useCommonSearchScopeOptions = (),},],- },- ];- return scopes.filter((scope) =>- unref(supportOptionIdList).includes(scope.id)- );+ }),+ } as Record<SearchScopeId, () => ScopeOption>;++ const scopes: ScopeOption[] = [];+ unref(supportOptionIdList).forEach((id) => {+ const create = scopeCreators[id];+ if (create) {+ scopes.push(create());+ }+ });+ return scopes;});// filteredScopeOptions will filter search options by chosen scope.diff --git a/frontend/src/components/ProvideDashboardContext.vue b/frontend/src/components/ProvideDashboardContext.vueindex 48b84c397e..d552bd4163 100644--- a/frontend/src/components/ProvideDashboardContext.vue+++ b/frontend/src/components/ProvideDashboardContext.vue@@ -13,6 +13,7 @@<script lang="ts" setup>import { NSpin } from "naive-ui";import { ref, onMounted } from "vue";+import { onUnmounted } from "vue";import { useRoute, useRouter } from "vue-router";import {useEnvironmentV1Store,@@ -65,6 +66,7 @@ const fetchInstancesAndDatabases = async (project: string) => {instanceAndDatabaseInitialized.add(project || "");};+let unregisterBeforeEachHook: (() => void) | undefined;onMounted(async () => {await router.isReady();@@ -89,7 +91,7 @@ onMounted(async () => {isInitializing.value = false;- router.beforeEach((to, from, next) => {+ unregisterBeforeEachHook = router.beforeEach((to, from, next) => {const fromProject = from.params.projectId as string;const toProject = to.params.projectId as string;if (fromProject !== toProject) {@@ -108,4 +110,8 @@ onMounted(async () => {next();});});++onUnmounted(() => {+ unregisterBeforeEachHook && unregisterBeforeEachHook();+});</script>diff --git a/frontend/src/store/modules/v1/instance.ts b/frontend/src/store/modules/v1/instance.tsindex 962421cf10..3d64c5115d 100644--- a/frontend/src/store/modules/v1/instance.ts+++ b/frontend/src/store/modules/v1/instance.ts@@ -50,12 +50,12 @@ export const useInstanceV1Store = defineStore("instance_v1", () => {// Actionsconst upsertInstances = async (list: Instance[]) => {- const composedInstances: ComposedInstance[] = [];- for (let i = 0; i < list.length; i++) {- const composed = await composeInstance(list[i]);+ const composedInstances = await Promise.all(+ list.map((instance) => composeInstance(instance))+ );+ composedInstances.forEach((composed) => {instanceMapByName.set(composed.name, composed);- composedInstances.push(composed);- }+ });return composedInstances;};const fetchInstanceList = async (showDeleted = false, parent?: string) => {