@ibiz-template/runtime 0.7.41-alpha.64 → 0.7.41-alpha.65

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/dist/index.esm.js CHANGED
@@ -40371,17 +40371,17 @@ var AppMenuController = class extends ControlController {
40371
40371
  }
40372
40372
  /**
40373
40373
  * @description 保存自定义菜单模型
40374
- * @param {IAppMenuItem[]} curMenuItems 当前显示的菜单项集合
40374
+ * @param {Array<{ id: string; order: number; hidden: boolean }>} items 有权限的菜单项集合
40375
40375
  * @returns {*} {Promise<void>}
40376
40376
  * @memberof AppMenuController
40377
40377
  */
40378
- async saveCustomMenusModel(curMenuItems) {
40379
- const model = curMenuItems.map((item) => ({
40380
- id: item.id
40381
- }));
40382
- await this.customController.saveCustomModelData(model);
40383
- this.saveConfigs = model;
40378
+ async saveMobCustomMenusModel(items) {
40379
+ await this.customController.saveCustomModelData(items);
40380
+ this.saveConfigs = items;
40384
40381
  if (ibiz.env.isMob) {
40382
+ this.state.mobAuthedMenuItems = this.calcMobCustomSorteItems(
40383
+ this.state.mobAuthedMenuItems
40384
+ );
40385
40385
  this.state.mobMenuItems = this.calcMobCustomVisibleItems(
40386
40386
  this.state.mobAuthedMenuItems
40387
40387
  );
@@ -40415,13 +40415,14 @@ var AppMenuController = class extends ControlController {
40415
40415
  */
40416
40416
  initMobMenuItems() {
40417
40417
  const isDefaultMenu = !this.model.appMenuStyle;
40418
- const mobAuthedMenuItems = this.calcMobAuthedMenuItems(
40418
+ let mobAuthedMenuItems = this.calcMobAuthedMenuItems(
40419
40419
  this.model.appMenuItems || [],
40420
40420
  isDefaultMenu
40421
40421
  );
40422
40422
  let mobMenuItems = [];
40423
40423
  if (this.model.enableCustomized) {
40424
40424
  if (this.saveConfigs.length > 0) {
40425
+ mobAuthedMenuItems = this.calcMobCustomSorteItems(mobAuthedMenuItems);
40425
40426
  mobMenuItems = this.calcMobCustomVisibleItems(mobAuthedMenuItems);
40426
40427
  } else if (isDefaultMenu) {
40427
40428
  mobMenuItems = mobAuthedMenuItems.slice(0, 4);
@@ -40489,7 +40490,7 @@ var AppMenuController = class extends ControlController {
40489
40490
  }
40490
40491
  items.forEach((item) => {
40491
40492
  var _a3;
40492
- if (!itemIdMap[item.id])
40493
+ if (!itemIdMap[item.id] || itemIdMap[item.id].hidden)
40493
40494
  return;
40494
40495
  const itemData = { ...item };
40495
40496
  if ((_a3 = item.appMenuItems) == null ? void 0 : _a3.length) {
@@ -40503,6 +40504,43 @@ var AppMenuController = class extends ControlController {
40503
40504
  });
40504
40505
  return customItems;
40505
40506
  }
40507
+ /**
40508
+ * @description 计算移动端自定义模式下菜单项的排序
40509
+ * @private
40510
+ * @param {IAppMenuItem[]} items
40511
+ * @param {IData} [idMap]
40512
+ * @returns {*} {IAppMenuItem[]}
40513
+ * @memberof AppMenuController
40514
+ */
40515
+ calcMobCustomSorteItems(items, idMap) {
40516
+ const customItems = [];
40517
+ let itemIdMap = idMap;
40518
+ if (!itemIdMap) {
40519
+ itemIdMap = {};
40520
+ this.saveConfigs.forEach((config) => {
40521
+ itemIdMap[config.id] = config;
40522
+ });
40523
+ }
40524
+ items.forEach((item) => {
40525
+ var _a3;
40526
+ const itemData = { ...item };
40527
+ if ((_a3 = item.appMenuItems) == null ? void 0 : _a3.length) {
40528
+ const childItems = this.calcMobCustomSorteItems(
40529
+ item.appMenuItems,
40530
+ itemIdMap
40531
+ );
40532
+ itemData.appMenuItems = childItems;
40533
+ }
40534
+ customItems.push(itemData);
40535
+ });
40536
+ customItems.sort((a, b) => {
40537
+ var _a3, _b2;
40538
+ const orderA = ((_a3 = itemIdMap[a.id]) == null ? void 0 : _a3.order) || 0;
40539
+ const orderB = ((_b2 = itemIdMap[b.id]) == null ? void 0 : _b2.order) || 0;
40540
+ return orderA - orderB;
40541
+ });
40542
+ return customItems;
40543
+ }
40506
40544
  /**
40507
40545
  * 初始化菜单项的适配器
40508
40546
  * @author lxm