mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-08 01:17:23 +08:00
perf: 更简单且兼容场景更多的首页图表尺寸自适应容器写法
This commit is contained in:
parent
e64cd0c8df
commit
ebc245d004
@ -54,7 +54,7 @@
|
|||||||
"@logicflow/extension": "^1.2.19",
|
"@logicflow/extension": "^1.2.19",
|
||||||
"@pureadmin/descriptions": "^1.2.0",
|
"@pureadmin/descriptions": "^1.2.0",
|
||||||
"@pureadmin/table": "^3.0.0",
|
"@pureadmin/table": "^3.0.0",
|
||||||
"@pureadmin/utils": "^2.1.2",
|
"@pureadmin/utils": "^2.2.0",
|
||||||
"@vueuse/core": "^10.7.1",
|
"@vueuse/core": "^10.7.1",
|
||||||
"@vueuse/motion": "^2.0.0",
|
"@vueuse/motion": "^2.0.0",
|
||||||
"@wangeditor/editor": "^5.1.23",
|
"@wangeditor/editor": "^5.1.23",
|
||||||
|
8
pnpm-lock.yaml
generated
8
pnpm-lock.yaml
generated
@ -24,8 +24,8 @@ dependencies:
|
|||||||
specifier: ^3.0.0
|
specifier: ^3.0.0
|
||||||
version: 3.0.0(element-plus@2.4.4)(typescript@5.3.3)
|
version: 3.0.0(element-plus@2.4.4)(typescript@5.3.3)
|
||||||
'@pureadmin/utils':
|
'@pureadmin/utils':
|
||||||
specifier: ^2.1.2
|
specifier: ^2.2.0
|
||||||
version: 2.1.2(echarts@5.4.3)(vue@3.4.5)
|
version: 2.2.0(echarts@5.4.3)(vue@3.4.5)
|
||||||
'@vueuse/core':
|
'@vueuse/core':
|
||||||
specifier: ^10.7.1
|
specifier: ^10.7.1
|
||||||
version: 10.7.1(vue@3.4.5)
|
version: 10.7.1(vue@3.4.5)
|
||||||
@ -1757,8 +1757,8 @@ packages:
|
|||||||
string-hash: 1.1.3
|
string-hash: 1.1.3
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@pureadmin/utils@2.1.2(echarts@5.4.3)(vue@3.4.5):
|
/@pureadmin/utils@2.2.0(echarts@5.4.3)(vue@3.4.5):
|
||||||
resolution: {integrity: sha512-TjMLN6MBNa5WkJYMidk1LhTfmTlHcSEjFm1jtN3e5z9Q3jzfnu5jF8MC+b0WF0LzeRqnq6kICrxXpSn5/HqNIA==}
|
resolution: {integrity: sha512-G4/Qzu0QosXlfTO/gWvgpygugFuUVpwUspfuejIqBnrJEudBllx17wZdDjNEL27Uwg+HjXYjofXQUGUX4E2NtA==}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
echarts: '*'
|
echarts: '*'
|
||||||
vue: '*'
|
vue: '*'
|
||||||
|
@ -18,7 +18,7 @@ const { isDark } = useDark();
|
|||||||
const theme = computed(() => (isDark.value ? "dark" : "light"));
|
const theme = computed(() => (isDark.value ? "dark" : "light"));
|
||||||
|
|
||||||
const chartRef = ref();
|
const chartRef = ref();
|
||||||
const { setOptions, resize } = useECharts(chartRef, {
|
const { setOptions } = useECharts(chartRef, {
|
||||||
theme
|
theme
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ watch(
|
|||||||
async () => {
|
async () => {
|
||||||
await nextTick(); // 确保DOM更新完成后再执行
|
await nextTick(); // 确保DOM更新完成后再执行
|
||||||
setOptions({
|
setOptions({
|
||||||
resize: false,
|
container: ".bar-card",
|
||||||
color: ["#41b6ff", "#e85f33"],
|
color: ["#41b6ff", "#e85f33"],
|
||||||
tooltip: {
|
tooltip: {
|
||||||
trigger: "axis",
|
trigger: "axis",
|
||||||
@ -101,10 +101,6 @@ watch(
|
|||||||
immediate: true
|
immediate: true
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
resize
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -24,6 +24,7 @@ const { setOptions } = useECharts(chartRef, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setOptions({
|
setOptions({
|
||||||
|
container: ".line-card",
|
||||||
xAxis: {
|
xAxis: {
|
||||||
type: "category",
|
type: "category",
|
||||||
show: false,
|
show: false,
|
||||||
|
@ -13,6 +13,7 @@ const { setOptions } = useECharts(chartRef, {
|
|||||||
});
|
});
|
||||||
|
|
||||||
setOptions({
|
setOptions({
|
||||||
|
container: ".line-card",
|
||||||
title: {
|
title: {
|
||||||
text: "100%",
|
text: "100%",
|
||||||
left: "47%",
|
left: "47%",
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, markRaw } from "vue";
|
import { ref, markRaw } from "vue";
|
||||||
import ReCol from "@/components/ReCol";
|
import ReCol from "@/components/ReCol";
|
||||||
|
import { useDark, randomGradient } from "./utils";
|
||||||
import PureTable from "./components/table/index.vue";
|
import PureTable from "./components/table/index.vue";
|
||||||
import { ReNormalCountTo } from "@/components/ReCountTo";
|
import { ReNormalCountTo } from "@/components/ReCountTo";
|
||||||
import { useRenderFlicker } from "@/components/ReFlicker";
|
import { useRenderFlicker } from "@/components/ReFlicker";
|
||||||
import { barChart, lineChart, roundChart } from "./components/chart";
|
import { barChart, lineChart, roundChart } from "./components/chart";
|
||||||
import Segmented, { type OptionsType } from "@/components/ReSegmented";
|
import Segmented, { type OptionsType } from "@/components/ReSegmented";
|
||||||
import { useResizeObserver, useDark, debounce, randomGradient } from "./utils";
|
|
||||||
import { chartData, barChartData, progressData, latestNewsData } from "./data";
|
import { chartData, barChartData, progressData, latestNewsData } from "./data";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "Welcome"
|
name: "Welcome"
|
||||||
});
|
});
|
||||||
|
|
||||||
const barCardRef = ref();
|
|
||||||
const barChartRef = ref();
|
|
||||||
const { isDark } = useDark();
|
const { isDark } = useDark();
|
||||||
|
|
||||||
let curWeek = ref(1); // 0上周、1本周
|
let curWeek = ref(1); // 0上周、1本周
|
||||||
@ -26,11 +24,6 @@ const optionsBasis: Array<OptionsType> = [
|
|||||||
label: "本周"
|
label: "本周"
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
useResizeObserver(
|
|
||||||
barCardRef,
|
|
||||||
debounce(() => barChartRef.value.resize(), 60)
|
|
||||||
);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -57,7 +50,7 @@ useResizeObserver(
|
|||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<el-card shadow="never">
|
<el-card class="line-card" shadow="never">
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<span class="text-md font-medium">
|
<span class="text-md font-medium">
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
@ -113,14 +106,13 @@ useResizeObserver(
|
|||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<el-card ref="barCardRef" shadow="never">
|
<el-card class="bar-card" shadow="never">
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<span class="text-md font-medium">分析概览</span>
|
<span class="text-md font-medium">分析概览</span>
|
||||||
<Segmented v-model="curWeek" :options="optionsBasis" />
|
<Segmented v-model="curWeek" :options="optionsBasis" />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex justify-between items-start mt-3">
|
<div class="flex justify-between items-start mt-3">
|
||||||
<barChart
|
<barChart
|
||||||
ref="barChartRef"
|
|
||||||
:requireData="barChartData[curWeek].requireData"
|
:requireData="barChartData[curWeek].requireData"
|
||||||
:questionData="barChartData[curWeek].questionData"
|
:questionData="barChartData[curWeek].questionData"
|
||||||
/>
|
/>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
export { default as dayjs } from "dayjs";
|
export { default as dayjs } from "dayjs";
|
||||||
export { useResizeObserver } from "@vueuse/core";
|
export { useDark, cloneDeep, randomGradient } from "@pureadmin/utils";
|
||||||
export { useDark, debounce, cloneDeep, randomGradient } from "@pureadmin/utils";
|
|
||||||
|
|
||||||
export function getRandomIntBetween(min: number, max: number) {
|
export function getRandomIntBetween(min: number, max: number) {
|
||||||
return Math.floor(Math.random() * (max - min + 1)) + min;
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user