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) { if (theme.value) {
root.classList.add("dark"); root.classList.add("dark");
root.classList.remove("light"); root.classList.remove("light");
appStore.setTheme("dark");
} else { } else {
root.classList.add("light"); root.classList.add("light");
root.classList.remove("dark"); root.classList.remove("dark");
appStore.setTheme("light");
} }
console.log(appStore.theme);
} }
function getName(list: any[]) { function getName(list: any[]) {

View File

@ -36,6 +36,7 @@ interface AppState {
isMobile: boolean; isMobile: boolean;
reloadTimer: Nullable<IntervalHandle>; reloadTimer: Nullable<IntervalHandle>;
allMenus: MenuOptions[]; allMenus: MenuOptions[];
theme: string;
} }
export const appStore = defineStore({ export const appStore = defineStore({
@ -56,6 +57,7 @@ export const appStore = defineStore({
isMobile: false, isMobile: false,
reloadTimer: null, reloadTimer: null,
allMenus: [], allMenus: [],
theme: "dark",
}), }),
getters: { getters: {
duration(): Duration { duration(): Duration {
@ -126,6 +128,9 @@ export const appStore = defineStore({
updateDurationRow(data: Duration) { updateDurationRow(data: Duration) {
this.durationRow = data; this.durationRow = data;
}, },
setTheme(data: string) {
this.theme = data;
},
setUTC(utcHour: number, utcMin: number): void { setUTC(utcHour: number, utcMin: number): void {
this.runEventStack(); this.runEventStack();
this.utcMin = utcMin; this.utcMin = utcMin;

View File

@ -27,7 +27,6 @@ html {
--border-color-primary: #eee; --border-color-primary: #eee;
--layout-background: #f7f9fa; --layout-background: #f7f9fa;
--box-shadow-color: #ccc; --box-shadow-color: #ccc;
--el-border-color: #f7f9fa;
--el-border: 1px solid #000000; --el-border: 1px solid #000000;
} }
@ -41,7 +40,6 @@ html.dark {
--border-color: #262629; --border-color: #262629;
--border-color-primary: #4b4b52; --border-color-primary: #4b4b52;
--layout-background: #000; --layout-background: #000;
--el-border-color: #4c4d4f;
--box-shadow-color: #666; --box-shadow-color: #666;
} }

View File

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

View File

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

View File

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

View File

@ -15,7 +15,13 @@ limitations under the License. -->
<template> <template>
<div class="time-range"> <div class="time-range">
<div class="header"> <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> <template #reference>
<span> <span>
<Icon iconName="ellipsis_v" size="middle" class="operation" /> <Icon iconName="ellipsis_v" size="middle" class="operation" />

View File

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

View File

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