From 310fff4b2883fab4fb5fd9d6a126a7bc1b1ece07 Mon Sep 17 00:00:00 2001 From: Fine0830 Date: Tue, 19 Sep 2023 17:47:59 +0800 Subject: [PATCH] fix: independent widget duration (#319) --- src/views/dashboard/Widget.vue | 4 +++- src/views/dashboard/components/WidgetLink.vue | 15 +++++++-------- vite.config.ts | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/views/dashboard/Widget.vue b/src/views/dashboard/Widget.vue index 0b8acaf8..6adb996c 100644 --- a/src/views/dashboard/Widget.vue +++ b/src/views/dashboard/Widget.vue @@ -87,10 +87,12 @@ limitations under the License. --> dashboardStore.setLayer(route.params.layer); dashboardStore.setEntity(route.params.entity); const { auto, autoPeriod } = config.value; - if (auto) { await setDuration(); appStoreWithOut.setReloadTimer(setInterval(setDuration, autoPeriod * 1000)); + } else { + const duration = JSON.parse(route.params.duration as string); + appStoreWithOut.setDuration(duration); } await setSelector(); await queryMetrics(); diff --git a/src/views/dashboard/components/WidgetLink.vue b/src/views/dashboard/components/WidgetLink.vue index 6a6b6c85..3660c504 100644 --- a/src/views/dashboard/components/WidgetLink.vue +++ b/src/views/dashboard/components/WidgetLink.vue @@ -20,14 +20,9 @@ limitations under the License. -->
- +
-
+
@@ -72,6 +67,7 @@ limitations under the License. --> const auto = ref(true); const period = ref(6); const freshOpt = ref(RefreshOptions[0].value); + const duration = ref(JSON.parse(JSON.stringify([appStore.durationRow.start, appStore.durationRow.end]))); function changeTimeRange(val: Date[] | any) { dates.value = val; @@ -127,7 +123,10 @@ limitations under the License. --> tips: encodeURIComponent(widget.tips || ""), }; } - if (auto.value) { + if (hasDuration.value) { + opt.auto = 0; + opt.autoPeriod = 0; + } else { const f = RefreshOptions.filter((d: { value: string }) => d.value === freshOpt.value)[0] || {}; opt.auto = Number(f.value) * 60 * 1000; opt.autoPeriod = period.value; diff --git a/vite.config.ts b/vite.config.ts index f5b596eb..d27a6462 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -64,7 +64,7 @@ export default ({ mode }: ConfigEnv): UserConfig => { preprocessorOptions: { //define global scss variable scss: { - additionalData: `@import "@/styles/light.scss";`, + additionalData: `@use "@/styles/light.scss" as *;`, }, }, },