@whitesev/utils 2.4.5 → 2.4.6

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.
@@ -1243,43 +1243,61 @@ System.register('Utils', [], (function (exports) {
1243
1243
  }
1244
1244
  /**
1245
1245
  * 新增菜单数据
1246
- * @param paramData
1246
+ * @param menuOption
1247
1247
  */
1248
- add(paramData) {
1249
- if (Array.isArray(paramData)) {
1250
- for (const _paramData of paramData) {
1251
- // @ts-ignore
1248
+ __add(menuOption) {
1249
+ if (Array.isArray(menuOption)) {
1250
+ for (let index = 0; index < menuOption.length; index++) {
1251
+ const option = menuOption[index];
1252
1252
  this.MenuHandle.$data.data.push({
1253
- data: _paramData,
1253
+ data: option,
1254
1254
  id: void 0,
1255
1255
  });
1256
1256
  }
1257
1257
  }
1258
1258
  else {
1259
- // @ts-ignore
1260
1259
  this.MenuHandle.$data.data.push({
1261
- data: paramData,
1260
+ data: menuOption,
1262
1261
  id: void 0,
1263
1262
  });
1264
1263
  }
1264
+ }
1265
+ /**
1266
+ * 新增菜单数据
1267
+ *
1268
+ * 自动调用.update()
1269
+ * @param menuOption
1270
+ */
1271
+ add(menuOption) {
1272
+ this.__add(menuOption);
1265
1273
  this.update();
1266
1274
  }
1267
1275
  /**
1268
1276
  * 更新菜单数据
1277
+ *
1278
+ * 实现方式:先取消注册所有已注册的菜单、再依次注册所有菜单项
1279
+ *
1280
+ * 如果菜单不存在,新增菜单项
1281
+ *
1282
+ * 如果菜单已存在,新菜单项覆盖旧的菜单项
1269
1283
  * @param options 数据
1270
1284
  */
1271
1285
  update(options) {
1272
- let optionsList = [];
1286
+ let menuOptionList = [];
1273
1287
  if (Array.isArray(options)) {
1274
- optionsList = [...optionsList, ...options];
1288
+ menuOptionList = [...menuOptionList, ...options];
1275
1289
  }
1276
1290
  else if (options != null) {
1277
- optionsList = [...optionsList, options];
1291
+ menuOptionList = [...menuOptionList, options];
1278
1292
  }
1279
- optionsList.forEach((item) => {
1280
- let targetMenu = this.MenuHandle.getMenuOption(item.key);
1281
- if (targetMenu) {
1282
- Object.assign(targetMenu, item);
1293
+ menuOptionList.forEach((menuOption) => {
1294
+ let oldMenuOption = this.MenuHandle.getMenuOption(menuOption.key);
1295
+ if (oldMenuOption) {
1296
+ // 覆盖
1297
+ Object.assign(oldMenuOption, menuOption);
1298
+ }
1299
+ else {
1300
+ this.__add(menuOption);
1283
1301
  }
1284
1302
  });
1285
1303
  this.MenuHandle.$data.data.forEach((value) => {
@@ -1300,6 +1318,7 @@ System.register('Utils', [], (function (exports) {
1300
1318
  /**
1301
1319
  * 根据键值获取enable值
1302
1320
  * @param menuKey 菜单-键key
1321
+ * @deprecated
1303
1322
  */
1304
1323
  get(menuKey) {
1305
1324
  return this.getEnable(menuKey);
@@ -1323,7 +1342,7 @@ System.register('Utils', [], (function (exports) {
1323
1342
  * @param menuKey 菜单-键key
1324
1343
  */
1325
1344
  getShowTextValue(menuKey) {
1326
- return this.MenuHandle.getMenuHandledOption(menuKey).showText(this.getText(menuKey), this.get(menuKey));
1345
+ return this.MenuHandle.getMenuHandledOption(menuKey).showText(this.getText(menuKey), this.getEnable(menuKey));
1327
1346
  }
1328
1347
  /**
1329
1348
  * 获取当前已注册菜单的id
@@ -4077,7 +4096,7 @@ System.register('Utils', [], (function (exports) {
4077
4096
  this.windowApi = new WindowApi(option);
4078
4097
  }
4079
4098
  /** 版本号 */
4080
- version = "2024.11.1";
4099
+ version = "2024.11.5";
4081
4100
  addStyle(cssText) {
4082
4101
  if (typeof cssText !== "string") {
4083
4102
  throw new Error("Utils.addStyle 参数cssText 必须为String类型");
@@ -7188,6 +7207,15 @@ System.register('Utils', [], (function (exports) {
7188
7207
  generateUUID = GenerateUUID;
7189
7208
  /**
7190
7209
  * 自定义的动态响应对象
7210
+ * @example
7211
+ * let vue = new Utils.Vue();
7212
+ * let reactive = new vue.reactive({});
7213
+ * vue.watch(()=>reactive["name"], (newValue, oldValue)=>{
7214
+ * console.log("newValue ==> " + newValue);
7215
+ * console.log("oldValue ==> " + oldValue);
7216
+ * })
7217
+ * vue["name"] = "测试";
7218
+ * > "测试"
7191
7219
  */
7192
7220
  Vue = Vue;
7193
7221
  }