update: 升级vben5.5.9到5.7.0

This commit is contained in:
2026-09-22 17:09:46 +08:00
parent 345e4a31f8
commit 802f72cd9e
766 changed files with 28468 additions and 15447 deletions
@@ -1,7 +1,7 @@
<script lang="ts" setup>
import type { ColPageProps } from './types';
import { computed, nextTick, onMounted, ref, unref, useSlots, watch } from 'vue';
import { computed, ref, useSlots } from 'vue';
import {
ResizableHandle,
@@ -18,34 +18,12 @@ defineOptions({
const props = withDefaults(defineProps<ColPageProps>(), {
leftWidth: 30,
leftCollapsed: false,
rightWidth: 70,
resizable: true,
});
const emit = defineEmits<{
'update:leftWidth': [width: number];
'update:leftCollapsed': [collapsed: boolean];
}>();
const delegatedProps = computed(() => {
const {
leftWidth: _leftWidth,
leftMinWidth: _leftMinWidth,
leftMaxWidth: _leftMaxWidth,
leftCollapsedWidth: _leftCollapsedWidth,
leftCollapsible: _leftCollapsible,
leftCollapsed: _leftCollapsed,
rightWidth: _rightWidth,
rightMinWidth: _rightMinWidth,
rightMaxWidth: _rightMaxWidth,
rightCollapsedWidth: _rightCollapsedWidth,
rightCollapsible: _rightCollapsible,
resizable: _resizable,
splitLine: _splitLine,
splitHandle: _splitHandle,
...delegated
} = props;
const { leftWidth: _, ...delegated } = props;
return delegated;
});
@@ -63,32 +41,6 @@ const delegatedSlots = computed(() => {
});
const leftPanelRef = ref<InstanceType<typeof ResizablePanel>>();
/** 自身操作引起的回写,避免与外部 v-model 互相触发 */
const suppressExternalSync = ref(false);
const leftDefaultSize = computed(() =>
props.leftCollapsed
? (props.leftCollapsedWidth ?? 0)
: props.leftWidth,
);
const rightDefaultSize = computed(() =>
props.leftCollapsed
? 100 - (props.leftCollapsedWidth ?? 0)
: props.rightWidth,
);
function isLeftCollapsed() {
return !!unref(leftPanelRef.value?.isCollapsed);
}
function runAsSelfApply(apply: () => void) {
suppressExternalSync.value = true;
apply();
void nextTick(() => {
suppressExternalSync.value = false;
});
}
function expandLeft() {
leftPanelRef.value?.expand();
@@ -98,56 +50,6 @@ function collapseLeft() {
leftPanelRef.value?.collapse();
}
function applyCollapsed(collapsed: boolean) {
const panel = leftPanelRef.value;
if (!panel) return;
if (collapsed) {
panel.collapse();
return;
}
panel.expand();
void nextTick(() => panel.resize(props.leftWidth));
}
function onLeftCollapse() {
runAsSelfApply(() => emit('update:leftCollapsed', true));
}
function onLeftExpand() {
runAsSelfApply(() => emit('update:leftCollapsed', false));
}
/** 收起过程中的尺寸不写入展开宽度 */
function onLeftResize(size: number) {
const collapsedSize = props.leftCollapsedWidth ?? 0;
if (isLeftCollapsed() || size <= collapsedSize + 0.51) return;
if (Math.abs(size - props.leftWidth) < 0.15) return;
runAsSelfApply(() => emit('update:leftWidth', size));
}
watch(
() => props.leftCollapsed,
(collapsed) => {
if (suppressExternalSync.value) return;
applyCollapsed(collapsed);
},
);
watch(
() => props.leftWidth,
(width) => {
if (suppressExternalSync.value || isLeftCollapsed()) return;
const current = leftPanelRef.value?.getSize();
if (current == null || Math.abs(current - width) < 0.3) return;
leftPanelRef.value?.resize(width);
},
);
onMounted(() => {
if (!props.leftCollapsed) return;
void nextTick(() => applyCollapsed(true));
});
defineExpose({
expandLeft,
collapseLeft,
@@ -166,16 +68,12 @@ defineExpose({
<ResizablePanelGroup class="w-full" direction="horizontal">
<ResizablePanel
id="col-page-left"
ref="leftPanelRef"
:collapsed-size="leftCollapsedWidth"
:collapsible="leftCollapsible"
:default-size="leftDefaultSize"
:default-size="leftWidth"
:max-size="leftMaxWidth"
:min-size="leftMinWidth"
@collapse="onLeftCollapse"
@expand="onLeftExpand"
@resize="onLeftResize"
>
<template #default="slotProps">
<slot
@@ -194,10 +92,9 @@ defineExpose({
:with-handle="splitHandle"
/>
<ResizablePanel
id="col-page-right"
:collapsed-size="rightCollapsedWidth"
:collapsible="rightCollapsible"
:default-size="rightDefaultSize"
:default-size="rightWidth"
:max-size="rightMaxWidth"
:min-size="rightMinWidth"
>