From 999d99b68c09fa14f06eedd3ae6e811ab72fdabe Mon Sep 17 00:00:00 2001 From: zjc <1034206993@qq.com> Date: Tue, 11 Mar 2025 16:02:49 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=AF=B9=E6=8E=A5=E9=A6=96?= =?UTF-8?q?=E9=A1=B5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __unconfig_vite.config.js | 58 ++++++++++++++++++++++ src/hooks/echart.js | 12 ++--- src/views/home/components/vacancy.vue | 16 +++--- src/views/home/index.vue | 1 + src/views/monitor/components/alarmRate.vue | 8 +-- 5 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 __unconfig_vite.config.js diff --git a/__unconfig_vite.config.js b/__unconfig_vite.config.js new file mode 100644 index 0000000..ce4eb14 --- /dev/null +++ b/__unconfig_vite.config.js @@ -0,0 +1,58 @@ + +let __unconfig_data; +let __unconfig_stub = function (data = {}) { __unconfig_data = data }; +__unconfig_stub.default = (data = {}) => { __unconfig_data = data }; +import { fileURLToPath, URL } from 'node:url' + +import { defineConfig } from 'vite' +import vue from '@vitejs/plugin-vue' +import vueJsx from '@vitejs/plugin-vue-jsx' +import AutoImport from 'unplugin-auto-import/vite' +import Components from 'unplugin-vue-components/vite' +import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' +// import vueDevTools from 'vite-plugin-vue-devtools' + +// https://vite.dev/config/ +const __unconfig_default = defineConfig({ + plugins: [ + vue(), + vueJsx(), + AutoImport({ + imports: ['vue'], + dts: 'src/auto-import.d.ts', + resolvers: [ElementPlusResolver()] + }), + Components({ + resolvers: [ElementPlusResolver()] + }) + // vueDevTools(), + ], + base: '/largeScreen/', + server: { + hmr: true, + host: '0.0.0.0' + // proxy: { + // '/': { + // // 目标服务器的地址 + // target: 'http://36.138.38.16:8001', + // changeOrigin: true + // } + // } + }, + resolve: { + alias: { + '@': fileURLToPath(new URL('./src', import.meta.url)) + }, + extensions: ['.js', '.vue'] + }, + css: { + preprocessorOptions: { + scss: { + additionalData: '@use "@/styles/screen.scss" as *;', + javascriptEnabled: true + } + } + } +}) + +if (typeof __unconfig_default === "function") __unconfig_default(...[{"command":"serve","mode":"development"}]);export default __unconfig_data; \ No newline at end of file diff --git a/src/hooks/echart.js b/src/hooks/echart.js index a154282..6dae2a8 100644 --- a/src/hooks/echart.js +++ b/src/hooks/echart.js @@ -3,21 +3,21 @@ import * as echarts from 'echarts' import { guid } from '@/utils/util' export function useEchart() { - let chart = ref(null) + let chart = null let id = ref(guid()) const initChart = () => { const dom = document.getElementById(id.value) - chart.value = echarts.init(dom) + chart = echarts.init(dom) } const setOption = (params, update = false) => { - chart.value.setOption(params, update) + chart.setOption(params, update) } const dispose = () => { - chart.value.dispose() - chart.value = null + chart.dispose() + chart = null } const resize = () => { - chart.value.resize() + if (chart) chart.resize() } onMounted(() => { initChart() diff --git a/src/views/home/components/vacancy.vue b/src/views/home/components/vacancy.vue index 7c0f2f1..e730be2 100644 --- a/src/views/home/components/vacancy.vue +++ b/src/views/home/components/vacancy.vue @@ -34,7 +34,7 @@ return props.list.map((item) => { return { ...item, - value: item.occupiedPercentage, + value: item.occupiedSpaces, itemStyle: { color: { type: 'linear', @@ -61,7 +61,7 @@ return props.list.map((item) => { return { ...item, - value: item.occupiedPercentage, + value: item.occupiedSpaces, itemStyle: { color: '#fff', opacity: 1 @@ -70,7 +70,7 @@ }) } const getYAxisData = () => { - return props.list.map((item) => item.occupied) + return props.list.map((item) => item.occupiedSpaces) } const init = () => { if (!params) { @@ -91,22 +91,23 @@ }, xAxis: [ { + type: 'value', + max: 100, + show: false, splitLine: { show: false - }, - type: 'value', - show: false + } } ], yAxis: [ { + type: 'category', splitLine: { show: false }, axisLine: { show: false }, - type: 'category', axisTick: { show: false }, @@ -146,6 +147,7 @@ { name: '', type: 'bar', + max: 100, barWidth: fitChartSize(8), showBackground: true, borderRadius: [0, 0, 0, 0], diff --git a/src/views/home/index.vue b/src/views/home/index.vue index aed911b..16f20b5 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -38,6 +38,7 @@ () => dataRes.value, (val) => { if (val) { + console.log(val, '首页接受数据') switch (val.type) { case 'userPortrait': homeStore.setUserPortraitData(val.data) diff --git a/src/views/monitor/components/alarmRate.vue b/src/views/monitor/components/alarmRate.vue index 73fb07d..18591c7 100644 --- a/src/views/monitor/components/alarmRate.vue +++ b/src/views/monitor/components/alarmRate.vue @@ -98,10 +98,12 @@ } watch( - () => [props.dataList, chart.value], + () => props.dataList, () => { - if (props.dataList.length > 0 && chart.value) { - init() + if (props.dataList.length > 0) { + setTimeout(() => { + init() + }, 1000) } }, { immediate: true }