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

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.
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.426",
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",
@@ -10,8 +10,8 @@
10
10
  <Col>
11
11
  <div class="system-name" :style="nameStyle">{{systemName}}</div>
12
12
  </Col>
13
- <Col v-if="'1' === systemInfo.backToHome">
14
- <Button class="home-btn" shape="circle" icon="ios-home">返回工作台</Button>
13
+ <Col v-if="'1' === systemInfo.backToHome && 'button' === systemInfo.backToHomeStyle">
14
+ <Button class="home-btn" shape="circle" icon="ios-home">{{ systemInfo.backToHomeText || '返回工作台' }}</Button>
15
15
  </Col>
16
16
  </Row>
17
17
  </div>
@@ -185,7 +185,7 @@ export default {
185
185
  cursor: pointer;
186
186
  border: none;
187
187
  outline: none;
188
- color: var(--primary-color) !important;
188
+ color: var(--primary-color,@_primary-color) !important;
189
189
  background: #FFFFFF !important;
190
190
  padding: 8px 14px;
191
191
  display: flex;
@@ -131,15 +131,29 @@ export default {
131
131
  }
132
132
  },
133
133
  initNav(data) {
134
+ // 过滤掉首页项,获取真实的业务数据
135
+ const realData = data.filter(item => item.appId !== 'backHome');
134
136
  if (
135
- _.some(data, (app) => app.children?.length) || // 分组以后会死循环调用,中断一下
136
- (arraysEqual(this.originNavList, data) &&
137
+ _.some(realData, (app) => app.children?.length) || // 分组以后会死循环调用,中断一下
138
+ (arraysEqual(this.originNavList, realData) &&
137
139
  this.topMenuNum === this.lastTopMenuNum)
138
140
  ) {
139
141
  return;
140
142
  }
141
- this.originNavList = data;
142
- let dataClone = _.cloneDeep(data);
143
+ this.originNavList = realData;
144
+ let dataClone = _.cloneDeep(realData);
145
+
146
+ // 如果配置了显示首页且显示样式是应用式,在列表最前面添加首页项
147
+ if (dataClone && dataClone.length > 0 && this.systemInfo.backToHome && this.systemInfo.backToHomeStyle === "app") {
148
+ const homeItem = {
149
+ appId: 'backHome',
150
+ name: this.systemInfo.backToHomeText || '首页',
151
+ icon: 'ios-home',
152
+ selected: false
153
+ };
154
+ dataClone.unshift(homeItem);
155
+ }
156
+
143
157
  let parentNameEnum = {};
144
158
  _.forEach(dataClone, (app) => {
145
159
  let extendProps = app.extendProps;
@@ -190,6 +204,9 @@ export default {
190
204
  }
191
205
  if (this.navList.length > 0) {
192
206
  let appId = this.navList[0].appId;
207
+ if (this.systemInfo.backToHome && this.systemInfo.backToHomeStyle === "app") {
208
+ appId = this.navList[1].appId;
209
+ }
193
210
  for (let i = 0; i < this.navList.length; i++) {
194
211
  if (this.navList[i].selected == true) {
195
212
  appId = this.navList[i].appId;
@@ -209,6 +226,13 @@ export default {
209
226
  },
210
227
  selectApp(appId) {
211
228
  if (appId) {
229
+ if (appId === 'backHome') {
230
+ Bus.$emit("change-app", {
231
+ appId,
232
+ appInfo: {}
233
+ });
234
+ return;
235
+ }
212
236
  let res = this.originNavList.filter((app) => app.appId == appId);
213
237
  if (res && res.length > 0) {
214
238
  Bus.$emit("change-app", { appId, appInfo: res[0] });
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;