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 +1 -1
- package/src/index.es.js +50 -61
- package/src/index.umd.js +2 -2
- package/src/webUtils/useNavStore.d.ts +40 -29
package/package.json
CHANGED
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
|
|
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
|
-
|
|
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
|
-
*
|
|
2540
|
-
*
|
|
2541
|
-
* @returns {ZNav[]} -
|
|
2537
|
+
* 获取包含所有导航项的数组的 getter 方法。
|
|
2538
|
+
* 该方法返回 `navsComputed` 计算属性的值,包含所有的导航项,方便统一处理导航项。
|
|
2539
|
+
* @returns {ZNav[]} - 包含所有导航项的数组。
|
|
2542
2540
|
*/
|
|
2543
2541
|
get navs() {
|
|
2544
|
-
return
|
|
2542
|
+
return navsComputed.value;
|
|
2545
2543
|
},
|
|
2546
2544
|
/**
|
|
2547
2545
|
* 获取导航项 ID 到导航项对象的映射的 getter 方法。
|
|
2548
|
-
* 该方法返回 `navMapComputed`
|
|
2549
|
-
*
|
|
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
|
-
*
|
|
2557
|
-
*
|
|
2558
|
-
* @returns {ZNavFolder[]} -
|
|
2553
|
+
* 获取导航目录项数组的 getter 方法。
|
|
2554
|
+
* 该方法返回 `navFoldersComputed` 计算属性的值,包含所有的导航目录项。
|
|
2555
|
+
* @returns {ZNavFolder[]} - 导航目录项数组。
|
|
2559
2556
|
*/
|
|
2560
2557
|
get navFolders() {
|
|
2561
|
-
return
|
|
2558
|
+
return navFoldersComputed.value;
|
|
2562
2559
|
},
|
|
2563
2560
|
/**
|
|
2564
|
-
*
|
|
2565
|
-
*
|
|
2566
|
-
* @returns {
|
|
2561
|
+
* 获取导航菜单项数组的 getter 方法。
|
|
2562
|
+
* 该方法返回 `navMenusComputed` 计算属性的值,包含所有的导航菜单项。
|
|
2563
|
+
* @returns {ZNavMenu[]} - 导航菜单项数组。
|
|
2567
2564
|
*/
|
|
2568
2565
|
get navMenus() {
|
|
2569
|
-
return
|
|
2566
|
+
return navMenusComputed.value;
|
|
2570
2567
|
},
|
|
2571
2568
|
/**
|
|
2572
|
-
*
|
|
2573
|
-
*
|
|
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
|
-
*
|
|
2581
|
-
*
|
|
2582
|
-
* @returns {Record<
|
|
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
|
|
2593
|
-
return
|
|
2581
|
+
get navMenuButtonMap() {
|
|
2582
|
+
return navMenuButtonMapComputed.value;
|
|
2594
2583
|
},
|
|
2595
2584
|
/**
|
|
2596
2585
|
* 获取当前路由对应的根导航目录的 getter 方法。
|