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 }