From 970f718351f957a2ead7cf5c7c99ff8eae4ab927 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sat, 21 Mar 2026 20:51:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96RightToolbar=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=A0=8F=E5=88=87=E6=8D=A2=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/RightToolbar/index.vue | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/ruoyi-ui/src/components/RightToolbar/index.vue b/ruoyi-ui/src/components/RightToolbar/index.vue index c71029a72..a511f6e8c 100644 --- a/ruoyi-ui/src/components/RightToolbar/index.vue +++ b/ruoyi-ui/src/components/RightToolbar/index.vue @@ -123,7 +123,34 @@ export default { methods: { // 搜索 toggleSearch() { - this.$emit("update:showSearch", !this.showSearch) + let el = this.$el + let formEl = null + while ((el = el.parentElement) && el !== document.body) { + if ((formEl = el.querySelector('.el-form'))) break + } + if (!formEl) return this.$emit('update:showSearch', !this.showSearch) + this._animateSearch(formEl, this.showSearch) + }, + // 搜索栏动画 + _animateSearch(el, isHide) { + const DURATION = 260 + const TRANSITION = 'max-height 0.25s ease, opacity 0.2s ease' + const clear = () => Object.assign(el.style, { transition: '', maxHeight: '', opacity: '', overflow: '' }) + Object.assign(el.style, { overflow: 'hidden', transition: '' }) + if (isHide) { + Object.assign(el.style, { maxHeight: el.scrollHeight + 'px', opacity: '1', transition: TRANSITION }) + requestAnimationFrame(() => Object.assign(el.style, { maxHeight: '0', opacity: '0' })) + setTimeout(() => { this.$emit('update:showSearch', false); clear() }, DURATION) + } else { + this.$emit('update:showSearch', true) + this.$nextTick(() => { + Object.assign(el.style, { maxHeight: '0', opacity: '0' }) + requestAnimationFrame(() => requestAnimationFrame(() => { + Object.assign(el.style, { transition: TRANSITION, maxHeight: el.scrollHeight + 'px', opacity: '1' }) + })) + setTimeout(clear, DURATION) + }) + } }, // 刷新 refresh() {