Commit b67cf22dfc8d27428b045f47fcd9e2797b81a81d

Authored by Vben
1 parent f55ad2f9

feat(route): add hideChildrenInMenu option close #346

package.json
... ... @@ -118,14 +118,15 @@
118 118 "vite-plugin-style-import": "^0.8.1",
119 119 "vite-plugin-svg-icons": "^0.3.5",
120 120 "vite-plugin-theme": "^0.5.0",
121   - "vite-plugin-windicss": "0.9.1",
  121 + "vite-plugin-windicss": "0.9.2",
122 122 "vue-eslint-parser": "^7.6.0",
123 123 "yargs": "^16.2.0"
124 124 },
125 125 "resolutions": {
126 126 "//": "Used to install imagemin dependencies, because imagemin may not be installed in China.If it is abroad, you can delete it",
127 127 "bin-wrapper": "npm:bin-wrapper-china",
128   - "rollup": "2.41.4"
  128 + "rollup": "2.41.5",
  129 + "vite": "2.0.5"
129 130 },
130 131 "repository": {
131 132 "type": "git",
... ...
src/components/Authority/src/index.vue
... ... @@ -3,12 +3,10 @@
3 3 -->
4 4 <script lang="ts">
5 5 import type { PropType } from 'vue';
6   - import { defineComponent, unref } from 'vue';
  6 + import { defineComponent } from 'vue';
7 7  
8   - import { PermissionModeEnum } from '/@/enums/appEnum';
9 8 import { RoleEnum } from '/@/enums/roleEnum';
10 9  
11   - import { useRootSetting } from '/@/hooks/setting/useRootSetting';
12 10 import { usePermission } from '/@/hooks/web/usePermission';
13 11  
14 12 import { getSlot } from '/@/utils/helper/tsxHelper';
... ... @@ -28,23 +26,12 @@
28 26 },
29 27 },
30 28 setup(props, { slots }) {
31   - const { getPermissionMode } = useRootSetting();
32 29 const { hasPermission } = usePermission();
33 30  
34 31 /**
35 32 * Render role button
36 33 */
37   - function renderRoleAuth() {
38   - const { value } = props;
39   - if (!value) {
40   - return getSlot(slots);
41   - }
42   - return hasPermission(value) ? getSlot(slots) : null;
43   - }
44   -
45   - // Render coding button
46   - // Here only judge whether it is included, the specific implementation can be written according to the project logic
47   - function renderCodeAuth() {
  34 + function renderAuth() {
48 35 const { value } = props;
49 36 if (!value) {
50 37 return getSlot(slots);
... ... @@ -53,18 +40,8 @@
53 40 }
54 41  
55 42 return () => {
56   - const mode = unref(getPermissionMode);
57 43 // Role-based value control
58   - if (mode === PermissionModeEnum.ROLE) {
59   - return renderRoleAuth();
60   - }
61   -
62   - // Based on background role permission control
63   - if (mode === PermissionModeEnum.BACK) {
64   - return renderCodeAuth();
65   - }
66   -
67   - return getSlot(slots);
  44 + return renderAuth();
68 45 };
69 46 },
70 47 });
... ...
src/components/CountDown/src/CountdownInput.vue
... ... @@ -18,8 +18,8 @@
18 18  
19 19 export default defineComponent({
20 20 name: 'CountDownInput',
21   - inheritAttrs: false,
22 21 components: { [Input.name]: Input, CountButton },
  22 + inheritAttrs: false,
23 23 props: {
24 24 value: propTypes.string,
25 25 size: propTypes.oneOf(['default', 'large', 'small']),
... ...
src/components/Form/src/components/ApiSelect.vue
... ... @@ -30,11 +30,11 @@
30 30  
31 31 export default defineComponent({
32 32 name: 'ApiSelect',
33   - inheritAttrs: false,
34 33 components: {
35 34 Select,
36 35 LoadingOutlined,
37 36 },
  37 + inheritAttrs: false,
38 38 props: {
39 39 value: propTypes.string,
40 40 numberToString: propTypes.bool,
... ...
src/components/Table/src/components/settings/index.vue
1 1 <template>
2 2 <div class="table-settings">
3   - <RedoSetting v-if="getSetting.size" />
4   - <SizeSetting v-if="getSetting.redo" />
  3 + <RedoSetting v-if="getSetting.redo" />
  4 + <SizeSetting v-if="getSetting.size" />
5 5 <ColumnSetting v-if="getSetting.setting" />
6 6 <FullScreenSetting v-if="getSetting.fullScreen" />
7 7 </div>
... ...
src/layouts/default/header/components/Breadcrumb.vue
... ... @@ -54,6 +54,7 @@
54 54 watchEffect(async () => {
55 55 if (currentRoute.value.name === REDIRECT_NAME) return;
56 56 const menus = await getMenus();
  57 +
57 58 const routeMatched = currentRoute.value.matched;
58 59 const cur = routeMatched?.[routeMatched.length - 1];
59 60 let path = currentRoute.value.path;
... ... @@ -63,26 +64,20 @@
63 64 }
64 65  
65 66 const parent = getAllParentPath(menus, path);
66   -
67 67 const filterMenus = menus.filter((item) => item.path === parent[0]);
68   -
69 68 const matched = getMatched(filterMenus, parent) as any;
70 69  
71 70 if (!matched || matched.length === 0) return;
72 71  
73   - let breadcrumbList = filterItem(matched);
74   -
75   - const filterBreadcrumbList = breadcrumbList.filter(
76   - (item) => item.path !== PageEnum.BASE_HOME
77   - );
  72 + const breadcrumbList = filterItem(matched);
78 73  
79 74 if (currentRoute.value.meta?.currentActiveMenu) {
80   - filterBreadcrumbList.push(({
  75 + breadcrumbList.push(({
81 76 ...currentRoute.value,
82 77 name: currentRoute.value.meta?.title || currentRoute.value.name,
83 78 } as unknown) as RouteLocationMatched);
84 79 }
85   - routes.value = filterBreadcrumbList;
  80 + routes.value = breadcrumbList;
86 81 });
87 82  
88 83 function getMatched(menus: Menu[], parent: string[]) {
... ... @@ -103,12 +98,10 @@
103 98  
104 99 function filterItem(list: RouteLocationMatched[]) {
105 100 let resultList = filter(list, (item) => {
106   - const { meta } = item;
107   -
  101 + const { meta, name } = item;
108 102 if (!meta) {
109   - return false;
  103 + return !!name;
110 104 }
111   -
112 105 const { title, hideBreadcrumb, hideMenu } = meta;
113 106 if (!title || hideBreadcrumb || hideMenu) {
114 107 return false;
... ...
src/router/helper/menuHelper.ts
... ... @@ -13,11 +13,15 @@ export function getAllParentPath&lt;T = Recordable&gt;(treeData: T[], path: string) {
13 13 function joinParentPath(menus: Menu[], parentPath = '') {
14 14 for (let index = 0; index < menus.length; index++) {
15 15 const menu = menus[index];
16   - const p = menu.path.startsWith('/') ? menu.path : `/${menu.path}`;
17   - const parent = isUrl(menu.path) ? menu.path : `${parentPath}${p}`;
18   - menus[index].path = parent;
  16 + // https://next.router.vuejs.org/guide/essentials/nested-routes.html
  17 + // Note that nested paths that start with / will be treated as a root path.
  18 + // This allows you to leverage the component nesting without having to use a nested URL.
  19 + if (!(menu.path.startsWith('/') || isUrl(menu.path))) {
  20 + // path doesn't start with /, nor is it a url, join parent path
  21 + menu.path = `${parentPath}/${menu.path}`;
  22 + }
19 23 if (menu?.children?.length) {
20   - joinParentPath(menu.children, parent);
  24 + joinParentPath(menu.children, menu.path);
21 25 }
22 26 }
23 27 }
... ...
src/router/menus/index.ts
... ... @@ -66,9 +66,9 @@ export async function getShallowMenus(): Promise&lt;Menu[]&gt; {
66 66  
67 67 // Get the children of the menu
68 68 export async function getChildrenMenus(parentPath: string) {
69   - const menus = await getAsyncMenus();
  69 + const menus = await getMenus();
70 70 const parent = menus.find((item) => item.path === parentPath);
71   - if (!parent || !parent.children) return [] as Menu[];
  71 + if (!parent || !parent.children || !!parent?.meta?.hideChildrenInMenu) return [] as Menu[];
72 72 const routes = router.getRoutes();
73 73  
74 74 return !isBackMode() ? filter(parent.children, basicFilter(routes)) : parent.children;
... ...
src/router/routes/modules/dashboard.ts
... ... @@ -11,7 +11,6 @@ const dashboard: AppRouteModule = {
11 11 meta: {
12 12 icon: 'ion:grid-outline',
13 13 title: t('routes.dashboard.dashboard'),
14   - hideChildrenInMenu: true,
15 14 },
16 15 children: [
17 16 {
... ...
vite.config.ts
... ... @@ -18,7 +18,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig =&gt; {
18 18 // The boolean type read by loadEnv is a string. This function can be converted to boolean type
19 19 const viteEnv = wrapperEnv(env);
20 20  
21   - const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY, VITE_DROP_CONSOLE, VITE_LEGACY } = viteEnv;
  21 + const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY, VITE_DROP_CONSOLE } = viteEnv;
22 22  
23 23 const isBuild = command === 'build';
24 24  
... ... @@ -45,7 +45,6 @@ export default ({ command, mode }: ConfigEnv): UserConfig =&gt; {
45 45 build: {
46 46 // minify: 'esbuild',
47 47 outDir: OUTPUT_DIR,
48   - polyfillDynamicImport: VITE_LEGACY,
49 48 terserOptions: {
50 49 compress: {
51 50 keep_infinity: true,
... ...
yarn.lock
... ... @@ -2379,15 +2379,15 @@
2379 2379 dependencies:
2380 2380 vue-demi latest
2381 2381  
2382   -"@windicss/plugin-utils@0.9.1":
2383   - version "0.9.1"
2384   - resolved "https://registry.npmjs.org/@windicss/plugin-utils/-/plugin-utils-0.9.1.tgz#6219854bbf87e142617b79234820b0c1a151cc6e"
2385   - integrity sha512-DLxOg1mJTio9W069g3RK5KpSljD/aeDJvqwgAf9JSwXxkg/9xOcDWNEWo8MIkkrq0WtpdaokM+quvdlRCl2IVA==
  2382 +"@windicss/plugin-utils@0.9.2":
  2383 + version "0.9.2"
  2384 + resolved "https://registry.npmjs.org/@windicss/plugin-utils/-/plugin-utils-0.9.2.tgz#0cf68a7fc978c1cdba172d2aa5e89f52e45f54bb"
  2385 + integrity sha512-mYKqjRVc2NYHp5uA5cDyHtqHFNK1pBC6RYYLywuUPTxsUVszYGnRbUXSeZwisGrHqD5dlHtpcefM5QOuTm53KA==
2386 2386 dependencies:
2387 2387 fast-glob "^3.2.5"
2388 2388 micromatch "^4.0.2"
2389 2389 sucrase "^3.17.1"
2390   - windicss "^2.4.7"
  2390 + windicss "^2.5.0"
2391 2391  
2392 2392 "@zxcvbn-ts/core@^0.3.0":
2393 2393 version "0.3.0"
... ... @@ -9920,10 +9920,10 @@ rollup-plugin-visualizer@^4.2.1:
9920 9920 source-map "^0.7.3"
9921 9921 yargs "^16.2.0"
9922 9922  
9923   -rollup@2.41.4, rollup@^0.63.4, rollup@^2.25.0, rollup@^2.38.5, rollup@^2.40.0:
9924   - version "2.41.4"
9925   - resolved "https://registry.npmjs.org/rollup/-/rollup-2.41.4.tgz#2a674d64db4322482d440699acb060dc6dd9e65f"
9926   - integrity sha512-f9IHfMO8p2Y8OdisI7Oj3oKkPuaQ6cgSwYqAi0TDvP3w2p+oX1VejX/w28a1h8WTnrapzfO5d4Uqhww+gL0b0g==
  9923 +rollup@2.41.5, rollup@^0.63.4, rollup@^2.25.0, rollup@^2.38.5, rollup@^2.40.0:
  9924 + version "2.41.5"
  9925 + resolved "https://registry.npmjs.org/rollup/-/rollup-2.41.5.tgz#e79cef8cc5c121612528f590319639b1f32da2d7"
  9926 + integrity sha512-uG+WNNxhOYyeuO7oRt98GA2CNVRgQ67zca75UQVMPzMrLG9FUKzTCgvYVWhtB18TNbV7Uqxo97h+wErAnpFNJw==
9927 9927 optionalDependencies:
9928 9928 fsevents "~2.3.1"
9929 9929  
... ... @@ -11722,14 +11722,14 @@ vite-plugin-theme@^0.5.0:
11722 11722 tinycolor2 "^1.4.2"
11723 11723 ts-jest "^26.5.3"
11724 11724  
11725   -vite-plugin-windicss@0.9.1:
11726   - version "0.9.1"
11727   - resolved "https://registry.npmjs.org/vite-plugin-windicss/-/vite-plugin-windicss-0.9.1.tgz#870690d6fe9f1067b9177d49d6db26f73b2a07ee"
11728   - integrity sha512-fyhW2Wg98QaEVSgEGUYOyvG+dZMfqHcZsSBPg2k1REBxjv5eAG/p5JG3SchSOh59Clo+2GiZnpfM1GHaqDp19A==
  11725 +vite-plugin-windicss@0.9.2:
  11726 + version "0.9.2"
  11727 + resolved "https://registry.npmjs.org/vite-plugin-windicss/-/vite-plugin-windicss-0.9.2.tgz#60caaa7966aa3dbb2cb11bf2210c09a71cac84dd"
  11728 + integrity sha512-JM7Q7EfkxGRXklqH84LzQnVjXWOVnTPfi0AnXdnJuxmVMW8YidtEq/2rqf4GiYVXLdya8CQHNdYWnkZFSl47Yw==
11729 11729 dependencies:
11730   - "@windicss/plugin-utils" "0.9.1"
  11730 + "@windicss/plugin-utils" "0.9.2"
11731 11731 body-parser "^1.19.0"
11732   - windicss "^2.4.7"
  11732 + windicss "^2.5.0"
11733 11733  
11734 11734 vite@2.0.5:
11735 11735 version "2.0.5"
... ... @@ -11920,7 +11920,7 @@ which@^2.0.1, which@^2.0.2:
11920 11920 dependencies:
11921 11921 isexe "^2.0.0"
11922 11922  
11923   -windicss@^2.4.7:
  11923 +windicss@^2.5.0:
11924 11924 version "2.5.0"
11925 11925 resolved "https://registry.npmjs.org/windicss/-/windicss-2.5.0.tgz#12910cead975778b8aee6511b563e1d6ce03362f"
11926 11926 integrity sha512-mQt42RmDPK9XayP8L+mJW4Gon2X/ftGlNB3/BKaz6hqi4Hywys0piuUjGQIG6KhMfC0LLIzDpHz5b9GFqxYMrQ==
... ...