Merge pull request 'projects/mescc/zhp' (#16) from projects/mescc/zhp into projects/mescc/develop
Some checks are pending
continuous-integration/drone/push Build is pending

Reviewed-on: #16
This commit is contained in:
朱菊兰 2024-05-14 08:49:23 +08:00
commit 5b33fe539c
11 changed files with 521 additions and 111 deletions

View File

@ -1,7 +1,7 @@
### ###
# @Author: zhp # @Author: zhp
# @Date: 2024-04-28 13:42:51 # @Date: 2024-04-28 13:42:51
# @LastEditTime: 2024-05-11 08:52:30 # @LastEditTime: 2024-05-13 13:30:20
# @LastEditors: zhp # @LastEditors: zhp
# @Description: # @Description:
### ###

View File

@ -8,33 +8,25 @@
<template> <template>
<chart-container class="line-chart-base"> <chart-container class="line-chart-base">
<div class="legend"> <div class="legend">
<span <span v-for="item in legend" :key="item.label" class="legend-item"
v-for="item in legend" :style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }">{{ item.label }}</span>
:key="item.label"
class="legend-item"
:style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }"
>{{ item.label }}</span
>
</div> </div>
<div <div ref="elsChart" :style="{ height: '100%',width: width}"></div>
ref="chart"
style="max-width: 50vw"
:style="{ height: vHeight + 'vh' }"
></div>
</chart-container> </chart-container>
</template> </template>
<script> <script>
import screenfull from "screenfull"; import screenfull from "screenfull";
import { debounce } from "@/utils/debounce";
import ChartContainer from "./ChartContainer.vue"; import ChartContainer from "./ChartContainer.vue";
import chartMixin from "@/mixins/chart.js"; // import chartMixin from "@/mixins/chart.js";
import * as echarts from "echarts"; import * as echarts from "echarts";
export default { export default {
name: "LineChartBase", name: "LineChartBase",
components: { components: {
ChartContainer, ChartContainer,
}, },
mixins: [chartMixin], // mixins: [chartMixin],
props: { props: {
vHeight: { vHeight: {
type: Number, type: Number,
@ -59,6 +51,7 @@ export default {
}, },
data() { data() {
return { return {
width: '100%',
isFullscreen: false, isFullscreen: false,
actualOptions: null, actualOptions: null,
options: { options: {
@ -84,11 +77,11 @@ export default {
// legend: { // legend: {
// data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine'] // data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
// }, // },
toolbox: { // toolbox: {
feature: { // feature: {
saveAsImage: {} // saveAsImage: {}
} // }
}, // },
grid: { grid: {
left: '3%', left: '3%',
right: '4%', right: '4%',
@ -366,7 +359,22 @@ export default {
}, },
}; };
}, },
computed: {
isOpen() {
return this.$store.getters.sidebar.opened
},
},
watch: { watch: {
isOpen(val) {
if (val === true) {
this.width = '99%'
this.canvasReset()
console.log(this.width)
} else {
this.watch = 100 + '%'
this.canvasReset()
}
},
/** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */ /** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */
isFullscreen(val) { isFullscreen(val) {
this.actualOptions.series.map((item) => { this.actualOptions.series.map((item) => {
@ -375,11 +383,11 @@ export default {
this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12; this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12;
this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12; this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12;
this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12; this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12;
this.initOptions(this.actualOptions); this.initChart(this.actualOptions);
}, },
series(val) { series(val) {
if (!val) { if (!val) {
this.initOptions(this.options); this.initChart(this.options);
return; return;
} }
const actualOptions = JSON.parse(JSON.stringify(this.options)); const actualOptions = JSON.parse(JSON.stringify(this.options));
@ -388,19 +396,42 @@ export default {
actualOptions.series[1].data = val?.[1]?.data || []; actualOptions.series[1].data = val?.[1]?.data || [];
actualOptions.series[1].name = val?.[1]?.name || ""; actualOptions.series[1].name = val?.[1]?.name || "";
this.actualOptions = actualOptions; this.actualOptions = actualOptions;
this.initOptions(actualOptions); this.initChart(actualOptions);
}, },
}, },
mounted() {
this.actualOptions = this.options;
this.initOptions(this.options);
if (screenfull.isEnabled) { mounted() {
screenfull.on("change", () => { // if (screenfull.isEnabled) {
this.isFullscreen = screenfull.isFullscreen; // screenfull.on("change", () => {
}); // this.isFullscreen = screenfull.isFullscreen;
// });
// }
this.actualOptions = this.options
this.canvasReset();
window.addEventListener("resize", this.canvasReset);
},
beforeDestroy() {
if (this.chart) {
this.chart.dispose();
} }
}, },
destroyed() {
window.removeEventListener("resize", this.canvasReset);
},
methods: {
canvasReset() {
debounce(() => {
this.initChart();
}, 500)();
},
initChart() {
if (this.chart) {
this.chart.dispose();
}
this.chart = echarts.init(this.$refs.elsChart);
this.chart.setOption(this.actualOptions);
},
},
}; };
</script> </script>

View File

@ -1,4 +1,3 @@
<!-- <!--
filename: LineChartBase.vue filename: LineChartBase.vue
author: liubin author: liubin
@ -9,33 +8,25 @@
<template> <template>
<chart-container class="line-chart-base"> <chart-container class="line-chart-base">
<div class="legend"> <div class="legend">
<span <span v-for="item in legend" :key="item.label" class="legend-item"
v-for="item in legend" :style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }">{{ item.label }}</span>
:key="item.label"
class="legend-item"
:style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }"
>{{ item.label }}</span
>
</div> </div>
<div <div ref="waterChart" :style="{ height: '100%',width: width}"></div>
ref="chart"
style="max-width: 50vw"
:style="{ height: vHeight + 'vh' }"
></div>
</chart-container> </chart-container>
</template> </template>
<script> <script>
import screenfull from "screenfull"; import screenfull from "screenfull";
import { debounce } from "@/utils/debounce";
import ChartContainer from "./ChartContainer.vue"; import ChartContainer from "./ChartContainer.vue";
import chartMixin from "@/mixins/chart.js"; // import chartMixin from "@/mixins/chart.js";
import * as echarts from "echarts"; import * as echarts from "echarts";
export default { export default {
name: "LineChartBase", name: "LineChartBase",
components: { components: {
ChartContainer, ChartContainer,
}, },
mixins: [chartMixin], // mixins: [chartMixin],
props: { props: {
vHeight: { vHeight: {
type: Number, type: Number,
@ -60,11 +51,12 @@ export default {
}, },
data() { data() {
return { return {
width:'',
isFullscreen: false, isFullscreen: false,
actualOptions: null, actualOptions: null,
options: { options: {
grid: { grid: {
left: "5%", left: "1%",
right: "4%", right: "4%",
bottom: "3%", bottom: "3%",
top: "15%", top: "15%",
@ -85,11 +77,11 @@ export default {
// legend: { // legend: {
// data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine'] // data: ['Email', 'Union Ads', 'Video Ads', 'Direct', 'Search Engine']
// }, // },
toolbox: { // toolbox: {
feature: { // feature: {
saveAsImage: {} // saveAsImage: {}
} // }
}, // },
grid: { grid: {
left: '3%', left: '3%',
right: '4%', right: '4%',
@ -368,19 +360,34 @@ export default {
}; };
}, },
watch: { watch: {
isOpen(val) {
// console.log(val)
if (val === true) {
console.log('ztl')
this.width = '99%'
this.canvasReset()
console.log(this.width)
} else {
this.watch = 100 + '%'
this.canvasReset()
}
},
/** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */ /** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */
isFullscreen(val) { isFullscreen(val) {
if (val === true && this.isOpen === true) {
this.width = '99%'
}
this.actualOptions.series.map((item) => { this.actualOptions.series.map((item) => {
item.barWidth = val ? 18 : 12; item.barWidth = val ? 18 : 12;
}); });
this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12; this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12;
this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12; this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12;
this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12; this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12;
this.initOptions(this.actualOptions); this.initChart(this.actualOptions);
}, },
series(val) { series(val) {
if (!val) { if (!val) {
this.initOptions(this.options); this.initChart(this.options);
return; return;
} }
const actualOptions = JSON.parse(JSON.stringify(this.options)); const actualOptions = JSON.parse(JSON.stringify(this.options));
@ -389,18 +396,45 @@ export default {
actualOptions.series[1].data = val?.[1]?.data || []; actualOptions.series[1].data = val?.[1]?.data || [];
actualOptions.series[1].name = val?.[1]?.name || ""; actualOptions.series[1].name = val?.[1]?.name || "";
this.actualOptions = actualOptions; this.actualOptions = actualOptions;
this.initOptions(actualOptions); this.initChart(actualOptions);
},
},
computed: {
isOpen() {
return this.$store.getters.sidebar.opened
}, },
}, },
mounted() { mounted() {
this.actualOptions = this.options;
this.initOptions(this.options);
if (screenfull.isEnabled) { if (screenfull.isEnabled) {
screenfull.on("change", () => { screenfull.on("change", () => {
this.isFullscreen = screenfull.isFullscreen; this.isFullscreen = screenfull.isFullscreen;
}); });
} }
this.actualOptions = this.options
this.canvasReset();
window.addEventListener("resize", this.canvasReset);
},
beforeDestroy() {
if (this.chart) {
this.chart.dispose();
}
},
destroyed() {
window.removeEventListener("resize", this.canvasReset);
},
methods: {
canvasReset() {
debounce(() => {
this.initChart();
}, 500)();
},
initChart() {
if (this.chart) {
this.chart.dispose();
}
this.chart = echarts.init(this.$refs.waterChart);
this.chart.setOption(this.actualOptions);
},
}, },
}; };
</script> </script>

View File

@ -0,0 +1,304 @@
<!--
* @Author: zhp
* @Date: 2024-05-13 14:08:51
* @LastEditTime: 2024-05-14 08:46:07
* @LastEditors: zhp
* @Description:
-->
<template>
<chart-container class="bar-chart-base">
<div class="legend">
<!-- <span v-for="item in legend" :key="item.label" class="legend-item"
:style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }">{{ item.label }}</span> -->
</div>
<div ref="gasChart" :style="{ height: '100%',width: width}"></div>
</chart-container>
</template>
<script>
import screenfull from "screenfull";
import ChartContainer from "./ChartContainer.vue";
// import chartMixin from "@/mixins/chart.js";
import { debounce } from "@/utils/debounce";
import * as echarts from "echarts";
export default {
name: "BarChartBase",
components: {
ChartContainer,
},
// mixins: [chartMixin],
props: {
vHeight: {
type: Number,
default: 38,
},
legend: {
type: Array,
required: false,
},
xAxis: {
type: Array,
required: true,
},
series: {
type: Array,
required: true,
},
in: {
type: String,
default: "",
},
},
data() {
return {
width: '100%',
isFullscreen: false,
actualOptions: null,
options: {
grid: {
left: "1%",
right: "4%",
bottom: "3%",
top: "15%",
containLabel: true,
},
tooltip: {},
xAxis: {
axisTick: {
show: false,
},
axisLine: {
lineStyle: {
color: "#4561AE",
},
},
axisLabel: {
color: "#fff",
fontSize: 12,
},
data: this.xAxis,
},
yAxis: {
name: "单位/片",
nameTextStyle: {
color: "#fff",
fontSize: 12,
},
axisTick: {
show: false,
},
axisLabel: {
color: "#fff",
fontSize: 12,
},
axisLine: {
show: true,
lineStyle: {
color: "#4561AE",
},
},
splitLine: {
lineStyle: {
color: "#4561AE",
},
},
},
series: [
{
name: "", // this.series[0].name,
type: "bar",
barWidth: 12,
itemStyle: {
borderRadius: [10, 10, 0, 0],
color: {
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: "#12f7f1", // 0%
},
{
offset: 0.35,
color: "#12f7f177", // 100%
},
{
offset: 0.75,
color: "#12f7f133", // 100%
},
{
offset: 1,
color: "transparent", // 100%
},
],
global: false, // false
},
},
data: [], // this.series[0].data,
},
{
name: "", // this.series[1].name,
type: "bar",
barWidth: 12,
// tooltip: {
// valueFormatter: function (value) {
// return value + " ml";
// },
// },
itemStyle: {
borderRadius: [10, 10, 0, 0],
color: {
type: "linear",
x: 0,
y: 0,
x2: 0,
y2: 1,
colorStops: [
{
offset: 0,
color: "#57abf8", // 0%
},
{
offset: 1,
color: "#364BFE66", // 100%
},
],
global: false, // false
},
},
data: [], // this.series[1].data,
},
],
},
};
},
computed: {
isOpen() {
return this.$store.getters.sidebar.opened
},
},
watch: {
isOpen(val) {
// console.log(val)
if (val === true) {
console.log('ryf')
this.width = '99%'
this.canvasReset()
console.log(this.width)
} else {
this.watch = 100 + '%'
this.canvasReset()
}
},
/** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */
isFullscreen(val) {
if (val === true && this.isOpen === true) {
this.width = '99%'
}
this.actualOptions.series.map((item) => {
item.barWidth = val ? 18 : 12;
});
this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12;
this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12;
this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12;
this.initOptions(this.actualOptions);
},
series(val) {
if (!val) {
this.initOptions(this.options);
return;
}
const actualOptions = JSON.parse(JSON.stringify(this.options));
console.log('actualOptions', this.options)
actualOptions.series[0].data = val[0].data;
actualOptions.series[0].name = val[0].name;
actualOptions.series[1].data = val?.[1]?.data || [];
actualOptions.series[1].name = val?.[1]?.name || "";
this.actualOptions = actualOptions;
this.initChart(actualOptions);
},
},
mounted() {
if (screenfull.isEnabled) {
screenfull.on("change", () => {
this.isFullscreen = screenfull.isFullscreen;
});
}
this.actualOptions = this.options
this.canvasReset();
window.addEventListener("resize", this.canvasReset);
},
beforeDestroy() {
if (this.chart) {
this.chart.dispose();
}
},
destroyed() {
window.removeEventListener("resize", this.canvasReset);
},
methods: {
canvasReset() {
debounce(() => {
this.initChart();
}, 500)();
},
initChart() {
if (this.chart) {
this.chart.dispose();
}
this.chart = echarts.init(this.$refs.gasChart);
this.chart.setOption(this.actualOptions);
},
},
// mounted() {
// this.actualOptions = this.options;
// this.initOptions(this.options);
// window.addEventListener("resize", this.initOptions(this.actualOptions))
// if (screenfull.isEnabled) {
// screenfull.on("change", () => {
// this.isFullscreen = screenfull.isFullscreen;
// });
// }
// },
};
</script>
<style scoped lang="scss">
.bar-chart-base {
// position: relative;
.legend {
position: absolute;
top: 5.2vh;
right: 1vw;
}
.legend-item {
position: relative;
// font-size: 12px;
margin-right: 0.67vw;
&::before {
content: "";
display: inline-block;
width: 0.531vw;
height: 0.531vw;
background-color: #ccc;
border-radius: 2px;
margin-right: 0.22vw;
}
}
.legend-item:nth-child(1):before {
background-color: #12f7f1;
}
.legend-item:nth-child(2):before {
background-color: #58adfa;
}
}
</style>

View File

@ -1,40 +1,32 @@
<!-- <!--
* @Author: zhp * @Author: zhp
* @Date: 2024-05-07 13:22:43 * @Date: 2024-05-07 13:22:43
* @LastEditTime: 2024-05-09 16:22:24 * @LastEditTime: 2024-05-14 08:32:44
* @LastEditors: zhp * @LastEditors: zhp
* @Description: * @Description:
--> -->
<template> <template>
<chart-container class="bar-chart-base"> <chart-container class="bar-chart-base">
<div class="legend"> <div class="legend">
<span <span v-for="item in legend" :key="item.label" class="legend-item"
v-for="item in legend" :style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }">{{ item.label }}</span>
:key="item.label"
class="legend-item"
:style="{ fontSize: isFullscreen ? '0.58vw' : '0.54vw' }"
>{{ item.label }}</span
>
</div> </div>
<div <div ref="chart" :style="{ height: '100%',width: width}"></div>
ref="chart"
style="max-width: 40vw"
:style="{ height: vHeight + 'vh' }"
></div>
</chart-container> </chart-container>
</template> </template>
<script> <script>
import screenfull from "screenfull"; import screenfull from "screenfull";
import ChartContainer from "../../../../components/ChartContainer.vue"; import ChartContainer from "../../../../components/ChartContainer.vue";
import chartMixin from "@/mixins/chart.js"; // import chartMixin from "@/mixins/chart.js";
import { debounce } from "@/utils/debounce";
import * as echarts from "echarts";
export default { export default {
name: "BarChartBase", name: "BarChartBase",
components: { components: {
ChartContainer, ChartContainer,
}, },
mixins: [chartMixin], // mixins: [chartMixin],
props: { props: {
vHeight: { vHeight: {
type: Number, type: Number,
@ -59,12 +51,13 @@ export default {
}, },
data() { data() {
return { return {
width: '100%',
isFullscreen: false, isFullscreen: false,
actualOptions: null, actualOptions: null,
options: { options: {
grid: { grid: {
left: "5%", left: "5%",
right: "4%", right: "0%",
bottom: "3%", bottom: "3%",
top: "15%", top: "15%",
containLabel: true, containLabel: true,
@ -182,7 +175,21 @@ export default {
}, },
}; };
}, },
computed: {
isOpen() {
return this.$store.getters.sidebar.opened
},
},
watch: { watch: {
isOpen(val) {
if (val === true) {
this.width = '100%-128px'
this.canvasReset()
} else {
this.watch = 100 + '%'
this.canvasReset()
}
},
/** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */ /** 全屏状态切换时,对柱子粗细和字体大小进行相应调整 */
isFullscreen(val) { isFullscreen(val) {
this.actualOptions.series.map((item) => { this.actualOptions.series.map((item) => {
@ -191,11 +198,11 @@ export default {
this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12; this.actualOptions.xAxis.axisLabel.fontSize = val ? 18 : 12;
this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12; this.actualOptions.yAxis.axisLabel.fontSize = val ? 18 : 12;
this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12; this.actualOptions.yAxis.nameTextStyle.fontSize = val ? 18 : 12;
this.initOptions(this.actualOptions); this.initChart(this.actualOptions);
}, },
series(val) { series(val) {
if (!val) { if (!val) {
this.initOptions(this.options); this.initChart(this.options);
return; return;
} }
console.log(val) console.log(val)
@ -205,19 +212,41 @@ export default {
actualOptions.series[1].data = val?.[1]?.data || []; actualOptions.series[1].data = val?.[1]?.data || [];
actualOptions.series[1].name = val?.[1]?.name || ""; actualOptions.series[1].name = val?.[1]?.name || "";
this.actualOptions = actualOptions; this.actualOptions = actualOptions;
this.initOptions(actualOptions); this.initChart(actualOptions);
}, },
}, },
mounted() { mounted() {
this.actualOptions = this.options; // if (screenfull.isEnabled) {
this.initOptions(this.options); // screenfull.on("change", () => {
// this.isFullscreen = screenfull.isFullscreen;
if (screenfull.isEnabled) { // });
screenfull.on("change", () => { // }
this.isFullscreen = screenfull.isFullscreen; this.actualOptions = this.options
}); this.canvasReset();
window.addEventListener("resize", this.canvasReset);
},
beforeDestroy() {
if (this.chart) {
this.chart.dispose();
} }
}, },
destroyed() {
window.removeEventListener("resize", this.canvasReset);
},
methods: {
canvasReset() {
debounce(() => {
this.initChart();
}, 500)();
},
initChart() {
if (this.chart) {
this.chart.dispose();
}
this.chart = echarts.init(this.$refs.chart);
this.chart.setOption(this.actualOptions);
},
},
}; };
</script> </script>

View File

@ -159,6 +159,7 @@ export default {
} }
.chart { .chart {
width: 390px;
align-self: stretch; align-self: stretch;
height: 280px; height: 280px;
} }

View File

@ -7,31 +7,30 @@
<template> <template>
<LineChartBase <LineChartBase
v-if="1"
:legend="legend" :legend="legend"
:series="series" :series="series"
:xAxis="xAxis" :xAxis="xAxis"
in="elecCost" in="elecCost"
class="elec-cost" class="elec-cost"
/> />
<BarChartBase <!-- <BarChartBase
v-else v-else
:legend="legend" :legend="legend"
:series="series" :series="series"
:xAxis="xAxis" :xAxis="xAxis"
in="elecCost" in="elecCost"
class="elec-cost" class="elec-cost"
/> /> -->
</template> </template>
<script> <script>
import BarChartBaseVue from "@/views/copilot/components/BarChartBase.vue"; // import BarChartBaseVue from "@/views/copilot/components/BarChartBase.vue";
import LineChartBaseVue from "@/views/copilot/components/LineChartBase.vue"; import LineChartBaseVue from "@/views/copilot/components/LineChartBase.vue";
export default { export default {
name: "ElecCost", name: "ElecCost",
components: { components: {
BarChartBase: BarChartBaseVue, // BarChartBase: BarChartBaseVue,
LineChartBase: LineChartBaseVue, LineChartBase: LineChartBaseVue,
}, },
props: { props: {

View File

@ -15,7 +15,7 @@
</template> </template>
<script> <script>
import BarChartBase from "@/views/copilot/components/BarChartBase.vue"; import BarChartBase from "@/views/copilot/components/gasBarChartBase.vue";
export default { export default {
name: "NatGasCost", name: "NatGasCost",

View File

@ -10,7 +10,9 @@
<div class="cities"> <div class="cities">
<CopilotButtons :options="cities" @update:active="handleCityUpdate" /> <CopilotButtons :options="cities" @update:active="handleCityUpdate" />
</div> </div>
<div style="padding: 0 30px;width: 90%;">
<div class="chart" ref="chart"></div> <div class="chart" ref="chart"></div>
</div>
<div class="legend" v-if="1"> <div class="legend" v-if="1">
<div class="legend-item" v-for="(lgd,index) in legendList" :key="lgd.name"> <div class="legend-item" v-for="(lgd,index) in legendList" :key="lgd.name">
<div> <div>
@ -108,6 +110,8 @@ export default {
} }
.chart { .chart {
margin-left: 5%;
width: 290px;
align-self: stretch; align-self: stretch;
height: 280px; height: 280px;
} }

View File

@ -1,7 +1,7 @@
<!-- <!--
* @Author: zhp * @Author: zhp
* @Date: 2024-05-07 10:25:10 * @Date: 2024-05-07 10:25:10
* @LastEditTime: 2024-05-09 08:41:11 * @LastEditTime: 2024-05-13 15:48:10
* @LastEditors: zhp * @LastEditors: zhp
* @Description: * @Description:
--> -->
@ -56,8 +56,11 @@ export default {
immediate: true, immediate: true,
}, },
}, },
methods: { methods: {
fetchData(period = "日") { fetchData(period = "日") {
// console.log(this.width);
// console.log('sidebar', this.$store.getters.sidebar);
console.log(`效率驾驶舱,获取${period}数据`); console.log(`效率驾驶舱,获取${period}数据`);
this.$store.dispatch("copilot/initCopilot", { this.$store.dispatch("copilot/initCopilot", {
period, period,

View File

@ -25,6 +25,7 @@ export default {
props: {}, props: {},
data() { data() {
return { return {
weatherInterval:null,
isFullscreen: false, isFullscreen: false,
times: null, times: null,
weather:'', weather:'',
@ -40,8 +41,14 @@ export default {
}, },
}, },
mounted() { mounted() {
;this.getTimes() this.getTimes()
this.getWeather() this.weatherInterval = setInterval(() => {
this,this.getWeather()
}, 1000)
},
destroyed() {
// console.log(1111)
clearInterval(this.weatherInterval)
}, },
methods: { methods: {
getTimes() { getTimes() {
@ -83,8 +90,7 @@ export default {
'.' + '.' +
day day
}, },
async getWeather() { getWeather() {
setInterval(() => {
fetch(`https://restapi.amap.com/v3/weather/weatherInfo?key=a20a2093715deb9bd68e423c34a2ac3c&city=110108`, { fetch(`https://restapi.amap.com/v3/weather/weatherInfo?key=a20a2093715deb9bd68e423c34a2ac3c&city=110108`, {
method: 'get', method: 'get',
extensions: 'base', extensions: 'base',
@ -99,7 +105,6 @@ export default {
console.log(err); console.log(err);
}) })
}) })
}, 1000)
}, },
toggleFullscreen() { toggleFullscreen() {
screenfull.toggle(); screenfull.toggle();