@lambo-design/pro-layout 1.0.0-beta.430 → 1.0.0-beta.432

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.430",
3
+ "version": "1.0.0-beta.432",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "lambo",
@@ -3,7 +3,7 @@
3
3
  <ul class="top-menu" :style="layoutSize === 'default' ? {height: '64px'} : {height: '50px'}" ref="topNav">
4
4
  <template v-for="(item,index) in topMenList" >
5
5
  <li class="top-menu-item"
6
- :class="{ 'active': notHomeIndex ? activeName === item.appId : 'backHome' === item.appId}"
6
+ :class="{ 'active': getIsActive(item) }"
7
7
  :key="item.appId"
8
8
  @click="selectApp(item.appId)">
9
9
  <div class="menu-item" :style="layoutSize === 'default' ? {paddingTop: '10px'} : {paddingTop: '2px'}">
@@ -19,6 +19,8 @@
19
19
  <script>
20
20
  import Bus from '@lambo-design/shared/utils/bus'
21
21
  import { deepCopy } from '@lambo-design/shared/utils/assist'
22
+ import _ from "lodash";
23
+ import {getSessionStorage} from "@lambo-design/shared/utils/n";
22
24
 
23
25
  export default {
24
26
  props: {
@@ -89,13 +91,27 @@ export default {
89
91
  }
90
92
  },
91
93
  initNav(data) {
92
- if (data.toString() === this.navList.toString() && this.topMenuNum === this.lastTopMenuNum) {
94
+ // 过滤掉首页项,获取真实的业务数据
95
+ const realData = data.filter(item => item.appId !== 'backHome');
96
+ if (realData.toString() === this.navList.toString() && this.topMenuNum === this.lastTopMenuNum) {
93
97
  return
94
98
  }
95
- this.navList = data
99
+ this.navList = realData
96
100
  this.lastTopMenuNum = this.topMenuNum
97
101
 
98
- this.topMenList = data
102
+ let dataClone = _.cloneDeep(realData);
103
+ // 如果配置了显示首页且显示样式是应用式,在列表最前面添加首页项
104
+ if (dataClone && dataClone.length > 0 && this.systemInfo.backToHome && this.systemInfo.backToHomeStyle === "app") {
105
+ const homeItem = {
106
+ appId: 'backHome',
107
+ name: this.systemInfo.backToHomeText || '首页',
108
+ icon: 'ios-home',
109
+ selected: false
110
+ };
111
+ dataClone.unshift(homeItem);
112
+ }
113
+
114
+ this.topMenList = dataClone
99
115
  this.$emit('topMen-list', this.topMenList);
100
116
 
101
117
  // 计算可以显示的菜单数量
@@ -103,6 +119,9 @@ export default {
103
119
 
104
120
  if (this.topMenList.length > 0) {
105
121
  let appId = this.topMenList[0].appId
122
+ if (this.systemInfo.backToHome && this.systemInfo.backToHomeStyle === "app") {
123
+ appId = this.topMenList[1].appId;
124
+ }
106
125
  for (let i = 0; i < this.topMenList.length; i++) {
107
126
  if (this.topMenList[i].selected == true) {
108
127
  appId = this.topMenList[i].appId
@@ -145,7 +164,7 @@ export default {
145
164
  let accumulatedWidth = 0;
146
165
  const reservedWidth = 40; // 预留一些边距
147
166
 
148
- this.navList.forEach((item, index) => {
167
+ this.topMenList.forEach((item, index) => {
149
168
  const estimatedWidth = this.estimateMenuItemWidth(item);
150
169
  if (accumulatedWidth + estimatedWidth <= this.availableWidth - reservedWidth) {
151
170
  accumulatedWidth += estimatedWidth;
@@ -208,6 +227,13 @@ export default {
208
227
 
209
228
  selectApp(appId) {
210
229
  if (appId) {
230
+ if (appId === 'backHome') {
231
+ Bus.$emit("change-app", {
232
+ appId,
233
+ appInfo: {}
234
+ });
235
+ return;
236
+ }
211
237
  this.activeName = appId
212
238
  let res = this.navList.filter(app => app.appId == appId)
213
239
  Bus.$emit('change-app', { appId, appInfo: res[0] })
@@ -241,6 +267,29 @@ export default {
241
267
  item.style.display = 'block';
242
268
  }
243
269
  });
270
+ },
271
+ getIsActive(item) {
272
+ // 如果不是首页模式,直接比较 appId
273
+ if (this.notHomeIndex) {
274
+ return this.activeName === item.appId;
275
+ }
276
+
277
+ // 如果是首页模式,检查当前 activeName 对应的应用是否隐藏了左侧菜单
278
+ const appList = getSessionStorage('appList');
279
+ if (appList && Array.isArray(appList) && appList.length > 0) {
280
+ // 查找当前 activeName 对应的应用
281
+ const currentApp = appList.find(app => app.appId === this.activeName);
282
+ // 如果找到应用且隐藏了左侧菜单,该应用应该保持激活状态
283
+ if (currentApp) {
284
+ const isHideLeftMenu = currentApp.extendProps?.is_hide_left_menu;
285
+ if ((isHideLeftMenu === '1' || isHideLeftMenu === 1) && this.activeName === item.appId) {
286
+ return true;
287
+ }
288
+ }
289
+ }
290
+
291
+ // 否则只有 backHome 项应该是激活的
292
+ return 'backHome' === item.appId;
244
293
  }
245
294
  },
246
295
  watch: {
@@ -4,7 +4,7 @@
4
4
  ref="topNav"
5
5
  mode="horizontal"
6
6
  theme="dark"
7
- :active-name="notHomeIndex ? activeName : 'backHome'"
7
+ :active-name="getActiveName()"
8
8
  @on-select="selectApp"
9
9
  >
10
10
  <template v-for="item in topMenList">
@@ -63,6 +63,7 @@ import Bus from "@lambo-design/shared/utils/bus";
63
63
  import { deepCopy } from "@lambo-design/shared/utils/assist";
64
64
  import { arraysEqual } from "@lambo-design/shared/utils/platform";
65
65
  import _ from "lodash";
66
+ import {getSessionStorage} from "@lambo-design/shared/utils/n";
66
67
 
67
68
  export default {
68
69
  name: "pro-layout-nav",
@@ -434,6 +435,29 @@ export default {
434
435
  return {
435
436
  type:item.icon
436
437
  }
438
+ },
439
+ getActiveName() {
440
+ // 如果不是首页模式,直接返回 activeName
441
+ if (this.notHomeIndex) {
442
+ return this.activeName;
443
+ }
444
+
445
+ // 如果是首页模式,检查当前 activeName 对应的应用是否隐藏了左侧菜单
446
+ const appList = getSessionStorage('appList');
447
+ if (appList && Array.isArray(appList) && appList.length > 0) {
448
+ // 查找当前 activeName 对应的应用
449
+ const currentApp = appList.find(app => app.appId === this.activeName);
450
+ // 如果找到应用且隐藏了左侧菜单,返回 activeName
451
+ if (currentApp) {
452
+ const isHideLeftMenu = currentApp.extendProps?.is_hide_left_menu;
453
+ if (isHideLeftMenu === '1' || isHideLeftMenu === 1) {
454
+ return this.activeName;
455
+ }
456
+ }
457
+ }
458
+
459
+ // 否则返回首页
460
+ return 'backHome';
437
461
  }
438
462
  },
439
463
  watch: {
package/src/index.vue CHANGED
@@ -341,12 +341,13 @@ export default {
341
341
  if(appInfo && appInfo.setting){
342
342
  appConfig=JSON.parse(appInfo.setting)
343
343
  }
344
- // 优先使用传入的 showLeftMenu prop,其次使用 appConfig,最后使用默认值
345
- if (this.showLeftMenu !== null) {
346
- this.isHideLeftMenu = this.showLeftMenu;
347
- } else if (appConfig && appConfig.is_hide_left_menu){
344
+
345
+ // 优先使用 appConfig,其次使用传入的 showLeftMenu prop,最后使用默认值
346
+ if (appConfig && appConfig.is_hide_left_menu){
348
347
  this.isHideLeftMenu=appConfig.is_hide_left_menu!='1'
349
- }else{
348
+ } else if (this.showLeftMenu !== null) {
349
+ this.isHideLeftMenu = this.showLeftMenu;
350
+ } else{
350
351
  this.isHideLeftMenu=true
351
352
  }
352
353