zzz-pc-view 0.0.52 → 0.0.53

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": "zzz-pc-view",
3
- "version": "0.0.52",
3
+ "version": "0.0.53",
4
4
  "main": "src/index.umd.js",
5
5
  "module": "src/index.es.js",
6
6
  "types": "src/index.d.ts",
package/src/index.es.js CHANGED
@@ -2389,7 +2389,30 @@ const setRoutes = (option) => {
2389
2389
  });
2390
2390
  };
2391
2391
  const navTreeRef = shallowRef(list$1);
2392
- const navChildrenMapRef = shallowRef(object);
2392
+ const navWithoutButtonsComputed = computed(() => toFlat(navTreeRef.value, "children"));
2393
+ const navWithoutButtonsMapComputed = computed(
2394
+ () => toKeyValue(navWithoutButtonsComputed.value, "id")
2395
+ );
2396
+ const navFoldersComputed = computed(
2397
+ () => navWithoutButtonsComputed.value.filter(
2398
+ (nav) => nav.type === 1
2399
+ /* FOLDER */
2400
+ )
2401
+ );
2402
+ const navMenusComputed = computed(
2403
+ () => navWithoutButtonsComputed.value.filter(
2404
+ (nav) => nav.type === 2
2405
+ /* MENU */
2406
+ )
2407
+ );
2408
+ const navButtonsRef = shallowRef([]);
2409
+ const navMenuButtonMapComputed = computed(() => toKeyValues(navButtonsRef.value, "parentId"));
2410
+ const navsComputed = computed(() => [...navWithoutButtonsComputed.value, ...navButtonsRef.value]);
2411
+ const navMapComputed = computed(() => toKeyValue(navsComputed.value, "id"));
2412
+ const setMenuButtons = (navButtons) => {
2413
+ const navWithoutButtonsMap = navWithoutButtonsMapComputed.value;
2414
+ navButtonsRef.value = navButtons.filter((navButton) => navWithoutButtonsMap[navButton.parentId]);
2415
+ };
2393
2416
  const setNavTree = (navFolders, navMenus, navLinks) => {
2394
2417
  const buildList = navMenus.filter((navMenu) => !navMenu.isHide);
2395
2418
  buildList.push(...navLinks);
@@ -2417,23 +2440,6 @@ const setNavTree = (navFolders, navMenus, navLinks) => {
2417
2440
  childrenMap[key2] = sort(childrenMap[key2], "orderNo");
2418
2441
  }
2419
2442
  navTreeRef.value = sort(roots, "orderNo");
2420
- navChildrenMapRef.value = childrenMap;
2421
- };
2422
- const menuButtonMapRef = shallowRef({});
2423
- const setMenuButtonMap = (navButtons) => {
2424
- menuButtonMapRef.value = toKeyValues(navButtons, "parentId");
2425
- };
2426
- const navsRef = shallowRef(list$1);
2427
- const navMapComputed = computed(() => toKeyValue(navsRef.value, "id"));
2428
- const navFoldersRef = shallowRef(list$1);
2429
- const navMenusRef = shallowRef(list$1);
2430
- const navButtonsRef = shallowRef(list$1);
2431
- const setNavsCategory = (navsCategory) => {
2432
- const { navFolders, navMenus, navLinks, navButtons } = navsCategory;
2433
- navsRef.value = [...navFolders, ...navMenus, ...navLinks, ...navButtons];
2434
- navFoldersRef.value = navFolders;
2435
- navMenusRef.value = [...navMenus, ...navLinks];
2436
- navButtonsRef.value = navButtons;
2437
2443
  };
2438
2444
  const setNavs = (option) => {
2439
2445
  const pageViewMap = getComponentViewMap(option.pageViewMap);
@@ -2441,33 +2447,25 @@ const setNavs = (option) => {
2441
2447
  const { navMenus, navButtons } = navsCategory;
2442
2448
  setRoutes({
2443
2449
  RootPageView: option.RootPageView,
2444
- // 根页面视图
2445
2450
  navMenus,
2446
- // 导航菜单
2447
2451
  pageViewMap,
2448
- // 页面视图映射
2449
2452
  navButtons,
2450
- // 导航按钮
2451
2453
  NotFoundPageView: option.NotFoundPageView
2452
- // 404页面视图
2453
2454
  });
2454
2455
  setNavTree(navsCategory.navFolders, navsCategory.navMenus, navsCategory.navLinks);
2455
- setMenuButtonMap(navButtons);
2456
- setNavsCategory(navsCategory);
2456
+ setMenuButtons(navButtons);
2457
2457
  };
2458
2458
  const clear = (option) => {
2459
2459
  navTreeRef.value = list$1;
2460
- navsRef.value = list$1;
2461
- navFoldersRef.value = list$1;
2462
- navMenusRef.value = list$1;
2463
2460
  navButtonsRef.value = list$1;
2464
- menuButtonMapRef.value = object;
2465
- navChildrenMapRef.value = object;
2466
2461
  if (option) {
2467
2462
  const { path } = option;
2468
2463
  router.addRoute({
2464
+ // 根路由的名称
2469
2465
  name: ROOT_ROUTE_NAME,
2466
+ // 根路由的路径
2470
2467
  path,
2468
+ // 根路由对应的组件
2471
2469
  component: option.PageView
2472
2470
  });
2473
2471
  router.replace(path).then(() => {
@@ -2536,61 +2534,52 @@ const response = {
2536
2534
  return navTreeRef.value;
2537
2535
  },
2538
2536
  /**
2539
- * 获取所有导航项的 getter 方法。
2540
- * 返回一个包含所有导航项的数组,这些导航项存储在 navsRef 引用中。
2541
- * @returns {ZNav[]} - 所有导航项的数组
2537
+ * 获取包含所有导航项的数组的 getter 方法。
2538
+ * 该方法返回 `navsComputed` 计算属性的值,包含所有的导航项,方便统一处理导航项。
2539
+ * @returns {ZNav[]} - 包含所有导航项的数组。
2542
2540
  */
2543
2541
  get navs() {
2544
- return navsRef.value;
2542
+ return navsComputed.value;
2545
2543
  },
2546
2544
  /**
2547
2545
  * 获取导航项 ID 到导航项对象的映射的 getter 方法。
2548
- * 该方法返回 `navMapComputed` 计算属性的值,此值是一个映射,
2549
- * 可以通过导航项的 ID 快速查找对应的导航项对象。
2550
- * @returns {Record<ZNav['id'], ZNav>} - 导航项 ID 到导航项对象的映射
2546
+ * 该方法返回 `navMapComputed` 计算属性的值,键为导航项的 ID,值为对应的导航项对象,方便通过 ID 快速查找导航项。
2547
+ * @returns {Record<ZNav['id'], ZNav>} - 导航项 ID 到导航项对象的映射。
2551
2548
  */
2552
2549
  get navMap() {
2553
2550
  return navMapComputed.value;
2554
2551
  },
2555
2552
  /**
2556
- * 获取导航目录项的 getter 方法。
2557
- * 返回一个包含所有导航目录项的数组,这些导航目录项存储在 navFoldersRef 引用中。
2558
- * @returns {ZNavFolder[]} - 导航目录项的数组
2553
+ * 获取导航目录项数组的 getter 方法。
2554
+ * 该方法返回 `navFoldersComputed` 计算属性的值,包含所有的导航目录项。
2555
+ * @returns {ZNavFolder[]} - 导航目录项数组。
2559
2556
  */
2560
2557
  get navFolders() {
2561
- return navFoldersRef.value;
2558
+ return navFoldersComputed.value;
2562
2559
  },
2563
2560
  /**
2564
- * 获取导航菜单和导航链接项的 getter 方法。
2565
- * 返回一个包含所有导航菜单和导航链接项的数组,这些项存储在 navMenusRef 引用中。
2566
- * @returns {(ZNavMenu | ZNavLink)[]} - 导航菜单和导航链接项的数组
2561
+ * 获取导航菜单项数组的 getter 方法。
2562
+ * 该方法返回 `navMenusComputed` 计算属性的值,包含所有的导航菜单项。
2563
+ * @returns {ZNavMenu[]} - 导航菜单项数组。
2567
2564
  */
2568
2565
  get navMenus() {
2569
- return navMenusRef.value;
2566
+ return navMenusComputed.value;
2570
2567
  },
2571
2568
  /**
2572
- * 获取导航按钮项的 getter 方法。
2573
- * 返回一个包含所有导航按钮项的数组,这些导航按钮项存储在 navButtonsRef 引用中。
2574
- * @returns {ZNavButton[]} - 导航按钮项的数组
2569
+ * 获取导航按钮项数组的 getter 方法。
2570
+ * 该方法返回 `navButtonsRef` 浅引用的值,包含所有的导航按钮项。
2571
+ * @returns {ZNavButton[]} - 导航按钮项数组。
2575
2572
  */
2576
2573
  get navButtons() {
2577
2574
  return navButtonsRef.value;
2578
2575
  },
2579
2576
  /**
2580
- * 获取菜单按钮映射的 getter 方法。
2581
- * 返回一个包含所有菜单按钮的映射对象,其中键为父级导航项的 ID,值为该父级导航项下的按钮数组。
2582
- * @returns {Record<ZBaseNav['id'], ZNavButton[]>} - 菜单按钮映射对象
2583
- */
2584
- get menuButtonMap() {
2585
- return menuButtonMapRef.value;
2586
- },
2587
- /**
2588
- * 获取导航目录的子导航项映射的 getter 方法。
2589
- * @type {Function}
2590
- * @returns {Record<ZNavFolder['id'], ZNavWithoutButton[]>} - 导航目录的子导航项映射。
2577
+ * 获取父级导航项 ID 到导航按钮项数组的映射的 getter 方法。
2578
+ * 该方法返回 `navMenuButtonMapComputed` 计算属性的值,键为父级导航项的 ID,值为该父级导航项下的导航按钮项数组,方便通过父级导航项 ID 快速查找对应的导航按钮项。
2579
+ * @returns {Record<ZNavButton['parentId'], ZNavButton[]>} - 父级导航项 ID 到导航按钮项数组的映射。
2591
2580
  */
2592
- get navChildrenMap() {
2593
- return navChildrenMapRef.value;
2581
+ get navMenuButtonMap() {
2582
+ return navMenuButtonMapComputed.value;
2594
2583
  },
2595
2584
  /**
2596
2585
  * 获取当前路由对应的根导航目录的 getter 方法。