feat: set theme variable

This commit is contained in:
Fine 2023-11-09 10:20:33 +08:00
parent 6fd48b7b2a
commit 9f4bdf3286
10 changed files with 49 additions and 9 deletions

View File

@ -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[]) {

View File

@ -36,6 +36,7 @@ interface AppState {
isMobile: boolean;
reloadTimer: Nullable<IntervalHandle>;
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;

View File

@ -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;
}

View File

@ -15,7 +15,7 @@ limitations under the License. -->
<template>
<div class="content-wrapper flex-v">
<div class="title">Task Timeline</div>
<el-popover placement="bottom" trigger="click" :width="100" v-if="dashboardStore.editMode">
<el-popover placement="bottom" trigger="click" :width="100" v-if="dashboardStore.editMode" :effect="appStore.theme">
<template #reference>
<span class="operation cp">
<Icon iconName="ellipsis_v" size="middle" />
@ -32,6 +32,7 @@ limitations under the License. -->
import type { PropType } from "vue";
import { useI18n } from "vue-i18n";
import { useDashboardStore } from "@/store/modules/dashboard";
import { useAppStoreWithOut } from "@/store/modules/app";
import Content from "../related/task-timeline/Content.vue";
/*global defineProps */
@ -45,6 +46,7 @@ limitations under the License. -->
});
const { t } = useI18n();
const dashboardStore = useDashboardStore();
const appStore = useAppStoreWithOut();
function removeWidget() {
dashboardStore.removeControls(props.data);

View File

@ -15,7 +15,13 @@ limitations under the License. -->
<template>
<div class="text">
<div class="header">
<el-popover placement="bottom" trigger="click" :width="100" v-if="dashboardStore.editMode">
<el-popover
placement="bottom"
trigger="click"
:width="100"
v-if="dashboardStore.editMode"
:effect="appStore.theme"
>
<template #reference>
<span>
<Icon iconName="ellipsis_v" size="middle" class="operation" />
@ -55,6 +61,7 @@ limitations under the License. -->
import { useI18n } from "vue-i18n";
import { useDashboardStore } from "@/store/modules/dashboard";
import { TextColors } from "@/views/dashboard/data";
import { useAppStoreWithOut } from "@/store/modules/app";
/*global defineProps */
const props = defineProps({
@ -67,6 +74,7 @@ limitations under the License. -->
const { t } = useI18n();
const graph = computed(() => props.data.graph || {});
const dashboardStore = useDashboardStore();
const appStore = useAppStoreWithOut();
function removeTopo() {
dashboardStore.removeControls(props.data);

View File

@ -15,7 +15,13 @@ limitations under the License. -->
<template>
<div class="text">
<div class="header">
<el-popover placement="bottom" trigger="click" :width="100" v-if="dashboardStore.editMode">
<el-popover
placement="bottom"
trigger="click"
:width="100"
v-if="dashboardStore.editMode"
:effect="appStore.theme"
>
<template #reference>
<span>
<Icon iconName="ellipsis_v" size="middle" class="operation" />
@ -47,6 +53,7 @@ limitations under the License. -->
import type { PropType } from "vue";
import { useI18n } from "vue-i18n";
import { useDashboardStore } from "@/store/modules/dashboard";
import { useAppStoreWithOut } from "@/store/modules/app";
/*global defineProps */
const props = defineProps({
@ -58,6 +65,7 @@ limitations under the License. -->
});
const { t } = useI18n();
const dashboardStore = useDashboardStore();
const appStore = useAppStoreWithOut();
const widget = computed(() => props.data.widget || {});
function removeTopo() {

View File

@ -15,7 +15,13 @@ limitations under the License. -->
<template>
<div class="time-range">
<div class="header">
<el-popover placement="bottom" trigger="click" :width="100" v-if="dashboardStore.editMode">
<el-popover
placement="bottom"
trigger="click"
:width="100"
v-if="dashboardStore.editMode"
:effect="appStore.theme"
>
<template #reference>
<span>
<Icon iconName="ellipsis_v" size="middle" class="operation" />

View File

@ -15,7 +15,13 @@ limitations under the License. -->
<template>
<div class="topology flex-v">
<div class="operation">
<el-popover placement="bottom" trigger="click" :width="100" v-if="dashboardStore.editMode">
<el-popover
placement="bottom"
trigger="click"
:width="100"
v-if="dashboardStore.editMode"
:effect="appStore.theme"
>
<template #reference>
<span>
<Icon iconName="ellipsis_v" size="middle" />
@ -37,6 +43,7 @@ limitations under the License. -->
import { useI18n } from "vue-i18n";
import { useDashboardStore } from "@/store/modules/dashboard";
import Topology from "../related/topology/Index.vue";
import { useAppStoreWithOut } from "@/store/modules/app";
/*global defineProps */
const props = defineProps({
@ -48,6 +55,7 @@ limitations under the License. -->
});
const { t } = useI18n();
const dashboardStore = useDashboardStore();
const appStore = useAppStoreWithOut();
function removeTopo() {
dashboardStore.removeControls(props.data);

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. -->
<template>
<div class="trace-wrapper flex-v">
<el-popover placement="bottom" trigger="click" :width="100" v-if="dashboardStore.editMode">
<el-popover placement="bottom" trigger="click" :width="100" v-if="dashboardStore.editMode" :effect="appStore.theme">
<template #reference>
<span class="delete cp">
<Icon iconName="ellipsis_v" size="middle" class="operation" />
@ -41,6 +41,7 @@ limitations under the License. -->
import TraceDetail from "../related/trace/Detail.vue";
import { useI18n } from "vue-i18n";
import { useDashboardStore } from "@/store/modules/dashboard";
import { useAppStoreWithOut } from "@/store/modules/app";
/*global defineProps */
const props = defineProps({
@ -54,6 +55,7 @@ limitations under the License. -->
provide("options", props.data);
const { t } = useI18n();
const dashboardStore = useDashboardStore();
const appStore = useAppStoreWithOut();
function removeWidget() {
dashboardStore.removeControls(props.data);
}

View File

@ -26,7 +26,7 @@ limitations under the License. -->
<Icon iconName="info_outline" size="sm" class="operation" v-show="widget.tips" />
</span>
</el-tooltip>
<el-popover placement="bottom" trigger="click" :width="100">
<el-popover placement="bottom" trigger="click" :width="100" :effect="appStore.theme">
<template #reference>
<span>
<Icon iconName="ellipsis_v" size="middle" class="operation" />