Browse Source

Merge branch 'main' into main

pull/7576/head
zouawen 4 weeks ago
committed by GitHub
parent
commit
3d4ae04d9b
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      internal/vite-config/src/index.ts
  2. 6
      packages/@core/ui-kit/form-ui/src/form-render/form-field.vue
  3. 27
      packages/effects/plugins/src/echarts/use-echarts.ts
  4. 1
      playground/src/router/routes/modules/dashboard.ts
  5. 7
      playground/src/views/examples/form/basic.vue

1
internal/vite-config/src/index.ts

@ -1,4 +1,5 @@
export * from './config';
export * from './options';
export * from './plugins';
export type * from './typing';
export { loadAndConvertEnv } from './utils/env';

6
packages/@core/ui-kit/form-ui/src/form-render/form-field.vue

@ -381,10 +381,10 @@ onUnmounted(() => {
<div v-if="suffix" class="ml-1">
<VbenRenderContent :content="suffix" />
</div>
<FormDescription v-if="description" class="ml-1">
<VbenRenderContent :content="description" />
</FormDescription>
</div>
<FormDescription v-if="description" class="text-xs">
<VbenRenderContent :content="description" />
</FormDescription>
<Transition name="slide-up" v-if="!compact">
<FormMessage class="absolute" />

27
packages/effects/plugins/src/echarts/use-echarts.ts

@ -6,7 +6,17 @@ import type { Nullable } from '@vben/types';
import type EchartsUI from './echarts-ui.vue';
import { computed, nextTick, watch } from 'vue';
import {
computed,
nextTick,
onActivated,
onBeforeUnmount,
onDeactivated,
onMounted,
ref,
unref,
watch,
} from 'vue';
import { usePreferences } from '@vben/preferences';
@ -27,6 +37,8 @@ type EchartsThemeType = 'dark' | 'light' | null;
function useEcharts(chartRef: Ref<EchartsUIType>) {
let chartInstance: echarts.ECharts | null = null;
let cacheOptions: EChartsOption = {};
// echart是否处于激活状态
const isActiveRef = ref(false);
const { isDark } = usePreferences();
const { height, width } = useWindowSize();
@ -42,6 +54,11 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
return maybeComponent.$el ?? null;
};
onMounted(() => (isActiveRef.value = true));
onActivated(() => (isActiveRef.value = true));
onDeactivated(() => (isActiveRef.value = false));
onBeforeUnmount(() => (isActiveRef.value = false));
const isElHidden = (el: HTMLElement | null): boolean => {
if (!el) return true;
return el.offsetHeight === 0 || el.offsetWidth === 0;
@ -71,6 +88,9 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
options: EChartsOption,
clear = true,
): Promise<Nullable<echarts.ECharts>> => {
if (!unref(isActiveRef)) {
return Promise.resolve(null);
}
cacheOptions = options;
const currentOptions = {
...options,
@ -154,8 +174,8 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
useResizeObserver(chartRef as never, resizeHandler);
watch(isDark, () => {
if (chartInstance) {
watch([isDark, isActiveRef], () => {
if (chartInstance && unref(isActiveRef)) {
chartInstance.dispose();
initCharts();
renderEcharts(cacheOptions);
@ -168,6 +188,7 @@ function useEcharts(chartRef: Ref<EchartsUIType>) {
chartInstance?.dispose();
});
return {
isActive: isActiveRef,
renderEcharts,
resize,
updateData,

1
playground/src/router/routes/modules/dashboard.ts

@ -20,6 +20,7 @@ const routes: RouteRecordRaw[] = [
affixTab: true,
icon: 'lucide:area-chart',
title: $t('page.dashboard.analytics'),
keepAlive: true,
},
},
{

7
playground/src/views/examples/form/basic.vue

@ -67,6 +67,13 @@ const [BaseForm, baseFormApi] = useVbenForm({
label: '字符串',
rules: 'required',
},
{
component: 'Input',
fieldName: 'desc',
// description
description: '这是表单描述',
label: '字符串(带描述)',
},
{
// #/adapter.ts
component: 'ApiSelect',

Loading…
Cancel
Save