hlq-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/bin/index.js +16 -0
- package/lib/aesCreate.js +11 -0
- package/lib/axiosCreate.js +11 -0
- package/lib/create.js +172 -0
- package/lib/echartCreate.js +12 -0
- package/lib/jwtDecodeCreate.js +16 -0
- package/lib/rsaCreate.js +11 -0
- package/lib/stateCreate.js +34 -0
- package/lib/websocketCreate.js +16 -0
- package/package.json +21 -0
- package/templates/.env +1 -0
- package/templates/.env.dev +2 -0
- package/templates/.env.pro +2 -0
- package/templates/index.html +15 -0
- package/templates/package-lock.json +4058 -0
- package/templates/package.json +31 -0
- package/templates/public/config.js +1 -0
- package/templates/public/font/iconfont.css +579 -0
- package/templates/public/font/iconfont.js +1 -0
- package/templates/public/font/iconfont.ttf +0 -0
- package/templates/public/font/iconfont.woff +0 -0
- package/templates/public/font/iconfont.woff2 +0 -0
- package/templates/src/App.vue +35 -0
- package/templates/src/components/chart/barChart.vue +103 -0
- package/templates/src/components/chart/color.ts +43 -0
- package/templates/src/components/chart/lineChart.vue +114 -0
- package/templates/src/components/chart/mapChart.vue +135 -0
- package/templates/src/components/chart/mixedChart.vue +148 -0
- package/templates/src/components/chart/pieChart.vue +104 -0
- package/templates/src/components/chart/radarChart.vue +112 -0
- package/templates/src/components/chart/scatterChart.vue +144 -0
- package/templates/src/components/chart/sunburstChart.vue +183 -0
- package/templates/src/components/descript/index.vue +45 -0
- package/templates/src/components/dialog/index.vue +54 -0
- package/templates/src/components/drawer/index.vue +53 -0
- package/templates/src/components/form/component/cascader.vue +65 -0
- package/templates/src/components/form/component/checkbox.vue +31 -0
- package/templates/src/components/form/component/datePicker.vue +39 -0
- package/templates/src/components/form/component/dateRange.vue +36 -0
- package/templates/src/components/form/component/datetimePicker.vue +25 -0
- package/templates/src/components/form/component/fileUpload.vue +80 -0
- package/templates/src/components/form/component/formFun.ts +132 -0
- package/templates/src/components/form/component/imageUpload.vue +92 -0
- package/templates/src/components/form/component/input.vue +41 -0
- package/templates/src/components/form/component/location.vue +79 -0
- package/templates/src/components/form/component/radio.vue +31 -0
- package/templates/src/components/form/component/select.vue +66 -0
- package/templates/src/components/form/component/textarea.vue +26 -0
- package/templates/src/components/form/component/timePicker.vue +28 -0
- package/templates/src/components/form/component/upload.ts +20 -0
- package/templates/src/components/form/formInterface.ts +115 -0
- package/templates/src/components/form/index.vue +193 -0
- package/templates/src/components/form/item.vue +323 -0
- package/templates/src/components/groupForm/index.vue +91 -0
- package/templates/src/components/icon/index.vue +29 -0
- package/templates/src/components/layout/header.vue +238 -0
- package/templates/src/components/layout/index.vue +167 -0
- package/templates/src/components/layout/menu.vue +130 -0
- package/templates/src/components/layout/sideBarItem.vue +49 -0
- package/templates/src/components/searchBox/height.ts +9 -0
- package/templates/src/components/searchBox/index.vue +265 -0
- package/templates/src/components/table/index.vue +371 -0
- package/templates/src/components/table/table.ts +23 -0
- package/templates/src/components/tree/index.vue +222 -0
- package/templates/src/components/tree/lazyTree.vue +136 -0
- package/templates/src/data.d.ts +4 -0
- package/templates/src/main.ts +18 -0
- package/templates/src/router/index.ts +60 -0
- package/templates/src/store/menuInterface.ts +10 -0
- package/templates/src/store/permission.ts +59 -0
- package/templates/src/store/user.ts +24 -0
- package/templates/src/utils/alioss/index.ts +0 -0
- package/templates/src/utils/axios/http.ts +99 -0
- package/templates/src/utils/axios/index.ts +112 -0
- package/templates/src/utils/axios/service.ts +8 -0
- package/templates/src/utils/crypto/index.ts +28 -0
- package/templates/src/utils/rsa/index.ts +18 -0
- package/templates/src/utils/token/index.ts +6 -0
- package/templates/src/utils/tree/index.ts +74 -0
- package/templates/src/utils/websocket/index.ts +136 -0
- package/templates/src/views/login/index.vue +248 -0
- package/templates/src/views/templete/table.vue +122 -0
- package/templates/src/views/templete/tableConfig.ts +153 -0
- package/templates/tsconfig.app.json +19 -0
- package/templates/tsconfig.json +7 -0
- package/templates/tsconfig.node.json +23 -0
- package/templates/vite.config.ts +34 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="chartConent">
|
|
3
|
+
<div ref="chartRef" class="chart-container"></div>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
<script lang="ts" setup>
|
|
7
|
+
import { ref, onMounted, watch, onUnmounted, nextTick } from 'vue'
|
|
8
|
+
import * as echarts from 'echarts'
|
|
9
|
+
import { colorList, colorList2 } from './color'
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
data?: any
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
16
|
+
data: () => ({
|
|
17
|
+
xAxis: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
18
|
+
series: [
|
|
19
|
+
{
|
|
20
|
+
name: 'Sales',
|
|
21
|
+
data: [120, 200, 150, 80, 70, 110, 130],
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
}),
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const chartRef = ref<HTMLElement | null>(null)
|
|
28
|
+
let chart: echarts.ECharts | null = null
|
|
29
|
+
|
|
30
|
+
const initChart = () => {
|
|
31
|
+
if (!chartRef.value) return
|
|
32
|
+
nextTick(() => {
|
|
33
|
+
chart = echarts.init(chartRef.value)
|
|
34
|
+
const option = {
|
|
35
|
+
tooltip: {
|
|
36
|
+
trigger: 'axis',
|
|
37
|
+
axisPointer: {
|
|
38
|
+
type: 'shadow',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
grid: {
|
|
42
|
+
left: '3%',
|
|
43
|
+
right: '4%',
|
|
44
|
+
bottom: '3%',
|
|
45
|
+
containLabel: true,
|
|
46
|
+
},
|
|
47
|
+
xAxis: {
|
|
48
|
+
type: 'category',
|
|
49
|
+
data: props.data.xAxis,
|
|
50
|
+
axisLabel: {
|
|
51
|
+
interval: 0,
|
|
52
|
+
rotate: 30,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
yAxis: {
|
|
56
|
+
type: 'value',
|
|
57
|
+
},
|
|
58
|
+
series: props.data.series.map((item: any, index: number) => ({
|
|
59
|
+
name: item.name,
|
|
60
|
+
type: 'bar',
|
|
61
|
+
data: item.data,
|
|
62
|
+
itemStyle: {
|
|
63
|
+
borderRadius: [4, 4, 0, 0],
|
|
64
|
+
color: colorList[index % colorList.length],
|
|
65
|
+
},
|
|
66
|
+
})),
|
|
67
|
+
}
|
|
68
|
+
chart.setOption(option)
|
|
69
|
+
chart?.resize()
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const handleResize = () => {
|
|
74
|
+
chart?.resize()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
onMounted(() => {
|
|
78
|
+
initChart()
|
|
79
|
+
window.addEventListener('resize', handleResize)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
onUnmounted(() => {
|
|
83
|
+
window.removeEventListener('resize', handleResize)
|
|
84
|
+
chart?.dispose()
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
watch(
|
|
88
|
+
() => props.data,
|
|
89
|
+
() => {
|
|
90
|
+
initChart()
|
|
91
|
+
},
|
|
92
|
+
{ deep: true },
|
|
93
|
+
)
|
|
94
|
+
</script>
|
|
95
|
+
<style lang="scss" scoped>
|
|
96
|
+
.chartConent {
|
|
97
|
+
height: 100%;
|
|
98
|
+
}
|
|
99
|
+
.chart-container {
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: 100%;
|
|
102
|
+
}
|
|
103
|
+
</style>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const colorList = [
|
|
2
|
+
"#41CE86",
|
|
3
|
+
"#FAC858",
|
|
4
|
+
"#FC8452",
|
|
5
|
+
"#EE6666",
|
|
6
|
+
"#73C0DE",
|
|
7
|
+
"#3BA272",
|
|
8
|
+
"#9A60B4",
|
|
9
|
+
"#EA7CCC",
|
|
10
|
+
"#1E90FF",
|
|
11
|
+
"#FF6347",
|
|
12
|
+
"#7B68EE",
|
|
13
|
+
"#00FA9A",
|
|
14
|
+
"#FFD700",
|
|
15
|
+
"#6A5ACD",
|
|
16
|
+
"#FF69B4",
|
|
17
|
+
"#00CED1",
|
|
18
|
+
"#FF4500",
|
|
19
|
+
"#8A2BE2",
|
|
20
|
+
"#ADFF2F",
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
export const colorList2 = [
|
|
24
|
+
"#D9FFEC",
|
|
25
|
+
"#FCEBB4",
|
|
26
|
+
"#FDCAB8",
|
|
27
|
+
"#F4A3A3",
|
|
28
|
+
"#B8E1ED",
|
|
29
|
+
"#8FD6B5",
|
|
30
|
+
"#CBA6D9",
|
|
31
|
+
"#F3CFE0",
|
|
32
|
+
"#A4D4FF",
|
|
33
|
+
"#FFA8A0",
|
|
34
|
+
"#B3A9F0",
|
|
35
|
+
"#A6FAD8",
|
|
36
|
+
"#FFEBA0",
|
|
37
|
+
"#B3A9E6",
|
|
38
|
+
"#FFA8C8",
|
|
39
|
+
"#A6E8E1",
|
|
40
|
+
"#FFA08A",
|
|
41
|
+
"#C3A6F0",
|
|
42
|
+
"#E8FFB3",
|
|
43
|
+
];
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="chartConent">
|
|
3
|
+
<div ref="chartRef" class="chart-container"></div>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
<script lang="ts" setup>
|
|
7
|
+
import { ref, onMounted, watch, onUnmounted, nextTick } from "vue";
|
|
8
|
+
import * as echarts from "echarts";
|
|
9
|
+
import { colorList, colorList2 } from "./color";
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
data?: any;
|
|
13
|
+
height?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
17
|
+
data: () => ({
|
|
18
|
+
xAxis: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
|
19
|
+
series: [
|
|
20
|
+
{
|
|
21
|
+
name: "Sales",
|
|
22
|
+
data: [120, 200, 150, 80, 70, 110, 130],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "Profit",
|
|
26
|
+
data: [80, 150, 120, 60, 50, 90, 100],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const chartRef = ref<HTMLElement | null>(null);
|
|
33
|
+
let chart: echarts.ECharts | null = null;
|
|
34
|
+
|
|
35
|
+
const initChart = () => {
|
|
36
|
+
if (!chartRef.value) return;
|
|
37
|
+
nextTick(() => {
|
|
38
|
+
chart = echarts.init(chartRef.value);
|
|
39
|
+
|
|
40
|
+
const option = {
|
|
41
|
+
tooltip: {
|
|
42
|
+
trigger: "axis",
|
|
43
|
+
},
|
|
44
|
+
legend: {
|
|
45
|
+
data: props.data.series.map((item: any) => item.name),
|
|
46
|
+
top: "top",
|
|
47
|
+
right: "10%",
|
|
48
|
+
orient: "horizontal"
|
|
49
|
+
},
|
|
50
|
+
grid: {
|
|
51
|
+
left: "3%",
|
|
52
|
+
right: "4%",
|
|
53
|
+
bottom: "3%",
|
|
54
|
+
top: "20%",
|
|
55
|
+
containLabel: true,
|
|
56
|
+
},
|
|
57
|
+
xAxis: {
|
|
58
|
+
type: "category",
|
|
59
|
+
boundaryGap: false,
|
|
60
|
+
data: props.data.xAxis,
|
|
61
|
+
},
|
|
62
|
+
yAxis: {
|
|
63
|
+
type: "value",
|
|
64
|
+
},
|
|
65
|
+
series: props.data.series.map((item: any, index: number) => ({
|
|
66
|
+
name: item.name,
|
|
67
|
+
type: "line",
|
|
68
|
+
stack: "Total",
|
|
69
|
+
data: item.data,
|
|
70
|
+
smooth: true,
|
|
71
|
+
lineStyle: {
|
|
72
|
+
color: colorList[index % colorList.length]
|
|
73
|
+
},
|
|
74
|
+
itemStyle: {
|
|
75
|
+
color: colorList[index % colorList.length]
|
|
76
|
+
}
|
|
77
|
+
})),
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
chart.setOption(option);
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const handleResize = () => {
|
|
85
|
+
chart?.resize();
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
onMounted(() => {
|
|
89
|
+
initChart();
|
|
90
|
+
window.addEventListener("resize", handleResize);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
onUnmounted(() => {
|
|
94
|
+
window.removeEventListener("resize", handleResize);
|
|
95
|
+
chart?.dispose();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
watch(
|
|
99
|
+
() => props.data,
|
|
100
|
+
() => {
|
|
101
|
+
initChart();
|
|
102
|
+
},
|
|
103
|
+
{ deep: true },
|
|
104
|
+
);
|
|
105
|
+
</script>
|
|
106
|
+
<style lang="scss" scoped>
|
|
107
|
+
.chartConent {
|
|
108
|
+
height: 100%;
|
|
109
|
+
}
|
|
110
|
+
.chart-container {
|
|
111
|
+
width: 100%;
|
|
112
|
+
height: 100%;
|
|
113
|
+
}
|
|
114
|
+
</style>
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="chartConent">
|
|
3
|
+
<div ref="chartRef" class="chart-container"></div>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
<script lang="ts" setup>
|
|
7
|
+
import { ref, onMounted, watch, onUnmounted, nextTick } from "vue";
|
|
8
|
+
import * as echarts from "echarts";
|
|
9
|
+
import { colorList, colorList2 } from "./color";
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
data?: any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
16
|
+
data: () => ({
|
|
17
|
+
series: [
|
|
18
|
+
{
|
|
19
|
+
name: "热力值",
|
|
20
|
+
data: [
|
|
21
|
+
{ name: "北京", value: 100 },
|
|
22
|
+
{ name: "上海", value: 80 },
|
|
23
|
+
{ name: "广州", value: 60 },
|
|
24
|
+
{ name: "深圳", value: 90 },
|
|
25
|
+
{ name: "杭州", value: 70 },
|
|
26
|
+
{ name: "成都", value: 50 },
|
|
27
|
+
{ name: "武汉", value: 40 },
|
|
28
|
+
{ name: "西安", value: 30 },
|
|
29
|
+
{ name: "南京", value: 65 },
|
|
30
|
+
{ name: "重庆", value: 75 }
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const chartRef = ref<HTMLElement | null>(null);
|
|
38
|
+
let chart: echarts.ECharts | null = null;
|
|
39
|
+
let currentMap = "china";
|
|
40
|
+
|
|
41
|
+
const initChart = () => {
|
|
42
|
+
if (!chartRef.value) return;
|
|
43
|
+
nextTick(() => {
|
|
44
|
+
chart = echarts.init(chartRef.value);
|
|
45
|
+
|
|
46
|
+
// 模拟地图数据加载
|
|
47
|
+
const option = {
|
|
48
|
+
title: {
|
|
49
|
+
text: "中国热力图",
|
|
50
|
+
left: "center"
|
|
51
|
+
},
|
|
52
|
+
tooltip: {
|
|
53
|
+
trigger: "item",
|
|
54
|
+
formatter: function(params: any) {
|
|
55
|
+
return params.name + ": " + params.value;
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
visualMap: {
|
|
59
|
+
min: 0,
|
|
60
|
+
max: 100,
|
|
61
|
+
calculable: true,
|
|
62
|
+
inRange: {
|
|
63
|
+
color: ["#D9FFEC", "#41CE86"]
|
|
64
|
+
},
|
|
65
|
+
textStyle: {
|
|
66
|
+
color: "#333"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
series: [
|
|
70
|
+
{
|
|
71
|
+
name: "热力值",
|
|
72
|
+
type: "map",
|
|
73
|
+
map: currentMap,
|
|
74
|
+
roam: true,
|
|
75
|
+
label: {
|
|
76
|
+
show: true,
|
|
77
|
+
fontSize: 10
|
|
78
|
+
},
|
|
79
|
+
emphasis: {
|
|
80
|
+
label: {
|
|
81
|
+
show: true,
|
|
82
|
+
fontSize: 12
|
|
83
|
+
},
|
|
84
|
+
itemStyle: {
|
|
85
|
+
areaColor: "#FAC858"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
data: props.data.series[0].data
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
chart.setOption(option);
|
|
94
|
+
chart?.resize();
|
|
95
|
+
|
|
96
|
+
// 添加点击事件,模拟下钻功能
|
|
97
|
+
chart.on("click", function(params: any) {
|
|
98
|
+
console.log("点击了", params.name);
|
|
99
|
+
// 这里可以实现实际的下钻逻辑
|
|
100
|
+
// 例如加载省/市地图数据
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const handleResize = () => {
|
|
106
|
+
chart?.resize();
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
onMounted(() => {
|
|
110
|
+
initChart();
|
|
111
|
+
window.addEventListener("resize", handleResize);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
onUnmounted(() => {
|
|
115
|
+
window.removeEventListener("resize", handleResize);
|
|
116
|
+
chart?.dispose();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
watch(
|
|
120
|
+
() => props.data,
|
|
121
|
+
() => {
|
|
122
|
+
initChart();
|
|
123
|
+
},
|
|
124
|
+
{ deep: true },
|
|
125
|
+
);
|
|
126
|
+
</script>
|
|
127
|
+
<style lang="scss" scoped>
|
|
128
|
+
.chartConent {
|
|
129
|
+
height: 100%;
|
|
130
|
+
}
|
|
131
|
+
.chart-container {
|
|
132
|
+
width: 100%;
|
|
133
|
+
height: 100%;
|
|
134
|
+
}
|
|
135
|
+
</style>
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="chartConent">
|
|
3
|
+
<div ref="chartRef" class="chart-container"></div>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
<script lang="ts" setup>
|
|
7
|
+
import { ref, onMounted, watch, onUnmounted, nextTick } from "vue";
|
|
8
|
+
import * as echarts from "echarts";
|
|
9
|
+
import { colorList, colorList2 } from "./color";
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
data?: any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
16
|
+
data: () => ({
|
|
17
|
+
xAxis: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
|
18
|
+
series: [
|
|
19
|
+
{
|
|
20
|
+
name: "Sales",
|
|
21
|
+
type: "bar",
|
|
22
|
+
data: [120, 200, 150, 80, 70, 110, 130]
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "Profit",
|
|
26
|
+
type: "line",
|
|
27
|
+
data: [80, 150, 120, 60, 50, 90, 100]
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
}),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
const chartRef = ref<HTMLElement | null>(null);
|
|
34
|
+
let chart: echarts.ECharts | null = null;
|
|
35
|
+
|
|
36
|
+
const initChart = () => {
|
|
37
|
+
if (!chartRef.value) return;
|
|
38
|
+
nextTick(() => {
|
|
39
|
+
chart = echarts.init(chartRef.value);
|
|
40
|
+
const option = {
|
|
41
|
+
tooltip: {
|
|
42
|
+
trigger: "axis",
|
|
43
|
+
axisPointer: {
|
|
44
|
+
type: "cross",
|
|
45
|
+
crossStyle: {
|
|
46
|
+
color: "#999"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
legend: {
|
|
51
|
+
data: props.data.series.map((item: any) => item.name),
|
|
52
|
+
top: "top",
|
|
53
|
+
right: "10%",
|
|
54
|
+
orient: "horizontal"
|
|
55
|
+
},
|
|
56
|
+
grid: {
|
|
57
|
+
left: "3%",
|
|
58
|
+
right: "4%",
|
|
59
|
+
bottom: "3%",
|
|
60
|
+
top: "20%",
|
|
61
|
+
containLabel: true
|
|
62
|
+
},
|
|
63
|
+
xAxis: [
|
|
64
|
+
{
|
|
65
|
+
type: "category",
|
|
66
|
+
data: props.data.xAxis,
|
|
67
|
+
axisPointer: {
|
|
68
|
+
type: "shadow"
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
],
|
|
72
|
+
yAxis: [
|
|
73
|
+
{
|
|
74
|
+
type: "value",
|
|
75
|
+
name: "Sales",
|
|
76
|
+
min: 0,
|
|
77
|
+
max: 250,
|
|
78
|
+
interval: 50,
|
|
79
|
+
axisLabel: {
|
|
80
|
+
formatter: "{value}"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: "value",
|
|
85
|
+
name: "Profit",
|
|
86
|
+
min: 0,
|
|
87
|
+
max: 160,
|
|
88
|
+
interval: 40,
|
|
89
|
+
axisLabel: {
|
|
90
|
+
formatter: "{value}"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
series: props.data.series.map((item: any, index: number) => {
|
|
95
|
+
const series: any = {
|
|
96
|
+
name: item.name,
|
|
97
|
+
type: item.type,
|
|
98
|
+
data: item.data,
|
|
99
|
+
itemStyle: {
|
|
100
|
+
color: colorList[index % colorList.length]
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
if (item.type === "line") {
|
|
104
|
+
series.yAxisIndex = 1;
|
|
105
|
+
series.smooth = true;
|
|
106
|
+
series.lineStyle = {
|
|
107
|
+
color: colorList[index % colorList.length]
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
return series;
|
|
111
|
+
})
|
|
112
|
+
};
|
|
113
|
+
chart.setOption(option);
|
|
114
|
+
chart?.resize();
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const handleResize = () => {
|
|
119
|
+
chart?.resize();
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
onMounted(() => {
|
|
123
|
+
initChart();
|
|
124
|
+
window.addEventListener("resize", handleResize);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
onUnmounted(() => {
|
|
128
|
+
window.removeEventListener("resize", handleResize);
|
|
129
|
+
chart?.dispose();
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
watch(
|
|
133
|
+
() => props.data,
|
|
134
|
+
() => {
|
|
135
|
+
initChart();
|
|
136
|
+
},
|
|
137
|
+
{ deep: true },
|
|
138
|
+
);
|
|
139
|
+
</script>
|
|
140
|
+
<style lang="scss" scoped>
|
|
141
|
+
.chartConent {
|
|
142
|
+
height: 100%;
|
|
143
|
+
}
|
|
144
|
+
.chart-container {
|
|
145
|
+
width: 100%;
|
|
146
|
+
height: 100%;
|
|
147
|
+
}
|
|
148
|
+
</style>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="chartConent">
|
|
3
|
+
<div ref="chartRef" class="chart-container"></div>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
<script lang="ts" setup>
|
|
7
|
+
import { ref, onMounted, watch, onUnmounted, nextTick } from "vue";
|
|
8
|
+
import * as echarts from "echarts";
|
|
9
|
+
import { colorList, colorList2 } from "./color";
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
data?: any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
16
|
+
data: () => ({
|
|
17
|
+
series: [
|
|
18
|
+
{
|
|
19
|
+
name: "Sales",
|
|
20
|
+
data: [
|
|
21
|
+
{ value: 335, name: "Direct" },
|
|
22
|
+
{ value: 310, name: "Email" },
|
|
23
|
+
{ value: 234, name: "Affiliate" },
|
|
24
|
+
{ value: 135, name: "Social" },
|
|
25
|
+
{ value: 1548, name: "Other" },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
}),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const chartRef = ref<HTMLElement | null>(null);
|
|
33
|
+
let chart: echarts.ECharts | null = null;
|
|
34
|
+
|
|
35
|
+
const initChart = () => {
|
|
36
|
+
if (!chartRef.value) return;
|
|
37
|
+
chart = echarts.init(chartRef.value);
|
|
38
|
+
|
|
39
|
+
const option = {
|
|
40
|
+
tooltip: {
|
|
41
|
+
trigger: "item",
|
|
42
|
+
formatter: "{a} <br/>{b}: {c} ({d}%)",
|
|
43
|
+
},
|
|
44
|
+
legend: {
|
|
45
|
+
orient: "vertical",
|
|
46
|
+
left: "left",
|
|
47
|
+
data: props.data.series[0].data.map((item: any) => item.name),
|
|
48
|
+
},
|
|
49
|
+
series: props.data.series.map((item: any) => ({
|
|
50
|
+
name: item.name,
|
|
51
|
+
type: "pie",
|
|
52
|
+
radius: "60%",
|
|
53
|
+
center: ["50%", "50%"],
|
|
54
|
+
data: item.data,
|
|
55
|
+
itemStyle: {
|
|
56
|
+
color: function(params: any) {
|
|
57
|
+
return colorList[params.dataIndex % colorList.length];
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
emphasis: {
|
|
61
|
+
itemStyle: {
|
|
62
|
+
shadowBlur: 10,
|
|
63
|
+
shadowOffsetX: 0,
|
|
64
|
+
shadowColor: "rgba(0, 0, 0, 0.5)",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
})),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
chart.setOption(option);
|
|
71
|
+
chart?.resize();
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const handleResize = () => {
|
|
75
|
+
chart?.resize();
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
onMounted(() => {
|
|
79
|
+
initChart();
|
|
80
|
+
window.addEventListener("resize", handleResize);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
onUnmounted(() => {
|
|
84
|
+
window.removeEventListener("resize", handleResize);
|
|
85
|
+
chart?.dispose();
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
watch(
|
|
89
|
+
() => props.data,
|
|
90
|
+
() => {
|
|
91
|
+
initChart();
|
|
92
|
+
},
|
|
93
|
+
{ deep: true },
|
|
94
|
+
);
|
|
95
|
+
</script>
|
|
96
|
+
<style lang="scss" scoped>
|
|
97
|
+
.chartConent {
|
|
98
|
+
height: 100%;
|
|
99
|
+
}
|
|
100
|
+
.chart-container {
|
|
101
|
+
width: 100%;
|
|
102
|
+
height: 100%;
|
|
103
|
+
}
|
|
104
|
+
</style>
|