he wei
5 天以前 3c3576d5792bfabcef84979757ee344712e71cd3
src/components/echarts/BaseChart.vue
@@ -2,14 +2,24 @@
import * as echarts from "echarts";
import "./transparent";
import { onMounted, onBeforeUnmount, ref, nextTick } from "vue";
import eventBus from "@/utils/eventBus";
let chart_instance = null;
let exportChart_instance = null;
const chart = ref(null);
const exportChart = ref(null);
const fullScreenFlag = ref(false);
const emit = defineEmits(["click"]);
const emit = defineEmits(["click", "update:fullFlag"]);
const props = defineProps({
  fullFlag: {
    type: Boolean,
    default: false,
  }
});
const fullScreenFlag = ref(props.fullFlag);
  onMounted(() => {
@@ -24,10 +34,20 @@
    });
    window.addEventListener("resize", resize);
    eventBus.on("toggleSiteList", () => {
      console.log('toggleSiteList', '=============');
      setTimeout(() => {
        resize();
        // 因为过渡设置了0.5s,所以需要等待0.5s后再resize
      }, 500);
    });
  });
  onBeforeUnmount(() => {
    window.removeEventListener("resize", resize);
    eventBus.off("toggleSiteList");
    dispose();
  });
@@ -43,6 +63,7 @@
  function fullScreen() {
    fullScreenFlag.value = !fullScreenFlag.value;
    emit("update:fullFlag", fullScreenFlag.value);
    nextTick(() => {
      resize();
    });
@@ -55,12 +76,17 @@
      option.xAxis[0].axisLine.lineStyle = {
        color: "#000",
      };
      option.xAxis[0].axisLabel.textStyle = option.xAxis[0].axisLabel.textStyle || {};
      option.xAxis[0].axisLabel.textStyle.color = "#000";
      option.yAxis[0].axisLine.lineStyle = {
        color: "#000",
      };
      option.yAxis[0].axisLabel.textStyle = option.yAxis[0].axisLabel.textStyle || {};
      option.yAxis[0].axisLabel.textStyle.color = "#000";
      option.animation = false;
      exportChart_instance.setOption(option);
      base64 = exportChart_instance.getDataURL({
        pixelRatio: 1,