refactor(测试跟踪): 功能用例列表页,记住模块树的宽度

--bug=1025065 --user=陈建星 左侧模块宽度调整后记住用户的操作 https://www.tapd.cn/55049933/s/1358949
This commit is contained in:
chenjianxing 2023-04-03 19:28:34 +08:00 committed by jianxing
parent 9329374d66
commit ac953f3231
2 changed files with 47 additions and 8 deletions

View File

@ -1,5 +1,5 @@
<template>
<el-aside :width="asideHidden ? '0' : width" class="ms-aside-container"
<el-aside :width="asideHidden ? '0' : defaultWidth" class="ms-aside-container"
:id="id"
:style="{
// 'margin-left': !asideHidden ? 0 : '-' + asideHiddenMargin,
@ -24,6 +24,16 @@ import {getUUID} from "../../utils";
export default {
name: "MsAsideContainer",
components: {MsHorizontalDragBar},
data() {
return {
asideHidden: false,
hiddenBottomTop: null,
id: null,
asideHiddenMargin: '292px',
defaultWidth: '269px',
observer: null
}
},
props: {
width: {
type: String,
@ -52,6 +62,12 @@ export default {
type: Number,
default: null
},
//
enableRememberWidth: Boolean,
pageKey: {
type: String,
default: null
}
},
watch: {
asideHidden() {
@ -75,13 +91,32 @@ export default {
this.$nextTick(() => {
this.setHiddenBottomTop();
});
if (this.pageKey && this.enableRememberWidth) {
let rememberKey = 'WIDTH_' + this.pageKey;
let rememberWidth = localStorage.getItem(rememberKey);
if (rememberWidth) {
//
this.defaultWidth = rememberWidth;
} else {
this.defaultWidth = this.width;
}
let element = document.getElementById(this.id);
let MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver
this.observer = new MutationObserver(() => {
// localStorage
localStorage.setItem(rememberKey, getComputedStyle(element).getPropertyValue('width'));
})
this.observer.observe(element, { attributes: true, attributeFilter: ['style'], attributeOldValue: true })
}
},
data() {
return {
asideHidden: false,
hiddenBottomTop: null,
id: null,
asideHiddenMargin: '292px'
beforeDestroyed () {
if (this.observer) {
this.observer.disconnect()
this.observer.takeRecords()
this.observer = null
}
},
methods: {

View File

@ -32,7 +32,11 @@
<div style="display: flex; height: calc(100vh - 130px)" class = "test-case-aside-layout">
<!-- case-aside-container -->
<ms-aside-container v-show="isAsideHidden" :min-width="'0'" :enable-aside-hidden.sync="enableAsideHidden">
<ms-aside-container v-show="isAsideHidden"
page-key="TEST_CASE_LIST"
:enable-remember-width="true"
:min-width="'0'"
:enable-aside-hidden.sync="enableAsideHidden">
<test-case-node-tree
:type="'edit'"
:total='total'