|
|
@@ -1,13 +1,29 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
<div
|
|
|
- :class="{ 'grid-container': isShowTopNavigation, 'grid-container-hide-column1': !isShowMenu }"
|
|
|
+ :class="{
|
|
|
+ 'grid-container': isShowTopNavigation,
|
|
|
+ 'grid-container-hide-column1': !isShowMenu,
|
|
|
+ }"
|
|
|
+ :style="{
|
|
|
+ gridTemplateColumns: width + 'px auto',
|
|
|
+ }"
|
|
|
>
|
|
|
<div v-if="isShowMenu" class="grid-item-row12-column1">
|
|
|
<div>
|
|
|
- <keep-alive>
|
|
|
- <MenuWidget />
|
|
|
- </keep-alive>
|
|
|
+ <div
|
|
|
+ id="resizable"
|
|
|
+ ref="resizable"
|
|
|
+ class="resizable-container"
|
|
|
+ :style="{ width: width + 'px' }"
|
|
|
+ >
|
|
|
+ <div>
|
|
|
+ <keep-alive>
|
|
|
+ <MenuWidget :width="width" />
|
|
|
+ <div class="resize-handle" @mousedown="handleMouseDown" />
|
|
|
+ </keep-alive>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
@@ -20,9 +36,17 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
- <div :class="{'grid-item-row2-column2' : isShowTopNavigation}">
|
|
|
- <div id="grid-item-center" :class="{'grid-center-container' : isShowTopNavigation}" />
|
|
|
- <div :class="{'center-container-single' : !isShowTopNavigation, 'center-container' : isShowTopNavigation }">
|
|
|
+ <div :class="{ 'grid-item-row2-column2': isShowTopNavigation }">
|
|
|
+ <div
|
|
|
+ id="grid-item-center"
|
|
|
+ :class="{ 'grid-center-container': isShowTopNavigation }"
|
|
|
+ />
|
|
|
+ <div
|
|
|
+ :class="{
|
|
|
+ 'center-container-single': !isShowTopNavigation,
|
|
|
+ 'center-container': isShowTopNavigation,
|
|
|
+ }"
|
|
|
+ >
|
|
|
<a-config-provider :locale="locale">
|
|
|
<router-view />
|
|
|
</a-config-provider>
|
|
|
@@ -41,7 +65,6 @@ import 'dayjs/locale/zh-cn';
|
|
|
dayjs.locale('zh-cn');
|
|
|
|
|
|
export default {
|
|
|
-
|
|
|
components: {
|
|
|
MenuWidget,
|
|
|
TopNavigation,
|
|
|
@@ -53,6 +76,11 @@ export default {
|
|
|
// 是否显示上导航栏
|
|
|
isShowTopNavigation: false,
|
|
|
locale: zhCN,
|
|
|
+ // 菜单拉伸值
|
|
|
+ isResizing: false,
|
|
|
+ startX: 0,
|
|
|
+ startWidth: 0,
|
|
|
+ width: 230,
|
|
|
};
|
|
|
},
|
|
|
|
|
|
@@ -71,16 +99,89 @@ export default {
|
|
|
this.$i18n.locale = languageSelected;
|
|
|
}
|
|
|
|
|
|
+ // 恢复菜单栏宽度
|
|
|
+ const menuWidth = localStorage.getItem('menuWidth');
|
|
|
+ if (menuWidth !== null && menuWidth !== undefined) {
|
|
|
+ this.width = Number(menuWidth);
|
|
|
+ } else {
|
|
|
+ this.width = 230;
|
|
|
+ localStorage.setItem('menuWidth', 230);
|
|
|
+ }
|
|
|
+
|
|
|
this.computerComponentVisible();
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
+ throttle(func, limit) {
|
|
|
+ let inThrottle;
|
|
|
+ return function () {
|
|
|
+ const args = arguments;
|
|
|
+ const context = this;
|
|
|
+ if (!inThrottle) {
|
|
|
+ func.apply(context, args);
|
|
|
+ inThrottle = true;
|
|
|
+ setTimeout(() => (inThrottle = false), limit);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ // 鼠标按下时开始监听
|
|
|
+ handleMouseDown(e) {
|
|
|
+ this.isResizing = true;
|
|
|
+ this.startX = e.clientX;
|
|
|
+ this.startWidth = this.width;
|
|
|
+ const el = document.querySelector('.grid-container');
|
|
|
+ el.style.userSelect = 'none';
|
|
|
+ // 绑定鼠标移动和鼠标抬起事件到document
|
|
|
+ document.documentElement.addEventListener(
|
|
|
+ 'mousemove',
|
|
|
+ this.throttle(this.handleMouseMove, 20),
|
|
|
+ );
|
|
|
+ document.documentElement.addEventListener('mouseup', this.handleMouseUp);
|
|
|
+ },
|
|
|
+ // 鼠标移动时开始计算
|
|
|
+ handleMouseMove(e) {
|
|
|
+ const _self = this;
|
|
|
+ if (!_self.isResizing) return;
|
|
|
+ e.preventDefault();
|
|
|
+ const deltaX = e.clientX - _self.startX;
|
|
|
+ // 最小宽度230
|
|
|
+ if (_self.startWidth + deltaX >= 230) {
|
|
|
+ _self.width = _self.startWidth + deltaX;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 鼠标松开时清除
|
|
|
+ handleMouseUp(e) {
|
|
|
+ const _self = this;
|
|
|
+ this.isResizing = false;
|
|
|
+ const el = document.querySelector('.grid-container');
|
|
|
+ el.style.userSelect = 'auto';
|
|
|
+ setTimeout(() => {
|
|
|
+ localStorage.setItem('menuWidth', _self.width);
|
|
|
+ }, 1000);
|
|
|
+ document.documentElement.removeEventListener(
|
|
|
+ 'mousemove',
|
|
|
+ this.handleMouseMove,
|
|
|
+ );
|
|
|
+ document.documentElement.removeEventListener(
|
|
|
+ 'mouseup',
|
|
|
+ this.handleMouseUp,
|
|
|
+ );
|
|
|
+ },
|
|
|
+
|
|
|
/**
|
|
|
* 点击之后存储isShowMenu
|
|
|
*/
|
|
|
clickIsShowMenu: function () {
|
|
|
var _self = this;
|
|
|
this.isShowMenu = !this.isShowMenu;
|
|
|
+ if (this.isShowMenu) {
|
|
|
+ const menuWidth = localStorage.getItem('menuWidth');
|
|
|
+ this.width = Number(menuWidth);
|
|
|
+ } else {
|
|
|
+ this.width = 0;
|
|
|
+ }
|
|
|
+ // localStorage.setItem('menuWidth', this.width);
|
|
|
// localStorage.setItem('#IsShowMenu', this.isShowMenu);
|
|
|
},
|
|
|
/**
|
|
|
@@ -224,7 +325,6 @@ export default {
|
|
|
padding: 0px;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
.center-container {
|
|
|
padding: 0px 20px 0;
|
|
|
}
|
|
|
@@ -463,4 +563,25 @@ nav ul.pagination {
|
|
|
.input-group .form-control:first-child {
|
|
|
border-radius: 4px;
|
|
|
}
|
|
|
+</style>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.resizable-container {
|
|
|
+ position: relative;
|
|
|
+ min-width: 230px; /* 设置最小宽度 */
|
|
|
+ padding: 10px;
|
|
|
+}
|
|
|
+
|
|
|
+.resize-handle {
|
|
|
+ position: absolute;
|
|
|
+ right: 0;
|
|
|
+ top: 0;
|
|
|
+ bottom: 0;
|
|
|
+ width: 6px;
|
|
|
+ height: calc(100vh);
|
|
|
+ background-color: #ffffff;
|
|
|
+}
|
|
|
+.resize-handle:hover {
|
|
|
+ cursor: ew-resize;
|
|
|
+}
|
|
|
</style>
|