From 9f4bdf3286057537615bea7ca3dd925026e1bd2b Mon Sep 17 00:00:00 2001 From: Fine Date: Thu, 9 Nov 2023 10:20:33 +0800 Subject: [PATCH] feat: set theme variable --- src/layout/components/NavBar.vue | 3 +++ src/store/modules/app.ts | 5 +++++ src/styles/theme.scss | 2 -- src/views/dashboard/controls/TaskTimeline.vue | 4 +++- src/views/dashboard/controls/Text.vue | 10 +++++++++- src/views/dashboard/controls/ThirdPartyApp.vue | 10 +++++++++- src/views/dashboard/controls/TimeRange.vue | 8 +++++++- src/views/dashboard/controls/Topology.vue | 10 +++++++++- src/views/dashboard/controls/Trace.vue | 4 +++- src/views/dashboard/controls/Widget.vue | 2 +- 10 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/layout/components/NavBar.vue b/src/layout/components/NavBar.vue index d49f4e7f..7d85a69d 100644 --- a/src/layout/components/NavBar.vue +++ b/src/layout/components/NavBar.vue @@ -100,10 +100,13 @@ limitations under the License. --> if (theme.value) { root.classList.add("dark"); root.classList.remove("light"); + appStore.setTheme("dark"); } else { root.classList.add("light"); root.classList.remove("dark"); + appStore.setTheme("light"); } + console.log(appStore.theme); } function getName(list: any[]) { diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index 994e83a5..95dcf99e 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -36,6 +36,7 @@ interface AppState { isMobile: boolean; reloadTimer: Nullable; allMenus: MenuOptions[]; + theme: string; } export const appStore = defineStore({ @@ -56,6 +57,7 @@ export const appStore = defineStore({ isMobile: false, reloadTimer: null, allMenus: [], + theme: "dark", }), getters: { duration(): Duration { @@ -126,6 +128,9 @@ export const appStore = defineStore({ updateDurationRow(data: Duration) { this.durationRow = data; }, + setTheme(data: string) { + this.theme = data; + }, setUTC(utcHour: number, utcMin: number): void { this.runEventStack(); this.utcMin = utcMin; diff --git a/src/styles/theme.scss b/src/styles/theme.scss index 94474346..eb712960 100644 --- a/src/styles/theme.scss +++ b/src/styles/theme.scss @@ -27,7 +27,6 @@ html { --border-color-primary: #eee; --layout-background: #f7f9fa; --box-shadow-color: #ccc; - --el-border-color: #f7f9fa; --el-border: 1px solid #000000; } @@ -41,7 +40,6 @@ html.dark { --border-color: #262629; --border-color-primary: #4b4b52; --layout-background: #000; - --el-border-color: #4c4d4f; --box-shadow-color: #666; } diff --git a/src/views/dashboard/controls/TaskTimeline.vue b/src/views/dashboard/controls/TaskTimeline.vue index 327e9bc5..58938217 100644 --- a/src/views/dashboard/controls/TaskTimeline.vue +++ b/src/views/dashboard/controls/TaskTimeline.vue @@ -15,7 +15,7 @@ limitations under the License. -->