feat:对接首页数据
This commit is contained in:
58
__unconfig_vite.config.js
Normal file
58
__unconfig_vite.config.js
Normal file
@@ -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;
|
||||
@@ -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()
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
() => dataRes.value,
|
||||
(val) => {
|
||||
if (val) {
|
||||
console.log(val, '首页接受数据')
|
||||
switch (val.type) {
|
||||
case 'userPortrait':
|
||||
homeStore.setUserPortraitData(val.data)
|
||||
|
||||
@@ -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 }
|
||||
|
||||
Reference in New Issue
Block a user