mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-07 01:46:42 +08:00
feat(ai-call): 实现对话框尺寸和位置状态持久化
- 添加对话框尺寸状态保存与恢复功能 - 支持通过 sessionStorage 存储对话框宽高及坐标 -优化欢迎消息区域高度计算逻辑- 移除旧的状态处理机制,采用事件驱动方式- 确保在无保存状态时使用默认尺寸配置
This commit is contained in:
@@ -488,16 +488,48 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
dialogVisible(newVal) {
|
dialogVisible: {
|
||||||
if(newVal){
|
handler(newVal) {
|
||||||
// this.$nextTick(() => {
|
if (newVal) {
|
||||||
// let doc = document.querySelector('.welcome-message')
|
this.$nextTick(() => {
|
||||||
// let sendBox = document.querySelector('.input-area-wrapper');
|
// 获取对话框元素
|
||||||
// doc.style.height = `calc(600px - ${sendBox.offsetHeight}px - 120px)`;
|
const dialogEl = document.querySelector('.case-expert-dialog .el-dialog');
|
||||||
// });
|
if (dialogEl) {
|
||||||
}
|
// 检查是否有保存的尺寸状态
|
||||||
|
const savedSize = sessionStorage.getItem('aiCallDialogSize');
|
||||||
|
if (savedSize) {
|
||||||
|
const { width, height, left, top } = JSON.parse(savedSize);
|
||||||
|
dialogEl.style.width = width + 'px';
|
||||||
|
dialogEl.style.height = height + 'px';
|
||||||
|
dialogEl.style.left = left + 'px';
|
||||||
|
dialogEl.style.top = top + 'px';
|
||||||
|
}
|
||||||
|
|
||||||
// 移除之前的逻辑,因为现在通过事件机制处理状态恢复
|
// 检查是否有保存的位置状态
|
||||||
|
const savedPosition = sessionStorage.getItem('aiCallDialogPosition');
|
||||||
|
if (savedPosition) {
|
||||||
|
const { left, top } = JSON.parse(savedPosition);
|
||||||
|
dialogEl.style.left = left + 'px';
|
||||||
|
dialogEl.style.top = top + 'px';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let doc = document.querySelector('.welcome-message')
|
||||||
|
let sendBox = document.querySelector('.input-area-wrapper');
|
||||||
|
// 只有在没有保存的尺寸状态时才使用默认值
|
||||||
|
if (doc && sendBox) {
|
||||||
|
const savedSize = sessionStorage.getItem('aiCallDialogSize');
|
||||||
|
if (!savedSize) {
|
||||||
|
doc.style.height = `calc(600px - ${sendBox.offsetHeight}px - 120px)`;
|
||||||
|
} else {
|
||||||
|
const { height } = JSON.parse(savedSize);
|
||||||
|
doc.style.height = `calc(${height}px - ${sendBox.offsetHeight}px - 120px)`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
},
|
},
|
||||||
messageList: {
|
messageList: {
|
||||||
handler() {
|
handler() {
|
||||||
|
|||||||
Reference in New Issue
Block a user