From 6e474d9ef06eeedeaab238330d9dda4d792891b0 Mon Sep 17 00:00:00 2001 From: Jim <48620344+JunmingZ@users.noreply.github.com> Date: Thu, 16 Jun 2022 19:02:10 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A,?= =?UTF-8?q?=20=E4=BF=AE=E5=A4=8D=20(#1927)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * docs: 添加注释 * docs: 添加注释 * fix: 后台动态权限changePermissionCode加上await * docs: 添加注释 * docs: 添加注释 * docs: 添加注释 * docs: 添加注释 * docs: 添加注释 --- .gitignore | 5 +- pnpm-lock.yaml | 154 +++++++++++++++---------------- src/enums/appEnum.ts | 6 +- src/hooks/web/usePermission.ts | 1 + src/router/helper/menuHelper.ts | 12 ++- src/router/helper/routeHelper.ts | 16 +++- src/router/index.ts | 1 + src/router/routes/index.ts | 4 +- src/store/modules/permission.ts | 41 ++++++++ src/utils/helper/treeHelper.ts | 12 +++ src/utils/http/axios/Axios.ts | 2 +- src/utils/http/axios/index.ts | 1 + src/utils/index.ts | 1 + 13 files changed, 173 insertions(+), 83 deletions(-) diff --git a/.gitignore b/.gitignore index d94f5966..e6922c46 100644 --- a/.gitignore +++ b/.gitignore @@ -27,4 +27,7 @@ pnpm-debug.log* *.njsproj *.sln *.sw? -/package-lock.json + +package-lock.json +pnpm-lock.yaml + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 63bb701c..1ad43466 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,4 +1,4 @@ -lockfileVersion: 5.4 +lockfileVersion: 5.3 overrides: bin-wrapper: npm:bin-wrapper-china @@ -138,7 +138,7 @@ dependencies: mockjs: 1.1.0 nprogress: 0.2.0 path-to-regexp: 6.2.0 - pinia: 2.0.12_ifhmkzsxec62ezvqv7qmanm4bq + pinia: 2.0.12_typescript@4.6.3+vue@3.2.33 print-js: 1.6.0 qrcode: 1.5.0 qs: 6.10.3 @@ -172,8 +172,8 @@ devDependencies: '@types/qs': 6.9.7 '@types/showdown': 1.9.4 '@types/sortablejs': 1.10.7 - '@typescript-eslint/eslint-plugin': 5.20.0_xgwjwvswzzo77lpghh6plzerx4 - '@typescript-eslint/parser': 5.20.0_jzhokl4shvj5szf5bgr66kln2a + '@typescript-eslint/eslint-plugin': 5.20.0_b9ac9b5656ce5dffade639fcf5e491bf + '@typescript-eslint/parser': 5.20.0_eslint@8.13.0+typescript@4.6.3 '@vitejs/plugin-legacy': 1.8.1_vite@2.9.5 '@vitejs/plugin-vue': 2.3.1_vite@2.9.5+vue@3.2.33 '@vitejs/plugin-vue-jsx': 1.3.10 @@ -186,7 +186,7 @@ devDependencies: dotenv: 16.0.0 eslint: 8.13.0 eslint-config-prettier: 8.5.0_eslint@8.13.0 - eslint-plugin-prettier: 4.0.0_dak2zfnx7mtmcpd5jcuo55rnb4 + eslint-plugin-prettier: 4.0.0_1815ac95b7fb26c13c7d48a8eef62d0f eslint-plugin-vue: 8.6.0_eslint@8.13.0 esno: 0.14.1 fs-extra: 10.1.0 @@ -206,17 +206,17 @@ devDependencies: stylelint: 14.7.1 stylelint-config-prettier: 9.0.3_stylelint@14.7.1 stylelint-config-recommended: 7.0.0_stylelint@14.7.1 - stylelint-config-recommended-vue: 1.4.0_dkblcabdfo7hanxmbj6kpjf26q + stylelint-config-recommended-vue: 1.4.0_1a82b100232bbe7036ec0a7ca7a4baf4 stylelint-config-standard: 25.0.0_stylelint@14.7.1 stylelint-order: 5.0.0_stylelint@14.7.1 - ts-node: 10.7.0_3z6inmgn4ud4moqealnfxgbl2m + ts-node: 10.7.0_de7c86b0cde507c63a0402da5b982bd3 typescript: 4.6.3 vite: 2.9.5_less@4.1.2 vite-plugin-compression: 0.5.1_vite@2.9.5 vite-plugin-html: 3.2.0_vite@2.9.5 vite-plugin-imagemin: 0.6.1_vite@2.9.5 vite-plugin-mkcert: 1.6.0 - vite-plugin-mock: 2.9.6_qiwm6q27tfokd2mntem6ma7w4y + vite-plugin-mock: 2.9.6_822ccf435f995ca1e98d9919e603f6e6 vite-plugin-purge-icons: 0.8.1_vite@2.9.5 vite-plugin-pwa: 0.11.13_vite@2.9.5 vite-plugin-style-import: 2.0.0_vite@2.9.5 @@ -1519,7 +1519,7 @@ packages: '@types/node': 17.0.25 chalk: 4.1.2 cosmiconfig: 7.0.1 - cosmiconfig-typescript-loader: 1.0.9_3z6inmgn4ud4moqealnfxgbl2m + cosmiconfig-typescript-loader: 1.0.9_de7c86b0cde507c63a0402da5b982bd3 lodash: 4.17.21 resolve-from: 5.0.0 typescript: 4.6.3 @@ -1905,7 +1905,7 @@ packages: '@iconify/iconify': 2.2.1 dev: true - /@rollup/plugin-babel/5.3.1_6m6vi5xreq5wlqqwvo3xvcrttm: + /@rollup/plugin-babel/5.3.1_@babel+core@7.17.9+rollup@2.70.2: resolution: {integrity: sha512-WFfdLWU/xVWKeRQnKmIAQULUI7Il0gZnBIH/ZFO069wYIfPu+8zrfp/KMW0atmELoRDq8FbiP3VCss9MhCut7Q==} engines: {node: '>= 10.0.0'} peerDependencies: @@ -2209,7 +2209,7 @@ packages: resolution: {integrity: sha512-F5DIZ36YVLE+PN+Zwws4kJogq47hNgX3Nx6WyDJ3kcplxyke3XIzB8uK5n/Lpm1HBsbGzd6nmGehL8cPekP+Tg==} dev: true - /@typescript-eslint/eslint-plugin/5.20.0_xgwjwvswzzo77lpghh6plzerx4: + /@typescript-eslint/eslint-plugin/5.20.0_b9ac9b5656ce5dffade639fcf5e491bf: resolution: {integrity: sha512-fapGzoxilCn3sBtC6NtXZX6+P/Hef7VDbyfGqTTpzYydwhlkevB+0vE0EnmHPVTVSy68GUncyJ/2PcrFBeCo5Q==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2220,10 +2220,10 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/parser': 5.20.0_jzhokl4shvj5szf5bgr66kln2a + '@typescript-eslint/parser': 5.20.0_eslint@8.13.0+typescript@4.6.3 '@typescript-eslint/scope-manager': 5.20.0 - '@typescript-eslint/type-utils': 5.20.0_jzhokl4shvj5szf5bgr66kln2a - '@typescript-eslint/utils': 5.20.0_jzhokl4shvj5szf5bgr66kln2a + '@typescript-eslint/type-utils': 5.20.0_eslint@8.13.0+typescript@4.6.3 + '@typescript-eslint/utils': 5.20.0_eslint@8.13.0+typescript@4.6.3 debug: 4.3.4 eslint: 8.13.0 functional-red-black-tree: 1.0.1 @@ -2236,7 +2236,7 @@ packages: - supports-color dev: true - /@typescript-eslint/parser/5.20.0_jzhokl4shvj5szf5bgr66kln2a: + /@typescript-eslint/parser/5.20.0_eslint@8.13.0+typescript@4.6.3: resolution: {integrity: sha512-UWKibrCZQCYvobmu3/N8TWbEeo/EPQbS41Ux1F9XqPzGuV7pfg6n50ZrFo6hryynD8qOTTfLHtHjjdQtxJ0h/w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2264,7 +2264,7 @@ packages: '@typescript-eslint/visitor-keys': 5.20.0 dev: true - /@typescript-eslint/type-utils/5.20.0_jzhokl4shvj5szf5bgr66kln2a: + /@typescript-eslint/type-utils/5.20.0_eslint@8.13.0+typescript@4.6.3: resolution: {integrity: sha512-WxNrCwYB3N/m8ceyoGCgbLmuZwupvzN0rE8NBuwnl7APgjv24ZJIjkNzoFBXPRCGzLNkoU/WfanW0exvp/+3Iw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2274,7 +2274,7 @@ packages: typescript: optional: true dependencies: - '@typescript-eslint/utils': 5.20.0_jzhokl4shvj5szf5bgr66kln2a + '@typescript-eslint/utils': 5.20.0_eslint@8.13.0+typescript@4.6.3 debug: 4.3.4 eslint: 8.13.0 tsutils: 3.21.0_typescript@4.6.3 @@ -2309,7 +2309,7 @@ packages: - supports-color dev: true - /@typescript-eslint/utils/5.20.0_jzhokl4shvj5szf5bgr66kln2a: + /@typescript-eslint/utils/5.20.0_eslint@8.13.0+typescript@4.6.3: resolution: {integrity: sha512-lHONGJL1LIO12Ujyx8L8xKbwWSkoUKFSO+0wDAqGXiudWB2EO7WEUT+YZLtVbmOmSllAjLb9tpoIPwpRe5Tn6w==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -2773,7 +2773,7 @@ packages: dev: true /archive-type/4.0.0: - resolution: {integrity: sha1-+S5yIzBW38aWlHJ0nCZ72wRrHXA=} + resolution: {integrity: sha512-zV4Ky0v1F8dBrdYElwTvQhweQ0P7Kwc1aluqJsYtOBP01jXcWCyW2IEfI1YiqsG+Iy7ZR+o5LF1N+PGECBxHWA==} engines: {node: '>=4'} dependencies: file-type: 4.4.0 @@ -3116,11 +3116,11 @@ packages: dev: true /buffer-crc32/0.2.13: - resolution: {integrity: sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=} + resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} dev: true /buffer-fill/1.0.0: - resolution: {integrity: sha1-+PeLdniYiO858gXNY39o5wISKyw=} + resolution: {integrity: sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==} dev: true /buffer-from/1.1.2: @@ -3161,7 +3161,7 @@ packages: dev: true /cacheable-request/2.1.4: - resolution: {integrity: sha1-DYCIAbY0KtM8kd+dC0TcCbkeXD0=} + resolution: {integrity: sha512-vag0O2LKZ/najSoUwDbVlnlCFvhBE/7mGTY2B5FgCBDcRD+oVV1HYTOwM6JZfMg/hIcM6IwnTZ1uQQL5/X3xIQ==} dependencies: clone-response: 1.0.2 get-stream: 3.0.0 @@ -3416,7 +3416,7 @@ packages: dev: true /clone-response/1.0.2: - resolution: {integrity: sha1-0dyXOSAxTfZ/vrlCI7TuNQI56Ws=} + resolution: {integrity: sha512-yjLXh88P599UOyPTFX0POsd7WxnbsVsGohcwzHOLspIhhpalPw1BcqED8NblyZLKcGrL8dTgMlcaZxV2jAD41Q==} dependencies: mimic-response: 1.0.1 dev: true @@ -3793,7 +3793,7 @@ packages: vary: 1.1.2 dev: true - /cosmiconfig-typescript-loader/1.0.9_3z6inmgn4ud4moqealnfxgbl2m: + /cosmiconfig-typescript-loader/1.0.9_de7c86b0cde507c63a0402da5b982bd3: resolution: {integrity: sha512-tRuMRhxN4m1Y8hP9SNYfz7jRwt8lZdWxdjg/ohg5esKmsndJIn4yT96oJVcf5x0eA11taXl+sIp+ielu529k6g==} engines: {node: '>=12', npm: '>=6'} peerDependencies: @@ -3802,7 +3802,7 @@ packages: dependencies: '@types/node': 17.0.25 cosmiconfig: 7.0.1 - ts-node: 10.7.0_3z6inmgn4ud4moqealnfxgbl2m + ts-node: 10.7.0_de7c86b0cde507c63a0402da5b982bd3 typescript: 4.6.3 transitivePeerDependencies: - '@swc/core' @@ -3851,7 +3851,7 @@ packages: dev: true /cross-spawn/5.1.0: - resolution: {integrity: sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=} + resolution: {integrity: sha512-pTgQJ5KC0d2hcY8eyL1IzlBPYjTkyH72XRZPnLyKus2mBfNjQs3klqbJU2VILqZryAZUt9JOb3h/mWMy23/f5A==} dependencies: lru-cache: 4.1.5 shebang-command: 1.2.0 @@ -4031,12 +4031,12 @@ packages: engines: {node: '>=0.10.0'} /decode-uri-component/0.2.0: - resolution: {integrity: sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=} + resolution: {integrity: sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og==} engines: {node: '>=0.10'} dev: true /decompress-response/3.3.0: - resolution: {integrity: sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=} + resolution: {integrity: sha512-BzRPQuY1ip+qDonAOz42gRm/pg9F768C+npV/4JOsxRC2sq+Rlk+Q4ZCAsOhnIaMrgarILY+RMUIvMmmX1qAEA==} engines: {node: '>=4'} dependencies: mimic-response: 1.0.1 @@ -4072,7 +4072,7 @@ packages: dev: true /decompress-unzip/4.0.1: - resolution: {integrity: sha1-3qrM39FK6vhVePczroIQ+bSEj2k=} + resolution: {integrity: sha512-1fqeluvxgnn86MOh66u8FjbtJpAFv5wgCT9Iw8rcBqQcCo5tO8eiJw7NNTrvt9n4CRBVq7CstiS922oPgyGLrw==} engines: {node: '>=4'} dependencies: file-type: 3.9.0 @@ -4309,7 +4309,7 @@ packages: dev: true /duplexer3/0.1.4: - resolution: {integrity: sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI=} + resolution: {integrity: sha512-CEj8FwwNA4cVH2uFCoHUrmojhYh1vmCdOaneKJXwkeY1i9jnlslVo9dx+hQ5Hl9GnH/Bwy/IjxAyOePyPKYnzA==} dev: true /eastasianwidth/0.2.0: @@ -4699,7 +4699,7 @@ packages: eslint: 8.13.0 dev: true - /eslint-plugin-prettier/4.0.0_dak2zfnx7mtmcpd5jcuo55rnb4: + /eslint-plugin-prettier/4.0.0_1815ac95b7fb26c13c7d48a8eef62d0f: resolution: {integrity: sha512-98MqmCJ7vJodoQK359bqQWaxOE0CS8paAz/GgjaZLyex4TTk3g9HugoO89EqWCrFiOqn9EVvcoo7gZzONCWVwQ==} engines: {node: '>=6.0.0'} peerDependencies: @@ -4884,7 +4884,7 @@ packages: dev: true /execa/0.7.0: - resolution: {integrity: sha1-lEvs00zEHuMqY6n68nrVpl/Fl3c=} + resolution: {integrity: sha512-RztN09XglpYI7aBBrJCPW95jEH7YF1UEPOoX9yDhUTPdp7mK+CQvnLTuD10BNXZ3byLTu2uehZ8EcKT/4CGiFw==} engines: {node: '>=4'} dependencies: cross-spawn: 5.1.0 @@ -5070,7 +5070,7 @@ packages: dev: true /fd-slicer/1.1.0: - resolution: {integrity: sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=} + resolution: {integrity: sha512-cE1qsB/VwyQozZ+q1dGxR8LBYNZeofhEdUNGSMbQD3Gw2lAzX9Zb3uIU6Ebc/Fmyjo9AWWfnn0AUCHqtevs/8g==} dependencies: pend: 1.2.0 dev: true @@ -5115,17 +5115,17 @@ packages: dev: true /file-type/3.9.0: - resolution: {integrity: sha1-JXoHg4TR24CHvESdEH1SpSZyuek=} + resolution: {integrity: sha512-RLoqTXE8/vPmMuTI88DAzhMYC99I8BWv7zYP4A1puo5HIjEJ5EX48ighy4ZyKMG9EDXxBgW6e++cn7d1xuFghA==} engines: {node: '>=0.10.0'} dev: true /file-type/4.4.0: - resolution: {integrity: sha1-G2AOX8ofvcboDApwxxyNul95BsU=} + resolution: {integrity: sha512-f2UbFQEk7LXgWpi5ntcO86OeA/cC80fuDDDaX/fZ2ZGel+AF7leRQqBBW1eJNiiQkrZlAoM6P+VYP5P6bOlDEQ==} engines: {node: '>=4'} dev: true /file-type/5.2.0: - resolution: {integrity: sha1-LdvqfHP/42No365J3DOMBYwritY=} + resolution: {integrity: sha512-Iq1nJ6D2+yIO4c8HHg4fyVb8mAJieo1Oloy1mLLaB2PvezNedhBVm+QU7g0qM42aiMbRXTxKKwGD17rjKNJYVQ==} engines: {node: '>=4'} dev: true @@ -5146,7 +5146,7 @@ packages: dev: true /filename-reserved-regex/2.0.0: - resolution: {integrity: sha1-q/c9+rc10EVECr/qLZHzieu/oik=} + resolution: {integrity: sha512-lc1bnsSr4L4Bdif8Xb/qrtokGbq5zlsms/CYH8PP+WtCkGNF65DPiQY8vG3SakEdRn8Dlnm+gW/qWKKjS5sZzQ==} engines: {node: '>=4'} dev: true @@ -5302,7 +5302,7 @@ packages: dev: true /from2/2.3.0: - resolution: {integrity: sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8=} + resolution: {integrity: sha512-OMcX/4IC/uqEPVgGeyfN22LJk6AZrMkRZHxcHBMBvHScDGgwTm2GT2Wkgtocyd3JfZffjj2kYUDXXII0Fk9W0g==} dependencies: inherits: 2.0.4 readable-stream: 2.3.7 @@ -5412,7 +5412,7 @@ packages: dev: true /get-stream/2.3.1: - resolution: {integrity: sha1-Xzj5PzRgCWZu4BUKBUFn+Rvdld4=} + resolution: {integrity: sha512-AUGhbbemXxrZJRD5cDvKtQxLuYaIbNtDTK8YqupCI393Q2KSTreEsLUN3ZxAWFGiKTzL6nKuzfcIvieflUX9qA==} engines: {node: '>=0.10.0'} dependencies: object-assign: 4.1.1 @@ -5420,7 +5420,7 @@ packages: dev: true /get-stream/3.0.0: - resolution: {integrity: sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=} + resolution: {integrity: sha512-GlhdIUuVakc8SJ6kK0zAFbiGzRFzNnY4jUuEbV9UROo4Y+0Ny4fjvcZFVTeDA4odpFyOQzaw6hXukJSq/f28sQ==} engines: {node: '>=4'} dev: true @@ -5897,7 +5897,7 @@ packages: dev: true /image-size/0.5.5: - resolution: {integrity: sha1-Cd/Uq50g4p6xw+gLiZA3jfnjy5w=} + resolution: {integrity: sha512-6TDAlDPZxUFCv+fuOkIoXT/V/f3Qbq8e37p+YOiYrUv3v9cc3/6x78VdfPgFVaB9dZYeLUfKgHRebpkm/oP2VQ==} engines: {node: '>=0.10.0'} hasBin: true dev: true @@ -6079,7 +6079,7 @@ packages: dev: true /into-stream/3.1.0: - resolution: {integrity: sha1-lvsKk2wSur1v8XUqF9BWFqvQlMY=} + resolution: {integrity: sha512-TcdjPibTksa1NQximqep2r17ISRiNE9fwlfbg3F8ANdvP5/yrFTew86VcO//jk4QTaMlbjypPBq76HN2zaKfZQ==} engines: {node: '>=4'} dependencies: from2: 2.3.0 @@ -6267,7 +6267,7 @@ packages: dev: true /is-natural-number/4.0.1: - resolution: {integrity: sha1-q5124dtM7VHjXeDHLr7PCfc0zeg=} + resolution: {integrity: sha512-Y4LTamMe0DDQIIAlaer9eKebAlDSV6huy+TWhJVPlzZh2o4tRP5SQWFlLn5N0To4mDD22/qdOq+veo1cSISLgQ==} dev: true /is-negative-zero/2.0.2: @@ -6433,7 +6433,7 @@ packages: dev: true /isarray/1.0.0: - resolution: {integrity: sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=} + resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} dev: true /isexe/2.0.0: @@ -6532,7 +6532,7 @@ packages: dev: true /json-buffer/3.0.0: - resolution: {integrity: sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg=} + resolution: {integrity: sha512-CuUqjv0FUZIdXkHPI8MezCnFCdaTAacej1TZYulLoAg1h/PhwkdXFN4V/gzY4g+fMBCOV2xF+rp7t2XD2ns/NQ==} dev: true /json-parse-better-errors/1.0.2: @@ -6865,7 +6865,7 @@ packages: dev: true /lowercase-keys/1.0.0: - resolution: {integrity: sha1-TjNms55/VFfjXxMkvfb4jQv8cwY=} + resolution: {integrity: sha512-RPlX0+PHuvxVDZ7xX+EBVAp4RsVxP/TdDSN2mJYdiq1Lc4Hz7EUSjUI7RZrKKlmrIzVhf6Jo2stj7++gVarS0A==} engines: {node: '>=0.10.0'} dev: true @@ -7509,7 +7509,7 @@ packages: dev: true /p-event/1.3.0: - resolution: {integrity: sha1-jmtPT2XHK8W2/ii3XtqHT5akoIU=} + resolution: {integrity: sha512-hV1zbA7gwqPVFcapfeATaNjQ3J0NuzorHPyG8GPL9g/Y/TplWVBVoCKCXL6Ej2zscrCEv195QNWJXuBH6XZuzA==} engines: {node: '>=4'} dependencies: p-timeout: 1.2.1 @@ -7528,7 +7528,7 @@ packages: dev: true /p-is-promise/1.1.0: - resolution: {integrity: sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=} + resolution: {integrity: sha512-zL7VE4JVS2IFSkR2GQKDSPEVxkoH43/p7oEnwpdCndKYJO0HVeRB7fA8TJwuLOTBREtK0ea8eHaxdwcpob5dmg==} engines: {node: '>=4'} dev: true @@ -7597,7 +7597,7 @@ packages: dev: true /p-timeout/1.2.1: - resolution: {integrity: sha1-XrOzU7f86Z8QGhA4iAuwVOu+o4Y=} + resolution: {integrity: sha512-gb0ryzr+K2qFqFv6qi3khoeqMZF/+ajxQipEF6NteZVnvz9tzdsfAVj3lYtn1gAXvH5lfLwfxEII799gt/mRIA==} engines: {node: '>=4'} dependencies: p-finally: 1.0.0 @@ -7756,7 +7756,7 @@ packages: dev: true /pend/1.2.0: - resolution: {integrity: sha1-elfrVQpng/kRUzH89GY9XI4AelA=} + resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==} dev: true /picocolors/1.0.0: @@ -7780,12 +7780,12 @@ packages: dev: true /pify/2.3.0: - resolution: {integrity: sha1-7RQaasBDqEnqWISY59yosVMw6Qw=} + resolution: {integrity: sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==} engines: {node: '>=0.10.0'} dev: true /pify/3.0.0: - resolution: {integrity: sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=} + resolution: {integrity: sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==} engines: {node: '>=4'} dev: true @@ -7794,7 +7794,7 @@ packages: engines: {node: '>=6'} dev: true - /pinia/2.0.12_ifhmkzsxec62ezvqv7qmanm4bq: + /pinia/2.0.12_typescript@4.6.3+vue@3.2.33: resolution: {integrity: sha512-tUeuYGFrLU5irmGyRAIxp35q1OTcZ8sKpGT4XkPeVcG35W4R6cfXDbCGexzmVqH5lTQJJTXXbNGutIu9yS5yew==} peerDependencies: '@vue/composition-api': ^1.4.0 @@ -7813,14 +7813,14 @@ packages: dev: false /pinkie-promise/2.0.1: - resolution: {integrity: sha1-ITXW36ejWMBprJsXh3YogihFD/o=} + resolution: {integrity: sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==} engines: {node: '>=0.10.0'} dependencies: pinkie: 2.0.4 dev: true /pinkie/2.0.4: - resolution: {integrity: sha1-clVrgM+g1IqXToDnckjoDtT3+HA=} + resolution: {integrity: sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==} engines: {node: '>=0.10.0'} dev: true @@ -7971,12 +7971,12 @@ packages: dev: true /prepend-http/1.0.4: - resolution: {integrity: sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw=} + resolution: {integrity: sha512-PhmXi5XmoyKw1Un4E+opM2KcsJInDvKyuOumcjjw3waw86ZNjHwVUOOWLc4bCzLdcKNaWBH9e99sbWzDQsVaYg==} engines: {node: '>=0.10.0'} dev: true /prepend-http/2.0.0: - resolution: {integrity: sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=} + resolution: {integrity: sha512-ravE6m9Atw9Z/jjttRUZ+clIXogdghyZAuWJ3qEzjT+jI/dL1ifAqhZeC5VHzQp1MSt1+jxKkFNemj/iO7tVUA==} engines: {node: '>=4'} dev: true @@ -8007,7 +8007,7 @@ packages: dev: true /proto-list/1.2.4: - resolution: {integrity: sha1-IS1b/hMYMGpCD2QCuOJv85ZHqEk=} + resolution: {integrity: sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==} dev: true /prr/1.0.1: @@ -8016,7 +8016,7 @@ packages: optional: true /pseudomap/1.0.2: - resolution: {integrity: sha1-8FKijacOYYkX7wqKw0wa5aaChrM=} + resolution: {integrity: sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==} dev: true /pug-error/2.0.0: @@ -8351,7 +8351,7 @@ packages: dev: true /responselike/1.0.2: - resolution: {integrity: sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec=} + resolution: {integrity: sha512-/Fpe5guzJk1gPqdJLJR5u7eG/gNY4nImjbRDaVWVMRhne55TCmj2i9Q+54PBRfatRC8v/rIiv9BN0pMd9OV5EQ==} dependencies: lowercase-keys: 1.0.1 dev: true @@ -8511,7 +8511,7 @@ packages: dev: true /semver-truncate/1.1.2: - resolution: {integrity: sha1-V/Qd5pcHpicJp+AQS6IRcQnqR+g=} + resolution: {integrity: sha512-V1fGg9i4CL3qesB6U0L6XAm4xOJiHmt4QAacazumuasc03BvtFGIMCduv01JWQ69Nv+JST9TqhSCiJoxoY031w==} engines: {node: '>=0.10.0'} dependencies: semver: 5.7.1 @@ -8695,21 +8695,21 @@ packages: dev: true /sort-keys-length/1.0.1: - resolution: {integrity: sha1-nLb09OnkgVWmqgZx7dM2/xR5oYg=} + resolution: {integrity: sha512-GRbEOUqCxemTAk/b32F2xa8wDTs+Z1QHOkbhJDQTvv/6G3ZkbJ+frYWsTcc7cBB3Fu4wy4XlLCuNtJuMn7Gsvw==} engines: {node: '>=0.10.0'} dependencies: sort-keys: 1.1.2 dev: true /sort-keys/1.1.2: - resolution: {integrity: sha1-RBttTTRnmPG05J6JIK37oOVD+a0=} + resolution: {integrity: sha512-vzn8aSqKgytVik0iwdBEi+zevbTYZogewTUM6dtpmGwEcdzbub/TX4bCzRhebDCRC3QzXgJsLRKB2V/Oof7HXg==} engines: {node: '>=0.10.0'} dependencies: is-plain-obj: 1.1.0 dev: true /sort-keys/2.0.0: - resolution: {integrity: sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg=} + resolution: {integrity: sha512-/dPCrG1s3ePpWm6yBbxZq5Be1dXGLyLn9Z791chDC3NFrpkVbWGzkBwPN1knaciexFXgRJ7hzdnwZ4stHSDmjg==} engines: {node: '>=4'} dependencies: is-plain-obj: 1.1.0 @@ -9053,7 +9053,7 @@ packages: resolution: {integrity: sha1-eVjHk+R+MuB9K1yv5cC/jhLneQI=} dev: true - /stylelint-config-html/1.0.0_dkblcabdfo7hanxmbj6kpjf26q: + /stylelint-config-html/1.0.0_1a82b100232bbe7036ec0a7ca7a4baf4: resolution: {integrity: sha512-rKQUUWDpaYC7ybsS6tLxddjn6DxhjSIXybElSmcTyVQj3ExhmU3q+l41ktrlwHRyY0M5SkTkZiwngvYPYmsgSQ==} engines: {node: ^12 || >=14} peerDependencies: @@ -9074,7 +9074,7 @@ packages: stylelint: 14.7.1 dev: true - /stylelint-config-recommended-vue/1.4.0_dkblcabdfo7hanxmbj6kpjf26q: + /stylelint-config-recommended-vue/1.4.0_1a82b100232bbe7036ec0a7ca7a4baf4: resolution: {integrity: sha512-DVJqyX2KvMCn9U0+keL12r7xlsH26K4Vg8NrIZuq5MoF7g82DpMp326Om4E0Q+Il1o+bTHuUyejf2XAI0iD04Q==} engines: {node: ^12 || >=14} peerDependencies: @@ -9084,7 +9084,7 @@ packages: postcss-html: 1.4.1 semver: 7.3.7 stylelint: 14.7.1 - stylelint-config-html: 1.0.0_dkblcabdfo7hanxmbj6kpjf26q + stylelint-config-html: 1.0.0_1a82b100232bbe7036ec0a7ca7a4baf4 stylelint-config-recommended: 7.0.0_stylelint@14.7.1 dev: true @@ -9347,7 +9347,7 @@ packages: dev: true /timed-out/4.0.1: - resolution: {integrity: sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8=} + resolution: {integrity: sha512-G7r3AhovYtr5YKOWQkta8RKAPb+J9IsO4uVmzjl8AZwfhs8UcUwTiD6gcJYSgOtzyjvQKrKYn41syHbUWMkafA==} engines: {node: '>=0.10.0'} dev: true @@ -9436,13 +9436,13 @@ packages: dev: true /trim-repeated/1.0.0: - resolution: {integrity: sha1-42RqLqTokTEr9+rObPsFOAvAHCE=} + resolution: {integrity: sha512-pkonvlKk8/ZuR0D5tLW8ljt5I8kmxp2XKymhepUeOdCEfKpZaktSArkLHZt76OB1ZvO9bssUsDty4SWhLvZpLg==} engines: {node: '>=0.10.0'} dependencies: escape-string-regexp: 1.0.5 dev: true - /ts-node/10.7.0_3z6inmgn4ud4moqealnfxgbl2m: + /ts-node/10.7.0_de7c86b0cde507c63a0402da5b982bd3: resolution: {integrity: sha512-TbIGS4xgJoX2i3do417KSaep1uRAW/Lu+WAL2doDHC0D6ummjirVOXU5/7aiZotbQ5p1Zp9tP7U6cYhA0O7M8A==} hasBin: true peerDependencies: @@ -9496,7 +9496,7 @@ packages: dev: true /tunnel-agent/0.6.0: - resolution: {integrity: sha1-J6XeoGs2sEoKmWZ3SykIaPD8QP0=} + resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} dependencies: safe-buffer: 5.2.1 dev: true @@ -9681,14 +9681,14 @@ packages: dev: true /url-parse-lax/3.0.0: - resolution: {integrity: sha1-FrXK/Afb42dsGxmZF3gj1lA6yww=} + resolution: {integrity: sha512-NjFKA0DidqPa5ciFcSrXnAltTtzz84ogy+NebPvfEgAck0+TNg4UJ4IN+fB7zRZfbgUf0syOo9MDxFkDSMuFaQ==} engines: {node: '>=4'} dependencies: prepend-http: 2.0.0 dev: true /url-to-options/1.0.1: - resolution: {integrity: sha1-FQWgOiiaSMvXpDTvuu7FBV9WM6k=} + resolution: {integrity: sha512-0kQLIzG4fdk/G5NONku64rSH/x32NOA39LVQqlK8Le6lvTF6GGRJpqaQFGgU+CLwySIqBSMdwYM0sYcW9f6P4A==} engines: {node: '>= 4'} dev: true @@ -9816,7 +9816,7 @@ packages: - supports-color dev: true - /vite-plugin-mock/2.9.6_qiwm6q27tfokd2mntem6ma7w4y: + /vite-plugin-mock/2.9.6_822ccf435f995ca1e98d9919e603f6e6: resolution: {integrity: sha512-/Rm59oPppe/ncbkSrUuAxIQihlI2YcBmnbR4ST1RA2VzM1C0tEQc1KlbQvnUGhXECAGTaQN2JyasiwXP6EtKgg==} engines: {node: '>=12.0.0'} peerDependencies: @@ -10202,7 +10202,7 @@ packages: '@babel/core': 7.17.9 '@babel/preset-env': 7.16.11_@babel+core@7.17.9 '@babel/runtime': 7.17.9 - '@rollup/plugin-babel': 5.3.1_6m6vi5xreq5wlqqwvo3xvcrttm + '@rollup/plugin-babel': 5.3.1_@babel+core@7.17.9+rollup@2.70.2 '@rollup/plugin-node-resolve': 11.2.1_rollup@2.70.2 '@rollup/plugin-replace': 2.4.2_rollup@2.70.2 '@surma/rollup-plugin-off-main-thread': 2.2.3 @@ -10385,7 +10385,7 @@ packages: dev: true /yallist/2.1.2: - resolution: {integrity: sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=} + resolution: {integrity: sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==} dev: true /yallist/4.0.0: @@ -10459,7 +10459,7 @@ packages: dev: true /yauzl/2.10.0: - resolution: {integrity: sha1-x+sXyT4RLLEIb6bY5R+wZnt5pfk=} + resolution: {integrity: sha512-p4a9I6X6nu6IhoGmBqAcbJy1mlC4j27vEPZX9F4L4/vZT3Lyq1VkFHw/V/PUcB9Buo+DG3iHkT0x3Qya58zc3g==} dependencies: buffer-crc32: 0.2.13 fd-slicer: 1.1.0 diff --git a/src/enums/appEnum.ts b/src/enums/appEnum.ts index 63869d20..1fc3989f 100644 --- a/src/enums/appEnum.ts +++ b/src/enums/appEnum.ts @@ -30,14 +30,18 @@ export enum SessionTimeoutProcessingEnum { */ export enum PermissionModeEnum { // role + // 角色权限 ROLE = 'ROLE', // black + // 后端 BACK = 'BACK', // route mapping + // 路由映射 ROUTE_MAPPING = 'ROUTE_MAPPING', } -// Route switching animation +// Route switching animation +// 路由切换动画 export enum RouterTransitionEnum { ZOOM_FADE = 'zoom-fade', ZOOM_OUT = 'zoom-out', diff --git a/src/hooks/web/usePermission.ts b/src/hooks/web/usePermission.ts index cb2d442b..bfff591d 100644 --- a/src/hooks/web/usePermission.ts +++ b/src/hooks/web/usePermission.ts @@ -39,6 +39,7 @@ export function usePermission() { /** * Reset and regain authority resource information + * 重置和重新获得权限资源信息 * @param id */ async function resume() { diff --git a/src/router/helper/menuHelper.ts b/src/router/helper/menuHelper.ts index 2b16f5ea..f0767b21 100644 --- a/src/router/helper/menuHelper.ts +++ b/src/router/helper/menuHelper.ts @@ -11,14 +11,18 @@ export function getAllParentPath(treeData: T[], path: string) { return (menuList || []).map((item) => item.path); } +// 路径处理 function joinParentPath(menus: Menu[], parentPath = '') { for (let index = 0; index < menus.length; index++) { const menu = menus[index]; // https://next.router.vuejs.org/guide/essentials/nested-routes.html // Note that nested paths that start with / will be treated as a root path. + // 请注意,以 / 开头的嵌套路径将被视为根路径。 // This allows you to leverage the component nesting without having to use a nested URL. + // 这允许你利用组件嵌套,而无需使用嵌套 URL。 if (!(menu.path.startsWith('/') || isUrl(menu.path))) { // path doesn't start with /, nor is it a url, join parent path + // 路径不以 / 开头,也不是 url,加入父路径 menu.path = `${parentPath}/${menu.path}`; } if (menu?.children?.length) { @@ -37,14 +41,18 @@ export function transformMenuModule(menuModule: MenuModule): Menu { return menuList[0]; } +// 将路由转换成菜单 export function transformRouteToMenu(routeModList: AppRouteModule[], routerMapping = false) { + // 借助 lodash 深拷贝 const cloneRouteModList = cloneDeep(routeModList); const routeList: AppRouteRecordRaw[] = []; + // 对路由项进行修改 cloneRouteModList.forEach((item) => { if (routerMapping && item.meta.hideChildrenInMenu && typeof item.redirect === 'string') { item.path = item.redirect; } + if (item.meta?.single) { const realItem = item?.children?.[0]; realItem && routeList.push(realItem); @@ -52,6 +60,7 @@ export function transformRouteToMenu(routeModList: AppRouteModule[], routerMappi routeList.push(item); } }); + // 提取树指定结构 const list = treeMap(routeList, { conversion: (node: AppRouteRecordRaw) => { const { meta: { title, hideMenu = false } = {} } = node; @@ -66,7 +75,7 @@ export function transformRouteToMenu(routeModList: AppRouteModule[], routerMappi }; }, }); - + // 路径处理 joinParentPath(list); return cloneDeep(list); } @@ -75,6 +84,7 @@ export function transformRouteToMenu(routeModList: AppRouteModule[], routerMappi * config menu with given params */ const menuParamRegex = /(?::)([\s\S]+?)((?=\/)|$)/g; + export function configureDynamicParamsMenu(menu: Menu, params: RouteParams) { const { path, paramPath } = toRaw(menu); let realPath = paramPath ? paramPath : path; diff --git a/src/router/helper/routeHelper.ts b/src/router/helper/routeHelper.ts index d1ff3bb1..d1332090 100644 --- a/src/router/helper/routeHelper.ts +++ b/src/router/helper/routeHelper.ts @@ -68,6 +68,7 @@ function dynamicImport( } // Turn background objects into routing objects +// 将背景对象变成路由对象 export function transformObjToRoute(routeList: AppRouteModule[]): T[] { routeList.forEach((route) => { const component = route.component as string; @@ -94,35 +95,46 @@ export function transformObjToRoute(routeList: AppRouteModul /** * Convert multi-level routing to level 2 routing + * 将多级路由转换为 2 级路由 */ export function flatMultiLevelRoutes(routeModules: AppRouteModule[]) { const modules: AppRouteModule[] = cloneDeep(routeModules); + for (let index = 0; index < modules.length; index++) { const routeModule = modules[index]; + // 判断级别是否 多级 路由 if (!isMultipleRoute(routeModule)) { + // 声明终止当前循环, 即跳过此次循环,进行下一轮 continue; } + // 路由等级提升 promoteRouteLevel(routeModule); } return modules; } // Routing level upgrade +// 路由等级提升 function promoteRouteLevel(routeModule: AppRouteModule) { // Use vue-router to splice menus + // 使用vue-router拼接菜单 + // createRouter 创建一个可以被 Vue 应用程序使用的路由实例 let router: Router | null = createRouter({ routes: [routeModule as unknown as RouteRecordNormalized], history: createWebHashHistory(), }); - + // getRoutes: 获取所有 路由记录的完整列表。 const routes = router.getRoutes(); + // 将所有子路由添加到二级路由 addToChildren(routes, routeModule.children || [], routeModule); router = null; + // omit lodash的函数 对传入的item对象的children进行删除 routeModule.children = routeModule.children?.map((item) => omit(item, 'children')); } // Add all sub-routes to the secondary route +// 将所有子路由添加到二级路由 function addToChildren( routes: RouteRecordNormalized[], children: AppRouteRecordRaw[], @@ -145,7 +157,9 @@ function addToChildren( } // Determine whether the level exceeds 2 levels +// 判断级别是否超过2级 function isMultipleRoute(routeModule: AppRouteModule) { + // Reflect.has 与 in 操作符 相同, 用于检查一个对象(包括它原型链上)是否拥有某个属性 if (!routeModule || !Reflect.has(routeModule, 'children') || !routeModule.children?.length) { return false; } diff --git a/src/router/index.ts b/src/router/index.ts index 3107c468..bcfc17fb 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -36,6 +36,7 @@ export function resetRouter() { } // config router +// 配置路由器 export function setupRouter(app: App) { app.use(router); } diff --git a/src/router/routes/index.ts b/src/router/routes/index.ts index 8cf4831e..52623420 100644 --- a/src/router/routes/index.ts +++ b/src/router/routes/index.ts @@ -6,10 +6,11 @@ import { mainOutRoutes } from './mainOut'; import { PageEnum } from '/@/enums/pageEnum'; import { t } from '/@/hooks/web/useI18n'; +// import.meta.globEager() 直接引入所有的模块 Vite 独有的功能 const modules = import.meta.globEager('./modules/**/*.ts'); - const routeModuleList: AppRouteModule[] = []; +// 加入到路由集合中 Object.keys(modules).forEach((key) => { const mod = modules[key].default || {}; const modList = Array.isArray(mod) ? [...mod] : [mod]; @@ -18,6 +19,7 @@ Object.keys(modules).forEach((key) => { export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList]; +// 根路由 export const RootRoute: AppRouteRecordRaw = { path: '/', name: 'Root', diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index 6c8ae6ed..5472dfff 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -26,26 +26,37 @@ import { getUserMenu } from '/@/api/sys/user'; interface PermissionState { // Permission code list + // 权限代码列表 permCodeList: string[] | number[]; // Whether the route has been dynamically added + // 路由是否动态添加 isDynamicAddedRoute: boolean; // To trigger a menu update + // 触发菜单更新 lastBuildMenuTime: number; // Backstage menu list + // 后台菜单列表 backMenuList: Menu[]; + // 菜单列表 frontMenuList: Menu[]; } + export const usePermissionStore = defineStore({ id: 'app-permission', state: (): PermissionState => ({ + // 权限代码列表 permCodeList: [], // Whether the route has been dynamically added + // 路由是否动态添加 isDynamicAddedRoute: false, // To trigger a menu update + // 触发菜单更新 lastBuildMenuTime: 0, // Backstage menu list + // 后台菜单列表 backMenuList: [], // menu List + // 菜单列表 frontMenuList: [], }), getters: { @@ -96,6 +107,8 @@ export const usePermissionStore = defineStore({ // const codeList = await getPermCode(); // this.setPermCodeList(codeList); }, + + // 构建路由 async buildRoutesAction(): Promise { const { t } = useI18n(); const userStore = useUserStore(); @@ -105,16 +118,21 @@ export const usePermissionStore = defineStore({ const roleList = toRaw(userStore.getRoleList) || []; const { permissionMode = projectSetting.permissionMode } = appStore.getProjectConfig; + // 路由过滤器 在 函数filter 作为回调传入遍历使用 const routeFilter = (route: AppRouteRecordRaw) => { const { meta } = route; + // 抽出角色 const { roles } = meta || {}; if (!roles) return true; + // 进行角色权限判断 return roleList.some((role) => roles.includes(role)); }; const routeRemoveIgnoreFilter = (route: AppRouteRecordRaw) => { const { meta } = route; + // ignoreRoute 为true 则路由仅用于菜单生成,不会在实际的路由表中出现 const { ignoreRoute } = meta || {}; + // arr.filter 返回 true 表示该元素通过测试 return !ignoreRoute; }; @@ -124,6 +142,7 @@ export const usePermissionStore = defineStore({ const patchHomeAffix = (routes: AppRouteRecordRaw[]) => { if (!routes || routes.length === 0) return; let homePath: string = userStore.getUserInfo.homePath || PageEnum.BASE_HOME; + function patcher(routes: AppRouteRecordRaw[], parentPath = '') { if (parentPath) parentPath = parentPath + '/'; routes.forEach((route: AppRouteRecordRaw) => { @@ -140,6 +159,7 @@ export const usePermissionStore = defineStore({ children && children.length > 0 && patcher(children, currentPath); }); } + try { patcher(routes); } catch (e) { @@ -149,35 +169,52 @@ export const usePermissionStore = defineStore({ }; switch (permissionMode) { + // 角色权限 case PermissionModeEnum.ROLE: + // 对非一级路由进行过滤 routes = filter(asyncRoutes, routeFilter); + // 对一级路由根据角色权限过滤 routes = routes.filter(routeFilter); // Convert multi-level routing to level 2 routing + // 将多级路由转换为 2 级路由 routes = flatMultiLevelRoutes(routes); break; + // 路由映射, 默认进入该case case PermissionModeEnum.ROUTE_MAPPING: + // 对非一级路由进行过滤 routes = filter(asyncRoutes, routeFilter); + // 对一级路由再次根据角色权限过滤 routes = routes.filter(routeFilter); + // 将路由转换成菜单 const menuList = transformRouteToMenu(routes, true); + // 移除掉 ignoreRoute: true 的路由 非一级路由 routes = filter(routes, routeRemoveIgnoreFilter); + // 移除掉 ignoreRoute: true 的路由 一级路由; routes = routes.filter(routeRemoveIgnoreFilter); + // 对菜单进行排序 menuList.sort((a, b) => { return (a.meta?.orderNo || 0) - (b.meta?.orderNo || 0); }); + // 设置菜单列表 this.setFrontMenuList(menuList); + // Convert multi-level routing to level 2 routing + // 将多级路由转换为 2 级路由 routes = flatMultiLevelRoutes(routes); break; // If you are sure that you do not need to do background dynamic permissions, please comment the entire judgment below + // 如果确定不需要做后台动态权限,请在下方评论整个判断 case PermissionModeEnum.BACK: const { createMessage } = useMessage(); createMessage.loading(t('sys.app.menuLoading'), 1); // !Simulate to obtain permission codes from the background, + // 模拟从后台获取权限码, // this function may only need to be executed once, and the actual project can be put at the right time by itself + // 这个功能可能只需要执行一次,实际项目可以自己放在合适的时间 let routeList: AppRouteRecordRaw[] = []; try { // this.changePermissionCode(); @@ -188,13 +225,16 @@ export const usePermissionStore = defineStore({ } // Dynamically introduce components + // 动态引入组件 routeList = transformObjToRoute(routeList); // Background routing to menu structure + // 后台路由到菜单结构 const backMenuList = transformRouteToMenu(routeList); this.setBackMenuList(backMenuList); // remove meta.ignoreRoute item + // 删除 meta.ignoreRoute 项 routeList = filter(routeList, routeRemoveIgnoreFilter); routeList = routeList.filter(routeRemoveIgnoreFilter); @@ -211,6 +251,7 @@ export const usePermissionStore = defineStore({ }); // Need to be used outside the setup +// 需要在设置之外使用 export function usePermissionStoreWithOut() { return usePermissionStore(store); } diff --git a/src/utils/helper/treeHelper.ts b/src/utils/helper/treeHelper.ts index d905a224..922a4731 100644 --- a/src/utils/helper/treeHelper.ts +++ b/src/utils/helper/treeHelper.ts @@ -3,15 +3,19 @@ interface TreeHelperConfig { children: string; pid: string; } + +// 默认配置 const DEFAULT_CONFIG: TreeHelperConfig = { id: 'id', children: 'children', pid: 'pid', }; +// 获取配置。 Object.assign 从一个或多个源对象复制到目标对象 const getConfig = (config: Partial) => Object.assign({}, DEFAULT_CONFIG, config); // tree from list +// 列表中的树 export function listToTree(list: any[], config: Partial = {}): T[] { const conf = getConfig(config) as TreeHelperConfig; const nodeMap = new Map(); @@ -123,18 +127,24 @@ export function findPathAll(tree: any, func: Fn, config: Partial( tree: T[], func: (n: T) => boolean, + // Partial 将 T 中的所有属性设为可选 config: Partial = {}, ): T[] { + // 获取配置 config = getConfig(config); const children = config.children as string; + function listFilter(list: T[]) { return list .map((node: any) => ({ ...node })) .filter((node) => { + // 递归调用 对含有children项 进行再次调用自身函数 listFilter node[children] = node[children] && listFilter(node[children]); + // 执行传入的回调 func 进行过滤 return func(node) || (node[children] && node[children].length); }); } + return listFilter(tree); } @@ -157,6 +167,7 @@ export function forEach( /** * @description: Extract tree specified structure + * @description: 提取树指定结构 */ export function treeMap(treeData: T[], opt: { children?: string; conversion: Fn }): T[] { return treeData.map((item) => treeMapEach(item, opt)); @@ -164,6 +175,7 @@ export function treeMap(treeData: T[], opt: { children?: string; conver /** * @description: Extract tree specified structure + * @description: 提取树指定结构 */ export function treeMapEach( data: any, diff --git a/src/utils/http/axios/Axios.ts b/src/utils/http/axios/Axios.ts index 753a033b..3984cd8d 100644 --- a/src/utils/http/axios/Axios.ts +++ b/src/utils/http/axios/Axios.ts @@ -61,7 +61,7 @@ export class VAxios { } /** - * @description: Interceptor configuration + * @description: Interceptor configuration 拦截器配置 */ private setupInterceptors() { const transform = this.getTransform(); diff --git a/src/utils/http/axios/index.ts b/src/utils/http/axios/index.ts index 20d69136..96f27786 100644 --- a/src/utils/http/axios/index.ts +++ b/src/utils/http/axios/index.ts @@ -199,6 +199,7 @@ const transform: AxiosTransform = { function createAxios(opt?: Partial) { return new VAxios( + // 深度合并 deepMerge( { // See https://developer.mozilla.org/en-US/docs/Web/HTTP/Authentication#authentication_schemes diff --git a/src/utils/index.ts b/src/utils/index.ts index 112c3af4..78022c6a 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -32,6 +32,7 @@ export function setObjToUrlParams(baseUrl: string, obj: any): string { return /\?$/.test(baseUrl) ? baseUrl + parameters : baseUrl.replace(/\/?$/, '?') + parameters; } +// 深度合并 export function deepMerge(src: any = {}, target: any = {}): T { let key: string; for (key in target) {