From 3226a724be65935ce89fe6ae67f49a20d255c6ac Mon Sep 17 00:00:00 2001 From: Soybean <2570172956@qq.com> Date: Wed, 15 Sep 2021 07:35:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(projects):=20=E8=8F=9C=E5=8D=95=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=8F=8A=E7=BB=84=E4=BB=B6=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 13 +- pnpm-lock.yaml | 212 ++++++++++++++---- src/interface/common.ts | 11 +- src/interface/index.ts | 2 +- .../GlobalHeader/components/UserAvatar.vue | 45 ++++ .../GlobalHeader/components/index.ts | 3 +- .../components/GlobalHeader/index.vue | 3 +- .../components/common/GlobalLogo.vue | 9 +- .../components/common/GlobalMenu.vue | 38 +++- src/main.ts | 3 +- src/plugins/index.ts | 3 +- src/plugins/smooth-scroll.ts | 6 - src/router/index.ts | 1 + src/router/menus.ts | 48 +++- src/router/routes.ts | 8 +- src/store/modules/auth/index.ts | 3 + src/utils/auth/index.ts | 2 +- src/utils/auth/user.ts | 6 +- src/utils/common/icon.ts | 12 + src/utils/common/index.ts | 2 + src/utils/index.ts | 4 +- src/utils/storage/index.ts | 2 +- src/utils/storage/local.ts | 8 +- src/views/dashboard/workbench/index.vue | 10 - src/views/system/login/index.vue | 2 +- 25 files changed, 361 insertions(+), 95 deletions(-) create mode 100644 src/layouts/BasicLayout/components/GlobalHeader/components/UserAvatar.vue delete mode 100644 src/plugins/smooth-scroll.ts create mode 100644 src/utils/common/icon.ts diff --git a/package.json b/package.json index 5166c756..407197f7 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,6 @@ "naive-ui": "^2.18.2", "pinia": "^2.0.0-rc.4", "qs": "^6.10.1", - "smoothscroll-polyfill": "^0.4.4", "vue": "^3.2.10", "vue-router": "^4.0.11" }, @@ -41,6 +40,14 @@ "@types/smoothscroll-polyfill": "^0.3.1", "@typescript-eslint/eslint-plugin": "^4.31.1", "@typescript-eslint/parser": "^4.31.1", + "@vicons/antd": "^0.11.0", + "@vicons/carbon": "^0.11.0", + "@vicons/fa": "^0.11.0", + "@vicons/fluent": "^0.11.0", + "@vicons/ionicons4": "^0.11.0", + "@vicons/ionicons5": "^0.11.0", + "@vicons/material": "^0.11.0", + "@vicons/tabler": "^0.11.0", "@vitejs/plugin-vue": "^1.6.2", "@vue/compiler-sfc": "^3.2.11", "@vue/eslint-config-prettier": "^6.0.0", @@ -60,9 +67,9 @@ "patch-package": "^6.4.7", "postinstall-postinstall": "^2.1.0", "prettier": "^2.4.0", - "sass": "^1.40.0", + "sass": "^1.41.0", "typescript": "^4.4.3", - "unplugin-icons": "^0.10.0", + "unplugin-icons": "^0.11.1", "unplugin-vue-components": "^0.15.1", "vite": "^2.5.7", "vite-plugin-html": "^2.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3ed735ed..438f8637 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,14 @@ specifiers: '@types/smoothscroll-polyfill': ^0.3.1 '@typescript-eslint/eslint-plugin': ^4.31.1 '@typescript-eslint/parser': ^4.31.1 + '@vicons/antd': ^0.11.0 + '@vicons/carbon': ^0.11.0 + '@vicons/fa': ^0.11.0 + '@vicons/fluent': ^0.11.0 + '@vicons/ionicons4': ^0.11.0 + '@vicons/ionicons5': ^0.11.0 + '@vicons/material': ^0.11.0 + '@vicons/tabler': ^0.11.0 '@vitejs/plugin-vue': ^1.6.2 '@vue/compiler-sfc': ^3.2.11 '@vue/eslint-config-prettier': ^6.0.0 @@ -38,10 +46,9 @@ specifiers: postinstall-postinstall: ^2.1.0 prettier: ^2.4.0 qs: ^6.10.1 - sass: ^1.40.0 - smoothscroll-polyfill: ^0.4.4 + sass: ^1.41.0 typescript: ^4.4.3 - unplugin-icons: ^0.10.0 + unplugin-icons: ^0.11.1 unplugin-vue-components: ^0.15.1 vite: ^2.5.7 vite-plugin-html: ^2.1.0 @@ -60,7 +67,6 @@ dependencies: naive-ui: registry.nlark.com/naive-ui/2.18.2_vue@3.2.10 pinia: registry.nlark.com/pinia/2.0.0-rc.4_typescript@4.4.3+vue@3.2.10 qs: 6.10.1 - smoothscroll-polyfill: registry.nlark.com/smoothscroll-polyfill/0.4.4 vue: registry.nlark.com/vue/3.2.10 vue-router: registry.nlark.com/vue-router/4.0.11_vue@3.2.10 @@ -75,6 +81,14 @@ devDependencies: '@types/smoothscroll-polyfill': registry.nlark.com/@types/smoothscroll-polyfill/0.3.1 '@typescript-eslint/eslint-plugin': registry.nlark.com/@typescript-eslint/eslint-plugin/4.31.1_e2d3c88d378335c4183365c112128ce9 '@typescript-eslint/parser': registry.nlark.com/@typescript-eslint/parser/4.31.1_eslint@7.32.0+typescript@4.4.3 + '@vicons/antd': registry.nlark.com/@vicons/antd/0.11.0 + '@vicons/carbon': registry.nlark.com/@vicons/carbon/0.11.0 + '@vicons/fa': registry.nlark.com/@vicons/fa/0.11.0 + '@vicons/fluent': registry.nlark.com/@vicons/fluent/0.11.0 + '@vicons/ionicons4': registry.nlark.com/@vicons/ionicons4/0.11.0 + '@vicons/ionicons5': registry.nlark.com/@vicons/ionicons5/0.11.0 + '@vicons/material': registry.nlark.com/@vicons/material/0.11.0 + '@vicons/tabler': registry.nlark.com/@vicons/tabler/0.11.0 '@vitejs/plugin-vue': registry.nlark.com/@vitejs/plugin-vue/1.6.2_@vue+compiler-sfc@3.2.11 '@vue/compiler-sfc': registry.nlark.com/@vue/compiler-sfc/3.2.11 '@vue/eslint-config-prettier': 6.0.0_b4d73ff40db55d7af7de6f3602f2b630 @@ -94,9 +108,9 @@ devDependencies: patch-package: registry.nlark.com/patch-package/6.4.7 postinstall-postinstall: registry.nlark.com/postinstall-postinstall/2.1.0 prettier: registry.nlark.com/prettier/2.4.0 - sass: registry.nlark.com/sass/1.40.0 + sass: registry.nlark.com/sass/1.41.0 typescript: registry.nlark.com/typescript/4.4.3 - unplugin-icons: registry.nlark.com/unplugin-icons/0.10.0_54da2e3458e54be8937824c348b2c77e + unplugin-icons: registry.nlark.com/unplugin-icons/0.11.1_54da2e3458e54be8937824c348b2c77e unplugin-vue-components: registry.nlark.com/unplugin-vue-components/0.15.1_vite@2.5.7+vue@3.2.10 vite: registry.nlark.com/vite/2.5.7 vite-plugin-html: registry.nlark.com/vite-plugin-html/2.1.0_vite@2.5.7 @@ -917,11 +931,6 @@ packages: engines: {node: '>= 0.4'} dev: true - /is-number/7.0.0: - resolution: {integrity: sha1-dTU0W4lnNNX4DE0GxQlVUnoU8Ss=, tarball: is-number/download/is-number-7.0.0.tgz} - engines: {node: '>=0.12.0'} - dev: true - /is-obj/1.0.1: resolution: {integrity: sha1-PkcprB9f3gJc19g6iW2rn09n2w8=, tarball: is-obj/download/is-obj-1.0.1.tgz} engines: {node: '>=0.10.0'} @@ -2038,6 +2047,14 @@ packages: '@types/throttle-debounce': registry.nlark.com/@types/throttle-debounce/2.1.0 dev: true + registry.nlark.com/@antfu/utils/0.3.0: + resolution: {integrity: sha1-YwbEO1Kog72Olz4+2N1kJIQYvMQ=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@antfu/utils/download/@antfu/utils-0.3.0.tgz} + name: '@antfu/utils' + version: 0.3.0 + dependencies: + '@types/throttle-debounce': registry.nlark.com/@types/throttle-debounce/2.1.0 + dev: true + registry.nlark.com/@babel/code-frame/7.12.11: resolution: {integrity: sha1-9K1DWqJj25NbjxDyxVLSP7cWpj8=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@babel/code-frame/download/@babel/code-frame-7.12.11.tgz} name: '@babel/code-frame' @@ -2165,7 +2182,7 @@ packages: dev: true registry.nlark.com/@commitlint/load/13.1.0: - resolution: {integrity: sha1-1sm1R1UfIhZYbWwZZNk/kuewQnc=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@commitlint/load/download/@commitlint/load-13.1.0.tgz} + resolution: {integrity: sha1-1sm1R1UfIhZYbWwZZNk/kuewQnc=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@commitlint/load/download/@commitlint/load-13.1.0.tgz} name: '@commitlint/load' version: 13.1.0 engines: {node: '>=v12'} @@ -2315,6 +2332,8 @@ packages: js-yaml: 3.14.1 minimatch: 3.0.4 strip-json-comments: 3.1.1 + transitivePeerDependencies: + - supports-color dev: true registry.nlark.com/@humanwhocodes/config-array/0.5.0: @@ -2326,6 +2345,8 @@ packages: '@humanwhocodes/object-schema': registry.nlark.com/@humanwhocodes/object-schema/1.2.0 debug: registry.nlark.com/debug/4.3.2 minimatch: 3.0.4 + transitivePeerDependencies: + - supports-color dev: true registry.nlark.com/@humanwhocodes/object-schema/1.2.0: @@ -2335,7 +2356,7 @@ packages: dev: true registry.nlark.com/@iconify/json-tools/1.0.10: - resolution: {integrity: sha1-2acFDbvouynWhNSz+URu0tC+o8w=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@iconify/json-tools/download/@iconify/json-tools-1.0.10.tgz} + resolution: {integrity: sha1-2acFDbvouynWhNSz+URu0tC+o8w=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@iconify/json-tools/download/@iconify/json-tools-1.0.10.tgz} name: '@iconify/json-tools' version: 1.0.10 dev: true @@ -2525,7 +2546,7 @@ packages: dev: true registry.nlark.com/@types/throttle-debounce/2.1.0: - resolution: {integrity: sha1-HD32JL/Eti+ZLTASuExW1B6rN3Y=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@types/throttle-debounce/download/@types/throttle-debounce-2.1.0.tgz} + resolution: {integrity: sha1-HD32JL/Eti+ZLTASuExW1B6rN3Y=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@types/throttle-debounce/download/@types/throttle-debounce-2.1.0.tgz} name: '@types/throttle-debounce' version: 2.1.0 dev: true @@ -2667,6 +2688,54 @@ packages: eslint-visitor-keys: registry.nlark.com/eslint-visitor-keys/2.1.0 dev: true + registry.nlark.com/@vicons/antd/0.11.0: + resolution: {integrity: sha1-PSiVLQKK7XEtymHLgdvbEUVMVUI=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@vicons/antd/download/@vicons/antd-0.11.0.tgz} + name: '@vicons/antd' + version: 0.11.0 + dev: true + + registry.nlark.com/@vicons/carbon/0.11.0: + resolution: {integrity: sha1-UQ4B6IOnOx1DQ6PrHRAUFEZGOr4=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@vicons/carbon/download/@vicons/carbon-0.11.0.tgz} + name: '@vicons/carbon' + version: 0.11.0 + dev: true + + registry.nlark.com/@vicons/fa/0.11.0: + resolution: {integrity: sha1-3GeAslt5Q3NOfHXXTfL0RDsFcq4=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@vicons/fa/download/@vicons/fa-0.11.0.tgz} + name: '@vicons/fa' + version: 0.11.0 + dev: true + + registry.nlark.com/@vicons/fluent/0.11.0: + resolution: {integrity: sha1-hPPNolVTnLlvRcicFgHiiS15gm8=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@vicons/fluent/download/@vicons/fluent-0.11.0.tgz} + name: '@vicons/fluent' + version: 0.11.0 + dev: true + + registry.nlark.com/@vicons/ionicons4/0.11.0: + resolution: {integrity: sha1-pg9erWYdRz8XEDrQBRzoKtdxu+Y=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@vicons/ionicons4/download/@vicons/ionicons4-0.11.0.tgz} + name: '@vicons/ionicons4' + version: 0.11.0 + dev: true + + registry.nlark.com/@vicons/ionicons5/0.11.0: + resolution: {integrity: sha1-VBhb+lcqCd9wCU2xlU8ov78TY+0=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@vicons/ionicons5/download/@vicons/ionicons5-0.11.0.tgz} + name: '@vicons/ionicons5' + version: 0.11.0 + dev: true + + registry.nlark.com/@vicons/material/0.11.0: + resolution: {integrity: sha1-LCCRIfP/akZFD0loOX32wwCN+NE=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@vicons/material/download/@vicons/material-0.11.0.tgz} + name: '@vicons/material' + version: 0.11.0 + dev: true + + registry.nlark.com/@vicons/tabler/0.11.0: + resolution: {integrity: sha1-nrBXnADKowQMLBz55cDHa6EgT7M=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@vicons/tabler/download/@vicons/tabler-0.11.0.tgz} + name: '@vicons/tabler' + version: 0.11.0 + dev: true + registry.nlark.com/@vitejs/plugin-vue/1.6.2_@vue+compiler-sfc@3.2.11: resolution: {integrity: sha1-QN/jFM/2ENTdAnoLTqKpOiV/P8k=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@vitejs/plugin-vue/download/@vitejs/plugin-vue-1.6.2.tgz} id: registry.nlark.com/@vitejs/plugin-vue/1.6.2 @@ -3083,12 +3152,12 @@ packages: dev: true registry.nlark.com/anymatch/3.1.2: - resolution: {integrity: sha1-wFV8CWrzLxBhmPT04qODU343hxY=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/anymatch/download/anymatch-3.1.2.tgz} + resolution: {integrity: sha1-wFV8CWrzLxBhmPT04qODU343hxY=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/anymatch/download/anymatch-3.1.2.tgz} name: anymatch version: 3.1.2 engines: {node: '>= 8'} dependencies: - normalize-path: 3.0.0 + normalize-path: registry.nlark.com/normalize-path/3.0.0 picomatch: registry.nlark.com/picomatch/2.3.0 dev: true @@ -3129,6 +3198,8 @@ packages: version: 0.21.4 dependencies: follow-redirects: registry.nlark.com/follow-redirects/1.14.2 + transitivePeerDependencies: + - debug dev: false registry.nlark.com/babel-walk/3.0.0-canary-5: @@ -3147,7 +3218,7 @@ packages: dev: true registry.nlark.com/binary-extensions/2.2.0: - resolution: {integrity: sha1-dfUC7q+f/eQvyYgpZFvk6na9ni0=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/binary-extensions/download/binary-extensions-2.2.0.tgz} + resolution: {integrity: sha1-dfUC7q+f/eQvyYgpZFvk6na9ni0=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/binary-extensions/download/binary-extensions-2.2.0.tgz} name: binary-extensions version: 2.2.0 engines: {node: '>=8'} @@ -3168,6 +3239,15 @@ packages: concat-map: 0.0.1 dev: true + registry.nlark.com/braces/3.0.2: + resolution: {integrity: sha1-NFThpGLujVmeI23zNs2epPiv4Qc=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/braces/download/braces-3.0.2.tgz} + name: braces + version: 3.0.2 + engines: {node: '>=8'} + dependencies: + fill-range: registry.nlark.com/fill-range/7.0.1 + dev: true + registry.nlark.com/buffer-from/1.1.2: resolution: {integrity: sha1-KxRqb9cugLT1XSVfNe1Zo6mkG9U=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/buffer-from/download/buffer-from-1.1.2.tgz} name: buffer-from @@ -3227,17 +3307,17 @@ packages: supports-color: registry.nlark.com/supports-color/7.2.0 registry.nlark.com/chokidar/3.5.2: - resolution: {integrity: sha1-26OXb8rbAW9m/TZQIdkWANAcHnU=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/chokidar/download/chokidar-3.5.2.tgz?cache=0&sync_timestamp=1623763535523&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fchokidar%2Fdownload%2Fchokidar-3.5.2.tgz} + resolution: {integrity: sha1-26OXb8rbAW9m/TZQIdkWANAcHnU=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/chokidar/download/chokidar-3.5.2.tgz} name: chokidar version: 3.5.2 engines: {node: '>= 8.10.0'} dependencies: anymatch: registry.nlark.com/anymatch/3.1.2 - braces: 3.0.2 + braces: registry.nlark.com/braces/3.0.2 glob-parent: registry.nlark.com/glob-parent/5.1.2 is-binary-path: registry.nlark.com/is-binary-path/2.1.0 is-glob: registry.nlark.com/is-glob/4.0.1 - normalize-path: 3.0.0 + normalize-path: registry.nlark.com/normalize-path/3.0.0 readdirp: registry.nlark.com/readdirp/3.6.0 optionalDependencies: fsevents: registry.nlark.com/fsevents/2.3.2 @@ -3826,6 +3906,8 @@ packages: table: registry.nlark.com/table/6.7.1 text-table: 0.2.0 v8-compile-cache: 2.3.0 + transitivePeerDependencies: + - supports-color dev: true registry.nlark.com/espree/6.2.1: @@ -3923,7 +4005,7 @@ packages: dev: true registry.nlark.com/fill-range/7.0.1: - resolution: {integrity: sha1-GRmmp8df44ssfHflGYU12prN2kA=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/fill-range/download/fill-range-7.0.1.tgz} + resolution: {integrity: sha1-GRmmp8df44ssfHflGYU12prN2kA=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/fill-range/download/fill-range-7.0.1.tgz} name: fill-range version: 7.0.1 engines: {node: '>=8'} @@ -3968,6 +4050,11 @@ packages: name: follow-redirects version: 1.14.2 engines: {node: '>=4.0'} + peerDependencies: + debug: '*' + peerDependenciesMeta: + debug: + optional: true dev: false registry.nlark.com/fs-extra/10.0.0: @@ -4010,7 +4097,7 @@ packages: dev: true registry.nlark.com/fsevents/2.3.2: - resolution: {integrity: sha1-ilJveLj99GI7cJ4Ll1xSwkwC/Ro=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/fsevents/download/fsevents-2.3.2.tgz} + resolution: {integrity: sha1-ilJveLj99GI7cJ4Ll1xSwkwC/Ro=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/fsevents/download/fsevents-2.3.2.tgz} name: fsevents version: 2.3.2 engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -4263,7 +4350,7 @@ packages: dev: true registry.nlark.com/is-binary-path/2.1.0: - resolution: {integrity: sha1-6h9/O4DwZCNug0cPhsCcJU+0Wwk=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/is-binary-path/download/is-binary-path-2.1.0.tgz} + resolution: {integrity: sha1-6h9/O4DwZCNug0cPhsCcJU+0Wwk=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/is-binary-path/download/is-binary-path-2.1.0.tgz} name: is-binary-path version: 2.1.0 engines: {node: '>=8'} @@ -4305,13 +4392,20 @@ packages: has-tostringtag: registry.nlark.com/has-tostringtag/1.0.0 dev: true + registry.nlark.com/is-extglob/2.1.1: + resolution: {integrity: sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/is-extglob/download/is-extglob-2.1.1.tgz} + name: is-extglob + version: 2.1.1 + engines: {node: '>=0.10.0'} + dev: true + registry.nlark.com/is-glob/4.0.1: - resolution: {integrity: sha1-dWfb6fL14kZ7x3q4PEopSCQHpdw=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/is-glob/download/is-glob-4.0.1.tgz?cache=0&sync_timestamp=1624543039732&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-glob%2Fdownload%2Fis-glob-4.0.1.tgz} + resolution: {integrity: sha1-dWfb6fL14kZ7x3q4PEopSCQHpdw=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/is-glob/download/is-glob-4.0.1.tgz} name: is-glob version: 4.0.1 engines: {node: '>=0.10.0'} dependencies: - is-extglob: 2.1.1 + is-extglob: registry.nlark.com/is-extglob/2.1.1 dev: true registry.nlark.com/is-number-object/1.0.6: @@ -4323,6 +4417,13 @@ packages: has-tostringtag: registry.nlark.com/has-tostringtag/1.0.0 dev: true + registry.nlark.com/is-number/7.0.0: + resolution: {integrity: sha1-dTU0W4lnNNX4DE0GxQlVUnoU8Ss=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/is-number/download/is-number-7.0.0.tgz} + name: is-number + version: 7.0.0 + engines: {node: '>=0.12.0'} + dev: true + registry.nlark.com/is-regex/1.1.4: resolution: {integrity: sha1-7vVmPNWfpMCuM5UFMj32hUuxWVg=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/is-regex/download/is-regex-1.1.4.tgz} name: is-regex @@ -4724,6 +4825,13 @@ packages: validate-npm-package-license: 3.0.4 dev: true + registry.nlark.com/normalize-path/3.0.0: + resolution: {integrity: sha1-Dc1p/yOhybEf0JeDFmRKA4ghamU=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/normalize-path/download/normalize-path-3.0.0.tgz} + name: normalize-path + version: 3.0.0 + engines: {node: '>=0.10.0'} + dev: true + registry.nlark.com/object-assign/4.1.1: resolution: {integrity: sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/object-assign/download/object-assign-4.1.1.tgz?cache=0&sync_timestamp=1618847043548&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fobject-assign%2Fdownload%2Fobject-assign-4.1.1.tgz} name: object-assign @@ -4885,7 +4993,7 @@ packages: dev: true registry.nlark.com/picomatch/2.3.0: - resolution: {integrity: sha1-8fBh3o9qS/AiiS4tEoI0+5gwKXI=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/picomatch/download/picomatch-2.3.0.tgz} + resolution: {integrity: sha1-8fBh3o9qS/AiiS4tEoI0+5gwKXI=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/picomatch/download/picomatch-2.3.0.tgz} name: picomatch version: 2.3.0 engines: {node: '>=8.6'} @@ -4937,6 +5045,9 @@ packages: engines: {node: '>= 10'} peerDependencies: ts-node: '>=9.0.0' + peerDependenciesMeta: + ts-node: + optional: true dependencies: import-cwd: registry.nlark.com/import-cwd/3.0.0 lilconfig: registry.nlark.com/lilconfig/2.0.3 @@ -5112,7 +5223,7 @@ packages: dev: true registry.nlark.com/readdirp/3.6.0: - resolution: {integrity: sha1-dKNwvYVxFuJFspzJc0DNQxoCpsc=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/readdirp/download/readdirp-3.6.0.tgz} + resolution: {integrity: sha1-dKNwvYVxFuJFspzJc0DNQxoCpsc=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/readdirp/download/readdirp-3.6.0.tgz} name: readdirp version: 3.6.0 engines: {node: '>=8.10.0'} @@ -5200,10 +5311,10 @@ packages: tslib: registry.nlark.com/tslib/1.14.1 dev: true - registry.nlark.com/sass/1.40.0: - resolution: {integrity: sha1-/6cQbZwBhRafWwjqqxPWNN75SPI=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/sass/download/sass-1.40.0.tgz?cache=0&sync_timestamp=1631577412662&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fsass%2Fdownload%2Fsass-1.40.0.tgz} + registry.nlark.com/sass/1.41.0: + resolution: {integrity: sha1-97QdwAM2pMA0KcN7loC4Z1ivYdQ=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/sass/download/sass-1.41.0.tgz} name: sass - version: 1.40.0 + version: 1.41.0 engines: {node: '>=8.9.0'} hasBin: true dependencies: @@ -5254,12 +5365,6 @@ packages: engines: {node: '>=8'} dev: true - registry.nlark.com/smoothscroll-polyfill/0.4.4: - resolution: {integrity: sha1-OiWRMdxpMObKgAA+HLA7YDtpq/g=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/smoothscroll-polyfill/download/smoothscroll-polyfill-0.4.4.tgz} - name: smoothscroll-polyfill - version: 0.4.4 - dev: false - registry.nlark.com/source-map-js/0.6.2: resolution: {integrity: sha1-C7XeYxtBz72mz7qL0FqA79/SOF4=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/source-map-js/download/source-map-js-0.6.2.tgz} name: source-map-js @@ -5423,12 +5528,12 @@ packages: engines: {node: '>=4'} registry.nlark.com/to-regex-range/5.0.1: - resolution: {integrity: sha1-FkjESq58jZiKMmAY7XL1tN0DkuQ=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/to-regex-range/download/to-regex-range-5.0.1.tgz} + resolution: {integrity: sha1-FkjESq58jZiKMmAY7XL1tN0DkuQ=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/to-regex-range/download/to-regex-range-5.0.1.tgz} name: to-regex-range version: 5.0.1 engines: {node: '>=8.0'} dependencies: - is-number: 7.0.0 + is-number: registry.nlark.com/is-number/7.0.0 dev: true registry.nlark.com/token-stream/1.0.0: @@ -5488,6 +5593,9 @@ packages: hasBin: true peerDependencies: typescript: ^4.2.3 + peerDependenciesMeta: + typescript: + optional: true dependencies: cac: registry.nlark.com/cac/6.7.3 chalk: registry.nlark.com/chalk/4.1.2 @@ -5560,18 +5668,28 @@ packages: hasBin: true dev: true - registry.nlark.com/unplugin-icons/0.10.0_54da2e3458e54be8937824c348b2c77e: - resolution: {integrity: sha1-u4LobC5YdZnVLfDw0HzjB7Ivjq4=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/unplugin-icons/download/unplugin-icons-0.10.0.tgz} - id: registry.nlark.com/unplugin-icons/0.10.0 + registry.nlark.com/unplugin-icons/0.11.1_54da2e3458e54be8937824c348b2c77e: + resolution: {integrity: sha1-nodRKlzdyx0RPsD6N+xtlR/IS8U=, registry: http://registry.npm.taobao.org/, tarball: https://registry.nlark.com/unplugin-icons/download/unplugin-icons-0.11.1.tgz} + id: registry.nlark.com/unplugin-icons/0.11.1 name: unplugin-icons - version: 0.10.0 + version: 0.11.1 peerDependencies: '@iconify/json': '*' '@svgr/core': ^5.5.0 '@vue/compiler-sfc': ^3.0.2 vue-template-compiler: ^2.6.12 vue-template-es2015-compiler: ^1.9.0 + peerDependenciesMeta: + '@svgr/core': + optional: true + '@vue/compiler-sfc': + optional: true + vue-template-compiler: + optional: true + vue-template-es2015-compiler: + optional: true dependencies: + '@antfu/utils': registry.nlark.com/@antfu/utils/0.3.0 '@iconify/json': registry.nlark.com/@iconify/json/1.1.401 '@iconify/json-tools': registry.nlark.com/@iconify/json-tools/1.0.10 '@vue/compiler-sfc': registry.nlark.com/@vue/compiler-sfc/3.2.11 @@ -5618,6 +5736,13 @@ packages: rollup: ^2.50.0 vite: ^2.3.0 webpack: 4 || 5 + peerDependenciesMeta: + rollup: + optional: true + vite: + optional: true + webpack: + optional: true dependencies: upath: 2.0.1 vite: registry.nlark.com/vite/2.5.7 @@ -5870,9 +5995,6 @@ packages: peerDependencies: '@vue/composition-api': ^1.0.0-rc.1 vue: ^3.0.0-0 || ^2.6.0 - peerDependenciesMeta: - '@vue/composition-api': - optional: true dependencies: vue: registry.nlark.com/vue/3.2.10 dev: false diff --git a/src/interface/common.ts b/src/interface/common.ts index 8171f1dc..a0c63f86 100644 --- a/src/interface/common.ts +++ b/src/interface/common.ts @@ -1,8 +1,10 @@ +import type { Component } from 'vue'; import type { RouteRecordRaw } from 'vue-router'; +import type { MenuOption } from 'naive-ui'; import { EnumRoutePath, EnumLoginModule } from '@/enum'; /** 路由描述 */ -export interface RouteMeta { +interface RouteMeta { /** 路由名称 */ title?: string; /** 页面100%视高 */ @@ -10,11 +12,16 @@ export interface RouteMeta { /** 作为菜单 */ asMenu?: boolean; /** 菜单和面包屑对应的图标 */ - icon?: string; + icon?: Component; } export type CustomRoute = RouteRecordRaw & { meta: RouteMeta }; export type RoutePathKey = keyof typeof EnumRoutePath; +export type GlobalMenuOption = MenuOption & { + routeName: string; + routePath: string; +}; + export type LoginModuleType = keyof typeof EnumLoginModule; diff --git a/src/interface/index.ts b/src/interface/index.ts index 9a3d929d..5045405c 100644 --- a/src/interface/index.ts +++ b/src/interface/index.ts @@ -1,3 +1,3 @@ export { UserInfo } from './business'; export { ThemeSettings, NavMode, AnimateType } from './theme'; -export { CustomRoute, RoutePathKey, LoginModuleType } from './common'; +export { CustomRoute, RoutePathKey, GlobalMenuOption, LoginModuleType } from './common'; diff --git a/src/layouts/BasicLayout/components/GlobalHeader/components/UserAvatar.vue b/src/layouts/BasicLayout/components/GlobalHeader/components/UserAvatar.vue new file mode 100644 index 00000000..73b5fa81 --- /dev/null +++ b/src/layouts/BasicLayout/components/GlobalHeader/components/UserAvatar.vue @@ -0,0 +1,45 @@ + + + + diff --git a/src/layouts/BasicLayout/components/GlobalHeader/components/index.ts b/src/layouts/BasicLayout/components/GlobalHeader/components/index.ts index 668d96f5..9d3b18d0 100644 --- a/src/layouts/BasicLayout/components/GlobalHeader/components/index.ts +++ b/src/layouts/BasicLayout/components/GlobalHeader/components/index.ts @@ -1,3 +1,4 @@ +import UserAvatar from './UserAvatar.vue'; import HeaderItem from './HeaderItem.vue'; -export { HeaderItem }; +export { UserAvatar, HeaderItem }; diff --git a/src/layouts/BasicLayout/components/GlobalHeader/index.vue b/src/layouts/BasicLayout/components/GlobalHeader/index.vue index 48880d71..5c868935 100644 --- a/src/layouts/BasicLayout/components/GlobalHeader/index.vue +++ b/src/layouts/BasicLayout/components/GlobalHeader/index.vue @@ -10,6 +10,7 @@ + @@ -23,7 +24,7 @@ import { computed } from 'vue'; import { NLayoutHeader } from 'naive-ui'; import { useFullscreen } from '@vueuse/core'; import { useAppStore, useThemeStore } from '@/store'; -import { HeaderItem } from './components'; +import { UserAvatar, HeaderItem } from './components'; import { GlobalLogo } from '../common'; defineProps({ diff --git a/src/layouts/BasicLayout/components/common/GlobalLogo.vue b/src/layouts/BasicLayout/components/common/GlobalLogo.vue index daeab1d3..d1b212c3 100644 --- a/src/layouts/BasicLayout/components/common/GlobalLogo.vue +++ b/src/layouts/BasicLayout/components/common/GlobalLogo.vue @@ -1,18 +1,21 @@ diff --git a/src/layouts/BasicLayout/components/common/GlobalMenu.vue b/src/layouts/BasicLayout/components/common/GlobalMenu.vue index 82c4db74..6f323adc 100644 --- a/src/layouts/BasicLayout/components/common/GlobalMenu.vue +++ b/src/layouts/BasicLayout/components/common/GlobalMenu.vue @@ -1,11 +1,35 @@ - + diff --git a/src/main.ts b/src/main.ts index 252c1daf..237bc1a4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,7 +3,7 @@ import App from './App.vue'; import AppProvider from './AppProvider.vue'; import { setupStore } from './store'; import { setupRouter } from './router'; -import { setupSmoothScroll, setupWindicssDarkMode } from './plugins'; +import { setupWindicssDarkMode } from './plugins'; import 'virtual:windi.css'; import './styles/css/global.css'; @@ -27,5 +27,4 @@ async function setupApp() { setupWindicssDarkMode(); } -setupSmoothScroll(); setupApp(); diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 5c72f7db..1bfd8ff0 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -1,4 +1,3 @@ -import setupSmoothScroll from './smooth-scroll'; import setupWindicssDarkMode from './dark-mode'; -export { setupSmoothScroll, setupWindicssDarkMode }; +export { setupWindicssDarkMode }; diff --git a/src/plugins/smooth-scroll.ts b/src/plugins/smooth-scroll.ts deleted file mode 100644 index 7c803a35..00000000 --- a/src/plugins/smooth-scroll.ts +++ /dev/null @@ -1,6 +0,0 @@ -import smoothscroll from 'smoothscroll-polyfill'; - -/** 平滑滚动插件(兼容主流浏览器) */ -export default function setupSmoothScroll(): void { - smoothscroll.polyfill(); -} diff --git a/src/router/index.ts b/src/router/index.ts index f5cb71b2..6157e480 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -21,3 +21,4 @@ export async function setupRouter(app: App) { } export { RouteNameMap }; +export { menus } from './menus'; diff --git a/src/router/menus.ts b/src/router/menus.ts index 487c54fc..0ff90f65 100644 --- a/src/router/menus.ts +++ b/src/router/menus.ts @@ -1,5 +1,49 @@ -import { CustomRoute } from '@/interface'; +import type { Component } from 'vue'; +import { customRoutes } from './routes'; +import { CustomRoute, GlobalMenuOption } from '@/interface'; +import { dynamicIconRender } from '@/utils'; export function transformRouteToMenu(routes: CustomRoute[]) { - return routes; + const globalMenu: GlobalMenuOption[] = []; + routes.forEach(route => { + if (asMenu(route)) { + const { name, path, meta } = route; + const routeName = name as string; + let menuChildren: GlobalMenuOption[] | undefined; + if (route.children) { + menuChildren = transformRouteToMenu(route.children as CustomRoute[]); + } + const menuItem: GlobalMenuOption = addPartialProps( + { + key: routeName, + label: meta?.title ?? routeName, + routeName, + routePath: path + }, + meta?.icon, + menuChildren + ); + globalMenu.push(menuItem); + } + }); + return globalMenu; } + +/** 判断路由是否作为菜单 */ +function asMenu(route: CustomRoute) { + return Boolean(route.meta?.asMenu); +} + +/** 给菜单添加可选属性 */ +function addPartialProps(menuItem: GlobalMenuOption, icon?: Component, children?: GlobalMenuOption[]) { + const item = { ...menuItem }; + if (icon) { + Object.assign(item, { icon: dynamicIconRender(icon) }); + } + if (children) { + Object.assign(item, { children }); + } + return item; +} + +export const menus = transformRouteToMenu(customRoutes); diff --git a/src/router/routes.ts b/src/router/routes.ts index 920a062e..eab8064e 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -1,4 +1,6 @@ import type { RouteRecordRaw } from 'vue-router'; +import { Dashboard } from '@vicons/carbon'; +import { ExceptionOutlined } from '@vicons/antd'; import { BasicLayout, BlankLayout } from '@/layouts'; import { EnumRoutePath, EnumRouteTitle } from '@/enum'; import type { CustomRoute, RoutePathKey, LoginModuleType } from '@/interface'; @@ -100,7 +102,7 @@ export const customRoutes: CustomRoute[] = [ meta: { title: EnumRouteTitle.dashboard, asMenu: true, - icon: 'mdi:view-dashboard' + icon: Dashboard }, children: [ { @@ -130,7 +132,7 @@ export const customRoutes: CustomRoute[] = [ meta: { title: EnumRouteTitle.exception, asMenu: true, - icon: 'ant-design:exception-outlined' + icon: ExceptionOutlined }, children: [ { @@ -157,7 +159,7 @@ export const customRoutes: CustomRoute[] = [ component: () => import('@/views/system/exception/500.vue'), meta: { title: EnumRouteTitle['exception-500'], - asMenu: true + asMenu: false } } ] diff --git a/src/store/modules/auth/index.ts b/src/store/modules/auth/index.ts index bf99110f..87d5205b 100644 --- a/src/store/modules/auth/index.ts +++ b/src/store/modules/auth/index.ts @@ -1,5 +1,6 @@ import { defineStore } from 'pinia'; import { store } from '@/store'; +import { removeToken } from '@/utils'; import type { UserInfo } from '@/interface'; interface AuthState { @@ -30,7 +31,9 @@ const authStore = defineStore({ actions: { /** 重置auth状态 */ resetAuthState() { + removeToken(); this.$reset(); + window.location.reload(); } } }); diff --git a/src/utils/auth/index.ts b/src/utils/auth/index.ts index 8efa9e9b..766812d4 100644 --- a/src/utils/auth/index.ts +++ b/src/utils/auth/index.ts @@ -1,2 +1,2 @@ -export { getToken, setToken, getUserInfo, getLoginModuleRegExp } from './user'; +export { getToken, setToken, removeToken, getUserInfo, getLoginModuleRegExp } from './user'; export { getLoginRedirectUrl, toLoginRedirectUrl, toHomeByLocation } from './location'; diff --git a/src/utils/auth/user.ts b/src/utils/auth/user.ts index 8db728b5..b430869d 100644 --- a/src/utils/auth/user.ts +++ b/src/utils/auth/user.ts @@ -1,6 +1,6 @@ import { EnumStorageKey } from '@/enum'; import type { LoginModuleType } from '@/interface'; -import { setLocal, getLocal } from '../storage'; +import { setLocal, getLocal, removeLocal } from '../storage'; /** 设置token */ export function getToken() { @@ -12,6 +12,10 @@ export function setToken(token: string) { setLocal(EnumStorageKey.token, token); } +export function removeToken() { + removeLocal(EnumStorageKey.token); +} + export function getUserInfo() {} /** 获取登录模块的正则字符串 */ diff --git a/src/utils/common/icon.ts b/src/utils/common/icon.ts new file mode 100644 index 00000000..c8d823be --- /dev/null +++ b/src/utils/common/icon.ts @@ -0,0 +1,12 @@ +import { h } from 'vue'; +import type { Component } from 'vue'; +import { NIcon } from 'naive-ui'; + +/** 动态渲染vicon */ +export function dynamicIconRender(icon: Component) { + return () => { + return h(NIcon, null, { + default: () => h(icon) + }); + }; +} diff --git a/src/utils/common/index.ts b/src/utils/common/index.ts index c5bd9e07..6b9eb1bf 100644 --- a/src/utils/common/index.ts +++ b/src/utils/common/index.ts @@ -13,3 +13,5 @@ export { } from './typeof'; export { brightenColor, darkenColor } from './color'; + +export { dynamicIconRender } from './icon'; diff --git a/src/utils/index.ts b/src/utils/index.ts index 10a58827..e68bade8 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,6 +1,7 @@ export { setToken, getToken, + removeToken, getUserInfo, getLoginModuleRegExp, getLoginRedirectUrl, @@ -21,7 +22,8 @@ export { isSet, isMap, brightenColor, - darkenColor + darkenColor, + dynamicIconRender } from './common'; export { setLocal, getLocal, setSession, getSession } from './storage'; diff --git a/src/utils/storage/index.ts b/src/utils/storage/index.ts index 4ef4c94c..5aa7479b 100644 --- a/src/utils/storage/index.ts +++ b/src/utils/storage/index.ts @@ -1,2 +1,2 @@ -export { setLocal, getLocal } from './local'; +export { setLocal, getLocal, removeLocal } from './local'; export { setSession, getSession } from './session'; diff --git a/src/utils/storage/local.ts b/src/utils/storage/local.ts index 481351c5..b14efc98 100644 --- a/src/utils/storage/local.ts +++ b/src/utils/storage/local.ts @@ -1,12 +1,16 @@ export function setLocal(key: string, value: unknown) { const json = JSON.stringify(value); - localStorage.setItem(key, json); + window.localStorage.setItem(key, json); } export function getLocal(key: string) { - const json = localStorage.getItem(key); + const json = window.localStorage.getItem(key); if (json) { return JSON.parse(json) as T; } return json; } + +export function removeLocal(key: string) { + window.localStorage.removeItem(key); +} diff --git a/src/views/dashboard/workbench/index.vue b/src/views/dashboard/workbench/index.vue index 37c228e0..5a5be2d6 100644 --- a/src/views/dashboard/workbench/index.vue +++ b/src/views/dashboard/workbench/index.vue @@ -2,20 +2,10 @@

工作台

analysis - 去除
diff --git a/src/views/system/login/index.vue b/src/views/system/login/index.vue index d7d0f021..5f563219 100644 --- a/src/views/system/login/index.vue +++ b/src/views/system/login/index.vue @@ -1,6 +1,5 @@