mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-08-27 04:21:11 +08:00
Merge branch 'main' of https://github.com/vbenjs/vue-vben-admin
This commit is contained in:
@@ -1,5 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<Scrollbar ref="scrollbarRef" class="scroll-container" v-bind="$attrs">
|
<Scrollbar
|
||||||
|
ref="scrollbarRef"
|
||||||
|
class="scroll-container"
|
||||||
|
:scrollHeight="scrollHeight"
|
||||||
|
v-bind="$attrs"
|
||||||
|
>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</Scrollbar>
|
</Scrollbar>
|
||||||
</template>
|
</template>
|
||||||
@@ -13,6 +18,9 @@
|
|||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'ScrollContainer',
|
name: 'ScrollContainer',
|
||||||
components: { Scrollbar },
|
components: { Scrollbar },
|
||||||
|
props: {
|
||||||
|
scrollHeight: { type: Number },
|
||||||
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const scrollbarRef = ref<Nullable<ScrollbarType>>(null);
|
const scrollbarRef = ref<Nullable<ScrollbarType>>(null);
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<ScrollContainer ref="wrapperRef">
|
<ScrollContainer ref="wrapperRef" :scrollHeight="realHeight">
|
||||||
<div ref="spinRef" :style="spinStyle" v-loading="loading" :loading-tip="loadingTip">
|
<div ref="spinRef" :style="spinStyle" v-loading="loading" :loading-tip="loadingTip">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
</div>
|
</div>
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
const realHeightRef = ref(0);
|
const realHeightRef = ref(0);
|
||||||
const minRealHeightRef = ref(0);
|
const minRealHeightRef = ref(0);
|
||||||
|
|
||||||
let realHeight = 0;
|
const realHeight = ref(0);
|
||||||
|
|
||||||
let stopElResizeFn: AnyFunction = () => {};
|
let stopElResizeFn: AnyFunction = () => {};
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@
|
|||||||
if (!spinEl) return;
|
if (!spinEl) return;
|
||||||
await nextTick();
|
await nextTick();
|
||||||
// if (!realHeight) {
|
// if (!realHeight) {
|
||||||
realHeight = spinEl.scrollHeight;
|
realHeight.value = spinEl.scrollHeight;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (props.fullScreen) {
|
if (props.fullScreen) {
|
||||||
@@ -154,9 +154,9 @@
|
|||||||
} else {
|
} else {
|
||||||
realHeightRef.value = props.height
|
realHeightRef.value = props.height
|
||||||
? props.height
|
? props.height
|
||||||
: realHeight > maxHeight
|
: realHeight.value > maxHeight
|
||||||
? maxHeight
|
? maxHeight
|
||||||
: realHeight;
|
: realHeight.value;
|
||||||
}
|
}
|
||||||
emit('height-change', unref(realHeightRef));
|
emit('height-change', unref(realHeightRef));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -164,7 +164,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return { wrapperRef, spinRef, spinStyle, scrollTop, setModalHeight };
|
return { wrapperRef, spinRef, spinStyle, scrollTop, setModalHeight, realHeight };
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
provide,
|
provide,
|
||||||
computed,
|
computed,
|
||||||
unref,
|
unref,
|
||||||
|
watch,
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import Bar from './bar';
|
import Bar from './bar';
|
||||||
|
|
||||||
@@ -64,6 +65,11 @@
|
|||||||
type: String,
|
type: String,
|
||||||
default: 'div',
|
default: 'div',
|
||||||
},
|
},
|
||||||
|
scrollHeight: {
|
||||||
|
// 用于监控内部scrollHeight的变化
|
||||||
|
type: Number,
|
||||||
|
default: 0,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
setup(props) {
|
setup(props) {
|
||||||
const sizeWidth = ref('0');
|
const sizeWidth = ref('0');
|
||||||
@@ -99,6 +105,14 @@
|
|||||||
sizeWidth.value = widthPercentage < 100 ? widthPercentage + '%' : '';
|
sizeWidth.value = widthPercentage < 100 ? widthPercentage + '%' : '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.scrollHeight,
|
||||||
|
() => {
|
||||||
|
if (props.native) return;
|
||||||
|
update();
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
if (props.native) return;
|
if (props.native) return;
|
||||||
nextTick(update);
|
nextTick(update);
|
||||||
|
Reference in New Issue
Block a user