@lambo-design/pro-layout 1.0.0-beta.424 → 1.0.0-beta.425

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/index.vue +86 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lambo-design/pro-layout",
3
- "version": "1.0.0-beta.424",
3
+ "version": "1.0.0-beta.425",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -10,8 +10,8 @@
10
10
  "registry": "https://registry.npmjs.org/"
11
11
  },
12
12
  "devDependencies": {
13
- "@lambo-design/shared": "^1.0.0-beta.346",
14
- "@lambo-design/core": "^4.7.1-beta.176"
13
+ "@lambo-design/core": "^4.7.1-beta.176",
14
+ "@lambo-design/shared": "^1.0.0-beta.346"
15
15
  },
16
16
  "scripts": {
17
17
  "release-pro-layout": "pnpm release-beta && git push --follow-tags && pnpm re-publish",
package/src/index.vue CHANGED
@@ -23,14 +23,21 @@
23
23
  </LamboProLayoutHeader>
24
24
  </i-header>
25
25
  <i-layout>
26
- <i-sider v-show="isHideLeftMenu"
26
+ <i-sider
27
+ v-show="isHideLeftMenu"
27
28
  class="pro-layout-sider"
28
29
  hide-trigger
29
30
  collapsible
30
- :width="220"
31
+ :width="siderWidth"
31
32
  :collapsed-width="64"
32
33
  v-model="collapsed">
33
34
  <LamboProLayoutSider ref="sider"></LamboProLayoutSider>
35
+ <!-- 拖拽条 -->
36
+ <div
37
+ v-show="isHideLeftMenu"
38
+ class="sider-resize-bar"
39
+ @mousedown.stop.prevent="startResize"
40
+ ></div>
34
41
  </i-sider>
35
42
  <i-content class="pro-layout-content">
36
43
  <i-layout class="pro-layout-content-layout">
@@ -44,6 +51,13 @@
44
51
  </i-layout>
45
52
  </i-content>
46
53
  </i-layout>
54
+ <!-- 拖拽时的全局捕获层 -->
55
+ <div
56
+ v-if="isResizing"
57
+ class="resize-mask"
58
+ @mousemove="onMouseMove"
59
+ @mouseup="stopResize"
60
+ ></div>
47
61
  </i-layout>
48
62
  </template>
49
63
 
@@ -121,7 +135,11 @@ export default {
121
135
  appId: '',
122
136
  activeName: '',
123
137
  tagList: [],
124
- isHideLeftMenu: true
138
+ isHideLeftMenu: true,
139
+ siderWidth: 220,
140
+ isResizing: false,
141
+ minWidth: 180,
142
+ maxWidth: 600,
125
143
  }
126
144
  },
127
145
  components: {
@@ -169,9 +187,41 @@ export default {
169
187
  },
170
188
  immediate: true,
171
189
  deep: true
190
+ },
191
+ collapsed(val) {
192
+ if (val) {
193
+ this.siderWidth = 64
194
+ } else {
195
+ const savedWidth = localStorage.getItem('siderWidth')
196
+ this.siderWidth = savedWidth ? parseInt(savedWidth) : 220
197
+ }
172
198
  }
173
199
  },
174
200
  methods: {
201
+ startResize(e) {
202
+ e.preventDefault()
203
+ e.stopPropagation()
204
+
205
+ this.isResizing = true
206
+ this.startX = e.clientX
207
+ this.startWidth = this.siderWidth
208
+ },
209
+
210
+ onMouseMove(e) {
211
+ if (!this.isResizing) return
212
+
213
+ const moveX = e.clientX - this.startX
214
+ const newWidth = this.startWidth + moveX
215
+
216
+ if (newWidth < this.minWidth) return
217
+ if (newWidth > this.maxWidth) return
218
+
219
+ this.siderWidth = newWidth
220
+ },
221
+
222
+ stopResize() {
223
+ this.isResizing = false
224
+ },
175
225
  initListener(){
176
226
  Bus.$on('trigger-change',(data)=>{
177
227
  this.triggerChange(data)
@@ -357,6 +407,10 @@ export default {
357
407
  },
358
408
  mounted(){
359
409
  this.initTags();
410
+ const savedWidth = localStorage.getItem('siderWidth')
411
+ if (savedWidth) {
412
+ this.siderWidth = parseInt(savedWidth)
413
+ }
360
414
  },
361
415
  created(){
362
416
  this.initListener();
@@ -370,6 +424,34 @@ export default {
370
424
  <style lang="less">
371
425
  @import "@lambo-design/core/src/styles/default";
372
426
  @import "styles/color";
427
+ .resize-mask {
428
+ position: fixed;
429
+ left: 0;
430
+ top: 0;
431
+ width: 100vw;
432
+ height: 100vh;
433
+ z-index: 999999; /* 比所有菜单、浮层都高 */
434
+ background: transparent;
435
+ cursor: col-resize;
436
+ }
437
+ .sider-resize-bar {
438
+ position: absolute;
439
+ right: -3px;
440
+ top: 0;
441
+ width: 6px;
442
+ height: 100%;
443
+ cursor: col-resize;
444
+ z-index: 99999;
445
+ background: transparent;
446
+ }
447
+
448
+ .sider-resize-bar:hover {
449
+ background: #ddd;
450
+ }
451
+
452
+ .sider-resize-bar:hover {
453
+ background: #ddd;
454
+ }
373
455
  .pro-layout {
374
456
  height: 100vh;
375
457
  width: 100%;
@@ -380,6 +462,7 @@ export default {
380
462
  }
381
463
  .pro-layout-sider {
382
464
  overflow: hidden;
465
+ position: relative;
383
466
  .ivu-layout-sider-children {
384
467
  height: calc(100vh - 65px);
385
468
  overflow-y: scroll;