dashboard (#6)

* feat(dashboard): 增加dashboard示例

* feat(chart-ui): 增加图表UI组件库

* feat(dashboard): 完善dashboard示例
This commit is contained in:
jinmao88
2024-06-23 13:41:02 +08:00
committed by GitHub
parent 303a200427
commit 6f0c05dd50
16 changed files with 690 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
<script setup lang="ts">
import { echartsInstance, ECOption } from './index';
import { onMounted, ref, unref, warn } from 'vue';
import { usePreferences } from '@vben-core/preferences';
const { isDark } = usePreferences();
interface Props {
height?: string;
width?: string;
}
withDefaults(defineProps<Props>(), {
height: '500px',
width: '100%',
});
const instance = ref();
const instanceRef = ref(HTMLElement);
onMounted(() => {
instance.value = echartsInstance.init(
instanceRef.value,
isDark.value ? 'dark' : '',
);
});
const setChart = (option: ECOption, clear: boolean = true) => {
const c = unref(instance);
if (!c) {
warn('instance is null');
return;
}
if (clear) c.clear();
c.setOption(option);
};
defineExpose({ setChart });
</script>
<template>
<div ref="instanceRef" :style="{ height, width }"></div>
</template>