优化高度计算

This commit is contained in:
kuaifan 2022-04-22 07:05:20 +08:00
parent 52392e2e0a
commit 0b0e6951e5
5 changed files with 21 additions and 27 deletions

View File

@ -197,6 +197,7 @@ export default {
windowSizeListener() { windowSizeListener() {
this.$store.state.windowWidth = window.innerWidth this.$store.state.windowWidth = window.innerWidth
this.$store.state.windowHeight = window.innerHeight
this.$store.state.windowMax768 = window.innerWidth <= 768 this.$store.state.windowMax768 = window.innerWidth <= 768
}, },

View File

@ -415,7 +415,6 @@ export default {
openMenu: {}, openMenu: {},
visibleMenu: false, visibleMenu: false,
show768Menu: false, show768Menu: false,
innerHeight: window.innerHeight,
workReportShow: false, workReportShow: false,
allUserShow: false, allUserShow: false,
@ -452,7 +451,6 @@ export default {
this.dialogMsgSubscribe = Store.subscribe('dialogMsgPush', this.addDialogMsg); this.dialogMsgSubscribe = Store.subscribe('dialogMsgPush', this.addDialogMsg);
// //
document.addEventListener('keydown', this.shortcutEvent); document.addEventListener('keydown', this.shortcutEvent);
window.addEventListener('resize', this.innerHeightListener);
}, },
beforeDestroy() { beforeDestroy() {
@ -466,7 +464,6 @@ export default {
} }
// //
document.removeEventListener('keydown', this.shortcutEvent); document.removeEventListener('keydown', this.shortcutEvent);
window.removeEventListener('resize', this.innerHeightListener);
}, },
deactivated() { deactivated() {
@ -493,6 +490,8 @@ export default {
'clientNewVersion', 'clientNewVersion',
'cacheTaskBrowse', 'cacheTaskBrowse',
'windowHeight',
]), ]),
...mapGetters(['taskData', 'dashboardTask']), ...mapGetters(['taskData', 'dashboardTask']),
@ -603,9 +602,9 @@ export default {
}, },
taskStyle() { taskStyle() {
const {innerHeight} = this; const {windowHeight} = this;
return { return {
maxHeight: (innerHeight - (innerHeight > 900 ? 200 : 70) - 20) + 'px' maxHeight: (windowHeight - (windowHeight > 900 ? 200 : 70) - 20) + 'px'
} }
}, },
@ -709,10 +708,6 @@ export default {
}; };
}, },
innerHeightListener() {
this.innerHeight = window.innerHeight;
},
chackPass() { chackPass() {
if (this.userInfo.changepass === 1) { if (this.userInfo.changepass === 1) {
this.goForward({name: 'manage-setting-password'}); this.goForward({name: 'manage-setting-password'});

View File

@ -489,8 +489,6 @@ export default {
nowTime: $A.Time(), nowTime: $A.Time(),
nowInterval: null, nowInterval: null,
innerHeight: Math.min(1100, window.innerHeight),
msgText: '', msgText: '',
msgFile: [], msgFile: [],
navActive: 'dialog', navActive: 'dialog',
@ -531,7 +529,6 @@ export default {
this.nowInterval = setInterval(() => { this.nowInterval = setInterval(() => {
this.nowTime = $A.Time(); this.nowTime = $A.Time();
}, 1000); }, 1000);
window.addEventListener('resize', this.innerHeightListener);
// //
this.receiveTaskSubscribe = Store.subscribe('receiveTask', () => { this.receiveTaskSubscribe = Store.subscribe('receiveTask', () => {
this.receiveShow = true; this.receiveShow = true;
@ -540,7 +537,6 @@ export default {
destroyed() { destroyed() {
clearInterval(this.nowInterval); clearInterval(this.nowInterval);
window.removeEventListener('resize', this.innerHeightListener);
// //
if (this.receiveTaskSubscribe) { if (this.receiveTaskSubscribe) {
this.receiveTaskSubscribe.unsubscribe(); this.receiveTaskSubscribe.unsubscribe();
@ -559,7 +555,8 @@ export default {
'taskFiles', 'taskFiles',
'taskPriority', 'taskPriority',
'windowMax768' 'windowMax768',
'windowHeight'
]), ]),
projectName() { projectName() {
@ -619,23 +616,25 @@ export default {
}, },
dialogStyle() { dialogStyle() {
const {innerHeight, hasOpenDialog} = this; const {windowHeight, hasOpenDialog} = this;
if (!innerHeight) { let height = Math.min(1100, windowHeight)
if (!height) {
return {}; return {};
} }
if (!hasOpenDialog) { if (!hasOpenDialog) {
return {}; return {};
} }
return { return {
minHeight: (innerHeight - (innerHeight > 900 ? 200 : 70) - 48) + 'px' minHeight: (height - (height > 900 ? 200 : 70) - 48) + 'px'
} }
}, },
taskDetailStyle() { taskDetailStyle() {
const {modalMode, innerHeight, hasOpenDialog} = this; const {modalMode, windowHeight, hasOpenDialog} = this;
let height = Math.min(1100, windowHeight)
if (modalMode && hasOpenDialog) { if (modalMode && hasOpenDialog) {
return { return {
maxHeight: (innerHeight - (innerHeight > 900 ? 200 : 70) - 30) + 'px' maxHeight: (height - (height > 900 ? 200 : 70) - 30) + 'px'
} }
} }
return {} return {}
@ -756,10 +755,6 @@ export default {
}, },
methods: { methods: {
innerHeightListener() {
this.innerHeight = Math.min(1100, window.innerHeight);
},
within24Hours(date) { within24Hours(date) {
return $A.Date(date, true) - this.nowTime < 86400 return $A.Date(date, true) - this.nowTime < 86400
}, },

View File

@ -436,7 +436,6 @@ export default {
} }
], ],
tableHeight: 500,
tableMode: $A.getStorageString("fileTableMode"), tableMode: $A.getStorageString("fileTableMode"),
columns: [], columns: [],
@ -505,7 +504,6 @@ export default {
}, },
mounted() { mounted() {
this.tableHeight = window.innerHeight - 160;
this.uploadAccept = this.uploadFormat.map(item => { this.uploadAccept = this.uploadFormat.map(item => {
return '.' + item return '.' + item
}).join(","); }).join(",");
@ -516,7 +514,7 @@ export default {
}, },
computed: { computed: {
...mapState(['userId', 'userToken', 'userIsAdmin', 'userInfo', 'files', 'wsOpenNum']), ...mapState(['userId', 'userToken', 'userIsAdmin', 'userInfo', 'files', 'wsOpenNum', 'windowHeight']),
pid() { pid() {
const {folderId} = this.$route.params; const {folderId} = this.$route.params;
@ -608,6 +606,10 @@ export default {
return ['multiple']; return ['multiple'];
} }
return []; return [];
},
tableHeight() {
return Math.max(300, this.windowHeight - 160)
} }
}, },

View File

@ -2,8 +2,9 @@ const stateData = {
// 是否桌面端 // 是否桌面端
isDesktop: $A.isDesktop(), isDesktop: $A.isDesktop(),
// 浏览器宽 // 浏览器宽
windowWidth: window.innerWidth, windowWidth: window.innerWidth,
windowHeight: window.innerHeight,
// 浏览器宽度≤768返回true // 浏览器宽度≤768返回true
windowMax768: window.innerWidth <= 768, windowMax768: window.innerWidth <= 768,