From c5d80d96fbc84a34cb92d3f890b6d62e09267830 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=BB=B6=E9=BE=99?= Date: Tue, 26 Dec 2023 19:56:42 +0800 Subject: [PATCH 1/4] fix: set default route (#354) --- src/router/index.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/router/index.ts b/src/router/index.ts index 60eebf24..2cfd6c9d 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -47,7 +47,23 @@ router.beforeEach((to, from, next) => { } if (to.path === "/") { - const defaultPath = (routesLayers[0] && routesLayers[0].children[0].path) || ""; + let defaultPath = ""; + for (const route of routesLayers) { + for (const child of route.children) { + if (child.meta.activate) { + defaultPath = child.path; + break; + } + } + if (defaultPath) { + break; + } + } + + if (!defaultPath) { + defaultPath = "/marketplace"; + } + next({ path: defaultPath }); } else { next(); From 300ec27ec4cc20d885c64b4627c7b2e54708fe3b Mon Sep 17 00:00:00 2001 From: Fine0830 Date: Wed, 3 Jan 2024 19:11:37 +0800 Subject: [PATCH 2/4] feat: add `isDefault` to the dashboard configuration (#355) --- src/locales/lang/en.ts | 4 +- src/types/dashboard.d.ts | 1 + src/views/dashboard/List.vue | 113 +++++++++++++++++++++++++++++------ 3 files changed, 97 insertions(+), 21 deletions(-) diff --git a/src/locales/lang/en.ts b/src/locales/lang/en.ts index 797b463f..30622ea0 100644 --- a/src/locales/lang/en.ts +++ b/src/locales/lang/en.ts @@ -94,8 +94,8 @@ const msg = { editTab: "Enable editing tab names", label: "Service Name", id: "Service ID", - setRoot: "Set this to root", - setNormal: "Set this to normal", + setRoot: "Set Normal to Root", + setNormal: "Set Root to Normal", export: "Export Dashboard Templates", import: "Import Dashboard Templates", yes: "Yes", diff --git a/src/types/dashboard.d.ts b/src/types/dashboard.d.ts index 400ccd0b..3f6aba05 100644 --- a/src/types/dashboard.d.ts +++ b/src/types/dashboard.d.ts @@ -21,6 +21,7 @@ export type DashboardItem = { layer: string; isRoot: boolean; name: string; + isDefault: boolean; }; export interface LayoutConfig { x: number; diff --git a/src/views/dashboard/List.vue b/src/views/dashboard/List.vue index d1c372dd..25373068 100644 --- a/src/views/dashboard/List.vue +++ b/src/views/dashboard/List.vue @@ -57,14 +57,39 @@ limitations under the License. --> - + - + + + + - - - @@ -175,17 +189,19 @@ limitations under the License. --> } loading.value = true; for (const item of arr) { - const { layer, name, entity, isRoot, children } = item.configuration; + const { layer, name, entity, isRoot, children, isDefault } = item.configuration; const index = dashboardStore.dashboards.findIndex((d: DashboardItem) => d.id === item.id); const p: DashboardItem = { name: name.split(" ").join("-"), layer: layer, entity: entity, isRoot: false, + isDefault: false, }; if (index > -1) { p.id = item.id; p.isRoot = isRoot; + p.isDefault = isDefault; } dashboardStore.setCurrentDashboard(p); dashboardStore.setLayout(children); @@ -328,7 +344,7 @@ limitations under the License. --> configuration: JSON.stringify(c), }; const res = await dashboardStore.updateDashboard(setting); - if (res.data.changeTemplate.id) { + if (res.data.changeTemplate.status) { sessionStorage.setItem( key, JSON.stringify({ @@ -356,7 +372,66 @@ limitations under the License. --> configuration: JSON.stringify(c), }; const res = await dashboardStore.updateDashboard(setting); - if (res.data.changeTemplate.id) { + if (res.data.changeTemplate.status) { + sessionStorage.setItem( + key, + JSON.stringify({ + id: d.id, + configuration: c, + }), + ); + } + } + } + items.push(d); + } + dashboardStore.resetDashboards(items); + searchDashboards(1); + loading.value = false; + } + async function handleTopLevel(row: DashboardItem) { + const items: DashboardItem[] = []; + loading.value = true; + for (const d of dashboardStore.dashboards) { + if (d.id === row.id) { + d.isDefault = !row.isDefault; + const key = [d.layer, d.entity, d.name].join("_"); + const layout = sessionStorage.getItem(key) || "{}"; + const c = { + ...JSON.parse(layout).configuration, + ...d, + }; + delete c.id; + const setting = { + id: d.id, + configuration: JSON.stringify(c), + }; + + const res = await dashboardStore.updateDashboard(setting); + if (res.data.changeTemplate.status) { + sessionStorage.setItem( + key, + JSON.stringify({ + id: d.id, + configuration: c, + }), + ); + } + } else { + if (d.layer === row.layer && [EntityType[0].value].includes(d.entity) && !row.isDefault && d.isDefault) { + d.isDefault = false; + const key = [d.layer, d.entity, d.name].join("_"); + const layout = sessionStorage.getItem(key) || "{}"; + const c = { + ...JSON.parse(layout).configuration, + ...d, + }; + const setting = { + id: d.id, + configuration: JSON.stringify(c), + }; + const res = await dashboardStore.updateDashboard(setting); + if (res.data.changeTemplate.status) { sessionStorage.setItem( key, JSON.stringify({ From b5c135b8112b289118f34faa8ae642e9e33d6a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=97=E5=A4=A7?= Date: Thu, 4 Jan 2024 15:49:36 +0800 Subject: [PATCH 3/4] perf(Theme): add theme change animation (#356) --- src/layout/components/NavBar.vue | 56 ++++++++++++++++++++++++++------ src/styles/theme.scss | 24 ++++++++++++++ src/types/global.d.ts | 9 +++-- 3 files changed, 77 insertions(+), 12 deletions(-) diff --git a/src/layout/components/NavBar.vue b/src/layout/components/NavBar.vue index 51c7e96d..292d4c5c 100644 --- a/src/layout/components/NavBar.vue +++ b/src/layout/components/NavBar.vue @@ -48,8 +48,14 @@ limitations under the License. --> @input="changeTimeRange" /> UTC{{ appStore.utcHour >= 0 ? "+" : "" }}{{ `${appStore.utcHour}:${appStore.utcMin}` }} - - + + @@ -67,18 +73,18 @@ limitations under the License. -->