mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-06 09:26:43 +08:00
feat(ai-call): 实现对话框尺寸和位置状态持久化
- 添加对话框尺寸状态保存与恢复功能 - 支持通过 sessionStorage 存储对话框宽高及坐标 -优化欢迎消息区域高度计算逻辑- 移除旧的状态处理机制,采用事件驱动方式- 确保在无保存状态时使用默认尺寸配置
This commit is contained in:
@@ -488,16 +488,48 @@ export default {
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
dialogVisible(newVal) {
|
||||
if(newVal){
|
||||
// this.$nextTick(() => {
|
||||
// let doc = document.querySelector('.welcome-message')
|
||||
// let sendBox = document.querySelector('.input-area-wrapper');
|
||||
// doc.style.height = `calc(600px - ${sendBox.offsetHeight}px - 120px)`;
|
||||
// });
|
||||
}
|
||||
dialogVisible: {
|
||||
handler(newVal) {
|
||||
if (newVal) {
|
||||
this.$nextTick(() => {
|
||||
// 获取对话框元素
|
||||
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: {
|
||||
handler() {
|
||||
|
||||
Reference in New Issue
Block a user