change theme for dowanload trace

This commit is contained in:
Fine 2025-03-10 17:31:01 +08:00
parent 39bc8069e0
commit 883cec9264

View File

@ -31,8 +31,10 @@ 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 * as d3 from "d3"; import * as d3 from "d3";
import { useAppStoreWithOut } from "@/store/modules/app";
import type { Span } from "@/types/trace"; import type { Span } from "@/types/trace";
import Graph from "./D3Graph/Index.vue"; import Graph from "./D3Graph/Index.vue";
import { Themes } from "@/constants/data";
/* global defineProps, Recordable*/ /* global defineProps, Recordable*/
const props = defineProps({ const props = defineProps({
@ -40,6 +42,7 @@ limitations under the License. -->
traceId: { type: String, default: "" }, traceId: { type: String, default: "" },
}); });
const { t } = useI18n(); const { t } = useI18n();
const appStore = useAppStoreWithOut();
const list = computed(() => Array.from(new Set(props.data.map((i: Span) => i.serviceCode)))); const list = computed(() => Array.from(new Set(props.data.map((i: Span) => i.serviceCode))));
function computedScale(i: number) { function computedScale(i: number) {
@ -58,7 +61,7 @@ limitations under the License. -->
const context: any = canvas.getContext("2d"); const context: any = canvas.getContext("2d");
canvas.width = (d3.select(".trace-list-dowanload") as Recordable)._groups[0][0].clientWidth; canvas.width = (d3.select(".trace-list-dowanload") as Recordable)._groups[0][0].clientWidth;
canvas.height = (d3.select(".trace-list-dowanload") as Recordable)._groups[0][0].clientHeight; canvas.height = (d3.select(".trace-list-dowanload") as Recordable)._groups[0][0].clientHeight;
context.fillStyle = "#fff"; context.fillStyle = appStore.theme === Themes.Dark ? "#212224" : `#fff`;
context.fillRect(0, 0, canvas.width, canvas.height); context.fillRect(0, 0, canvas.width, canvas.height);
const image = new Image(); const image = new Image();
image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(source)}`; image.src = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(source)}`;