From 666576fefa2371a44b7e84e444e74eed15563039 Mon Sep 17 00:00:00 2001 From: songshankun <songshankun@foxmail.com> Date: 星期三, 25 十月 2023 18:03:43 +0800 Subject: [PATCH] chore: 配置组件库/图标库/axios --- src/views/HomeView.vue | 52 +++ src/views/AboutView.vue | 21 - tsconfig.app.json | 2 src/components/HelloWorld.vue | 7 package-lock.json | 459 ++++++++++++++++++++++++++++ src/assets/styles/main.css | 9 src/common/constants/index.ts | 3 src/components.d.ts | 16 + src/api/index.ts | 1 src/auto-imports.d.ts | 77 ++++ src/main.ts | 2 src/assets/styles/base.css | 0 /dev/null | 35 -- tsconfig.node.json | 8 vite.config.ts | 44 ++ tsconfig.json | 6 package.json | 4 src/assets/images/.gitkeep | 0 src/common/utils/request.ts | 62 +++ env.d.ts | 6 src/App.vue | 72 --- src/common/utils/index.ts | 12 src/common/composable/index.ts | 3 23 files changed, 759 insertions(+), 142 deletions(-) diff --git a/env.d.ts b/env.d.ts index 11f02fe..b3f1432 100644 --- a/env.d.ts +++ b/env.d.ts @@ -1 +1,7 @@ /// <reference types="vite/client" /> +/// <reference types="unplugin-icons/types/vue" /> +declare module '~icons/*' { + import { FunctionalComponent, SVGAttributes } from 'vue' + const component: FunctionalComponent<SVGAttributes> + export default component +} diff --git a/package-lock.json b/package-lock.json index 2b4ac5f..79581d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,7 +8,9 @@ "name": "basic-vue3-template", "version": "0.0.0", "dependencies": { + "@element-plus/icons-vue": "^2.1.0", "@vueuse/core": "^10.5.0", + "axios": "^1.5.1", "element-plus": "^2.4.1", "lodash-es": "^4.17.21", "pinia": "^2.1.7", @@ -16,6 +18,7 @@ "vue-router": "^4.2.5" }, "devDependencies": { + "@iconify-json/mdi": "^1.1.55", "@rushstack/eslint-patch": "^1.3.3", "@tsconfig/node18": "^18.2.2", "@types/node": "^18.18.6", @@ -32,6 +35,7 @@ "sass": "^1.69.4", "typescript": "~5.2.0", "unplugin-auto-import": "^0.16.6", + "unplugin-icons": "^0.17.1", "unplugin-vue-components": "^0.25.2", "vite": "^4.4.11", "vue-tsc": "^1.8.19" @@ -44,6 +48,96 @@ "dev": true, "engines": { "node": ">=0.10.0" + } + }, + "node_modules/@antfu/install-pkg": { + "version": "0.1.1", + "resolved": "https://registry.npmmirror.com/@antfu/install-pkg/-/install-pkg-0.1.1.tgz", + "integrity": "sha512-LyB/8+bSfa0DFGC06zpCEfs89/XoWZwws5ygEa5D+Xsm3OfI+aXQ86VgVG7Acyef+rSZ5HE7J8rrxzrQeM3PjQ==", + "dev": true, + "dependencies": { + "execa": "^5.1.1", + "find-up": "^5.0.0" + } + }, + "node_modules/@antfu/install-pkg/node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmmirror.com/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@antfu/install-pkg/node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/@antfu/install-pkg/node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@antfu/install-pkg/node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/@antfu/install-pkg/node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmmirror.com/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@antfu/install-pkg/node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmmirror.com/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@antfu/install-pkg/node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, + "engines": { + "node": ">=6" } }, "node_modules/@antfu/utils": { @@ -712,6 +806,35 @@ "resolved": "https://registry.npmmirror.com/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", "dev": true + }, + "node_modules/@iconify-json/mdi": { + "version": "1.1.55", + "resolved": "https://registry.npmmirror.com/@iconify-json/mdi/-/mdi-1.1.55.tgz", + "integrity": "sha512-ycnFub+EQx+3D/aDCg6iC7sjexOUa5GzxUNIZFFl0Pq7aDxbmhIludoyYnguEO3REyWf9FcOOmvVcQkdtwKHTw==", + "dev": true, + "dependencies": { + "@iconify/types": "*" + } + }, + "node_modules/@iconify/types": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/@iconify/types/-/types-2.0.0.tgz", + "integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==", + "dev": true + }, + "node_modules/@iconify/utils": { + "version": "2.1.11", + "resolved": "https://registry.npmmirror.com/@iconify/utils/-/utils-2.1.11.tgz", + "integrity": "sha512-M/w3PkN8zQYXi8N6qK/KhnYMfEbbb6Sk8RZVn8g+Pmmu5ybw177RpsaGwpziyHeUsu4etrexYSWq3rwnIqzYCg==", + "dev": true, + "dependencies": { + "@antfu/install-pkg": "^0.1.1", + "@antfu/utils": "^0.7.5", + "@iconify/types": "^2.0.0", + "debug": "^4.3.4", + "kolorist": "^1.8.0", + "local-pkg": "^0.4.3" + } }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.15", @@ -1455,6 +1578,21 @@ "resolved": "https://registry.npmmirror.com/async-validator/-/async-validator-4.2.5.tgz", "integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==" }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "node_modules/axios": { + "version": "1.5.1", + "resolved": "https://registry.npmmirror.com/axios/-/axios-1.5.1.tgz", + "integrity": "sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz", @@ -1635,6 +1773,17 @@ "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", "dev": true }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "11.1.0", "resolved": "https://registry.npmmirror.com/commander/-/commander-11.1.0.tgz", @@ -1756,6 +1905,14 @@ "dev": true, "engines": { "node": ">=12" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" } }, "node_modules/dir-glob": { @@ -2290,6 +2447,32 @@ "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", "dev": true }, + "node_modules/follow-redirects": { + "version": "1.15.3", + "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmmirror.com/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -2706,6 +2889,12 @@ "json-buffer": "3.0.1" } }, + "node_modules/kolorist": { + "version": "1.8.0", + "resolved": "https://registry.npmmirror.com/kolorist/-/kolorist-1.8.0.tgz", + "integrity": "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==", + "dev": true + }, "node_modules/levn": { "version": "0.4.1", "resolved": "https://registry.npmmirror.com/levn/-/levn-0.4.1.tgz", @@ -2978,6 +3167,25 @@ }, "engines": { "node": ">=8.6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" } }, "node_modules/mimic-fn": { @@ -3457,6 +3665,11 @@ "engines": { "node": ">=6.0.0" } + }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, "node_modules/punycode": { "version": "2.3.0", @@ -4159,6 +4372,58 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/unplugin-icons": { + "version": "0.17.1", + "resolved": "https://registry.npmmirror.com/unplugin-icons/-/unplugin-icons-0.17.1.tgz", + "integrity": "sha512-KsWejBPCHokYCNDQUzGu6R3E3XDYH/YpewgQwrVBXgpl1iR0RdW1NEGNdjlbuapwVnZXVgA5eiDTfNaQCawSdg==", + "dev": true, + "dependencies": { + "@antfu/install-pkg": "^0.1.1", + "@antfu/utils": "^0.7.6", + "@iconify/utils": "^2.1.11", + "debug": "^4.3.4", + "kolorist": "^1.8.0", + "local-pkg": "^0.5.0", + "unplugin": "^1.5.0" + }, + "peerDependencies": { + "@svgr/core": ">=7.0.0", + "@svgx/core": "^1.0.1", + "@vue/compiler-sfc": "^3.0.2 || ^2.7.0", + "vue-template-compiler": "^2.6.12", + "vue-template-es2015-compiler": "^1.9.0" + }, + "peerDependenciesMeta": { + "@svgr/core": { + "optional": true + }, + "@svgx/core": { + "optional": true + }, + "@vue/compiler-sfc": { + "optional": true + }, + "vue-template-compiler": { + "optional": true + }, + "vue-template-es2015-compiler": { + "optional": true + } + } + }, + "node_modules/unplugin-icons/node_modules/local-pkg": { + "version": "0.5.0", + "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.5.0.tgz", + "integrity": "sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==", + "dev": true, + "dependencies": { + "mlly": "^1.4.2", + "pkg-types": "^1.0.3" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/unplugin-vue-components": { "version": "0.25.2", "resolved": "https://registry.npmmirror.com/unplugin-vue-components/-/unplugin-vue-components-0.25.2.tgz", @@ -4499,6 +4764,77 @@ "resolved": "https://registry.npmmirror.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", "dev": true + }, + "@antfu/install-pkg": { + "version": "0.1.1", + "resolved": "https://registry.npmmirror.com/@antfu/install-pkg/-/install-pkg-0.1.1.tgz", + "integrity": "sha512-LyB/8+bSfa0DFGC06zpCEfs89/XoWZwws5ygEa5D+Xsm3OfI+aXQ86VgVG7Acyef+rSZ5HE7J8rrxzrQeM3PjQ==", + "dev": true, + "requires": { + "execa": "^5.1.1", + "find-up": "^5.0.0" + }, + "dependencies": { + "execa": { + "version": "5.1.1", + "resolved": "https://registry.npmmirror.com/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + } + }, + "human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true + }, + "is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, + "npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmmirror.com/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "requires": { + "path-key": "^3.0.0" + } + }, + "onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmmirror.com/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true + } + } }, "@antfu/utils": { "version": "0.7.6", @@ -4901,6 +5237,35 @@ "resolved": "https://registry.npmmirror.com/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", "dev": true + }, + "@iconify-json/mdi": { + "version": "1.1.55", + "resolved": "https://registry.npmmirror.com/@iconify-json/mdi/-/mdi-1.1.55.tgz", + "integrity": "sha512-ycnFub+EQx+3D/aDCg6iC7sjexOUa5GzxUNIZFFl0Pq7aDxbmhIludoyYnguEO3REyWf9FcOOmvVcQkdtwKHTw==", + "dev": true, + "requires": { + "@iconify/types": "*" + } + }, + "@iconify/types": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/@iconify/types/-/types-2.0.0.tgz", + "integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==", + "dev": true + }, + "@iconify/utils": { + "version": "2.1.11", + "resolved": "https://registry.npmmirror.com/@iconify/utils/-/utils-2.1.11.tgz", + "integrity": "sha512-M/w3PkN8zQYXi8N6qK/KhnYMfEbbb6Sk8RZVn8g+Pmmu5ybw177RpsaGwpziyHeUsu4etrexYSWq3rwnIqzYCg==", + "dev": true, + "requires": { + "@antfu/install-pkg": "^0.1.1", + "@antfu/utils": "^0.7.5", + "@iconify/types": "^2.0.0", + "debug": "^4.3.4", + "kolorist": "^1.8.0", + "local-pkg": "^0.4.3" + } }, "@jridgewell/sourcemap-codec": { "version": "1.4.15", @@ -5476,6 +5841,21 @@ "resolved": "https://registry.npmmirror.com/async-validator/-/async-validator-4.2.5.tgz", "integrity": "sha512-7HhHjtERjqlNbZtqNqy2rckN/SpOOlmDliet+lP7k+eKZEjPk3DgyeU9lIXLdeLz0uBbbVp+9Qdow9wJWgwwfg==" }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, + "axios": { + "version": "1.5.1", + "resolved": "https://registry.npmmirror.com/axios/-/axios-1.5.1.tgz", + "integrity": "sha512-Q28iYCWzNHjAm+yEAot5QaAMxhMghWLFVf7rRdwhUI+c2jix2DUXjAHXVi+s1ibs3mjPO/cCgbA++3BjD0vP/A==", + "requires": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "balanced-match": { "version": "1.0.2", "resolved": "https://registry.npmmirror.com/balanced-match/-/balanced-match-1.0.2.tgz", @@ -5620,6 +6000,14 @@ "integrity": "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==", "dev": true }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, "commander": { "version": "11.1.0", "resolved": "https://registry.npmmirror.com/commander/-/commander-11.1.0.tgz", @@ -5713,6 +6101,11 @@ "resolved": "https://registry.npmmirror.com/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz", "integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==", "dev": true + }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" }, "dir-glob": { "version": "3.0.1", @@ -6128,6 +6521,21 @@ "integrity": "sha512-36yxDn5H7OFZQla0/jFJmbIKTdZAQHngCedGxiMmpNfEZM0sdEeT+WczLQrjK6D7o2aiyLYDnkw0R3JK0Qv1RQ==", "dev": true }, + "follow-redirects": { + "version": "1.15.3", + "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.3.tgz", + "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==" + }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + }, "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmmirror.com/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -6446,6 +6854,12 @@ "json-buffer": "3.0.1" } }, + "kolorist": { + "version": "1.8.0", + "resolved": "https://registry.npmmirror.com/kolorist/-/kolorist-1.8.0.tgz", + "integrity": "sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==", + "dev": true + }, "levn": { "version": "0.4.1", "resolved": "https://registry.npmmirror.com/levn/-/levn-0.4.1.tgz", @@ -6655,6 +7069,19 @@ "requires": { "braces": "^3.0.2", "picomatch": "^2.3.1" + } + }, + "mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" + }, + "mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "requires": { + "mime-db": "1.52.0" } }, "mimic-fn": { @@ -7010,6 +7437,11 @@ "requires": { "fast-diff": "^1.1.2" } + }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, "punycode": { "version": "2.3.0", @@ -7555,6 +7987,33 @@ } } }, + "unplugin-icons": { + "version": "0.17.1", + "resolved": "https://registry.npmmirror.com/unplugin-icons/-/unplugin-icons-0.17.1.tgz", + "integrity": "sha512-KsWejBPCHokYCNDQUzGu6R3E3XDYH/YpewgQwrVBXgpl1iR0RdW1NEGNdjlbuapwVnZXVgA5eiDTfNaQCawSdg==", + "dev": true, + "requires": { + "@antfu/install-pkg": "^0.1.1", + "@antfu/utils": "^0.7.6", + "@iconify/utils": "^2.1.11", + "debug": "^4.3.4", + "kolorist": "^1.8.0", + "local-pkg": "^0.5.0", + "unplugin": "^1.5.0" + }, + "dependencies": { + "local-pkg": { + "version": "0.5.0", + "resolved": "https://registry.npmmirror.com/local-pkg/-/local-pkg-0.5.0.tgz", + "integrity": "sha512-ok6z3qlYyCDS4ZEU27HaU6x/xZa9Whf8jD4ptH5UZTQYZVYeb9bnZ3ojVhiJNLiXK1Hfc0GNbLXcmZ5plLDDBg==", + "dev": true, + "requires": { + "mlly": "^1.4.2", + "pkg-types": "^1.0.3" + } + } + } + }, "unplugin-vue-components": { "version": "0.25.2", "resolved": "https://registry.npmmirror.com/unplugin-vue-components/-/unplugin-vue-components-0.25.2.tgz", diff --git a/package.json b/package.json index a7eb2dd..6a05ddb 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,9 @@ "prepare": "husky install" }, "dependencies": { + "@element-plus/icons-vue": "^2.1.0", "@vueuse/core": "^10.5.0", + "axios": "^1.5.1", "element-plus": "^2.4.1", "lodash-es": "^4.17.21", "pinia": "^2.1.7", @@ -21,6 +23,7 @@ "vue-router": "^4.2.5" }, "devDependencies": { + "@iconify-json/mdi": "^1.1.55", "@rushstack/eslint-patch": "^1.3.3", "@tsconfig/node18": "^18.2.2", "@types/node": "^18.18.6", @@ -37,6 +40,7 @@ "sass": "^1.69.4", "typescript": "~5.2.0", "unplugin-auto-import": "^0.16.6", + "unplugin-icons": "^0.17.1", "unplugin-vue-components": "^0.25.2", "vite": "^4.4.11", "vue-tsc": "^1.8.19" diff --git a/src/App.vue b/src/App.vue index 7905b05..64293dd 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,49 +1,24 @@ -<script setup lang="ts"> -import { RouterLink, RouterView } from 'vue-router' -import HelloWorld from './components/HelloWorld.vue' -</script> - <template> - <header> - <img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" /> - - <div class="wrapper"> - <HelloWorld msg="You did it!" /> - - <nav> - <RouterLink to="/">Home</RouterLink> - <RouterLink to="/about">About</RouterLink> - </nav> - </div> - </header> - + <nav> + <RouterLink to="/">Home</RouterLink> + <RouterLink to="/about">About</RouterLink> + </nav> <RouterView /> </template> +<script setup lang="ts"> +import { RouterLink, RouterView } from 'vue-router' +</script> + <style scoped> -header { - line-height: 1.5; - max-height: 100vh; -} - -.logo { - display: block; - margin: 0 auto 2rem; -} - nav { width: 100%; - font-size: 12px; + font-size: 24px; text-align: center; - margin-top: 2rem; } nav a.router-link-exact-active { - color: var(--color-text); -} - -nav a.router-link-exact-active:hover { - background-color: transparent; + color: var(--el-color-primary); } nav a { @@ -54,32 +29,5 @@ nav a:first-of-type { border: 0; -} - -@media (min-width: 1024px) { - header { - display: flex; - place-items: center; - padding-right: calc(var(--section-gap) / 2); - } - - .logo { - margin: 0 2rem 0 0; - } - - header .wrapper { - display: flex; - place-items: flex-start; - flex-wrap: wrap; - } - - nav { - text-align: left; - margin-left: -1rem; - font-size: 1rem; - - padding: 1rem 0; - margin-top: 1rem; - } } </style> diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..336ce12 --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1 @@ +export {} diff --git a/src/assets/images/.gitkeep b/src/assets/images/.gitkeep new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/assets/images/.gitkeep diff --git a/src/assets/logo.svg b/src/assets/logo.svg deleted file mode 100644 index 7565660..0000000 --- a/src/assets/logo.svg +++ /dev/null @@ -1 +0,0 @@ -<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.76 226.69"><path d="M161.096.001l-30.225 52.351L100.647.001H-.005l130.877 226.688L261.749.001z" fill="#41b883"/><path d="M161.096.001l-30.225 52.351L100.647.001H52.346l78.526 136.01L209.398.001z" fill="#34495e"/></svg> diff --git a/src/assets/main.css b/src/assets/main.css deleted file mode 100644 index e8667cd..0000000 --- a/src/assets/main.css +++ /dev/null @@ -1,35 +0,0 @@ -@import './base.css'; - -#app { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - - font-weight: normal; -} - -a, -.green { - text-decoration: none; - color: hsla(160, 100%, 37%, 1); - transition: 0.4s; -} - -@media (hover: hover) { - a:hover { - background-color: hsla(160, 100%, 37%, 0.2); - } -} - -@media (min-width: 1024px) { - body { - display: flex; - place-items: center; - } - - #app { - display: grid; - grid-template-columns: 1fr 1fr; - padding: 0 2rem; - } -} diff --git a/src/assets/base.css b/src/assets/styles/base.css similarity index 100% rename from src/assets/base.css rename to src/assets/styles/base.css diff --git a/src/assets/styles/main.css b/src/assets/styles/main.css new file mode 100644 index 0000000..ba1231a --- /dev/null +++ b/src/assets/styles/main.css @@ -0,0 +1,9 @@ +@import './base.css'; + +#app { + max-width: 1280px; + margin: 0 auto; + + font-weight: normal; +} + diff --git a/src/auto-imports.d.ts b/src/auto-imports.d.ts new file mode 100644 index 0000000..73df040 --- /dev/null +++ b/src/auto-imports.d.ts @@ -0,0 +1,77 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// noinspection JSUnusedGlobalSymbols +// Generated by unplugin-auto-import +export {} +declare global { + const EffectScope: (typeof import('vue'))['EffectScope'] + const computed: (typeof import('vue'))['computed'] + const createApp: (typeof import('vue'))['createApp'] + const customRef: (typeof import('vue'))['customRef'] + const defineAsyncComponent: (typeof import('vue'))['defineAsyncComponent'] + const defineComponent: (typeof import('vue'))['defineComponent'] + const effectScope: (typeof import('vue'))['effectScope'] + const getCurrentInstance: (typeof import('vue'))['getCurrentInstance'] + const getCurrentScope: (typeof import('vue'))['getCurrentScope'] + const h: (typeof import('vue'))['h'] + const inject: (typeof import('vue'))['inject'] + const isProxy: (typeof import('vue'))['isProxy'] + const isReactive: (typeof import('vue'))['isReactive'] + const isReadonly: (typeof import('vue'))['isReadonly'] + const isRef: (typeof import('vue'))['isRef'] + const markRaw: (typeof import('vue'))['markRaw'] + const nextTick: (typeof import('vue'))['nextTick'] + const onActivated: (typeof import('vue'))['onActivated'] + const onBeforeMount: (typeof import('vue'))['onBeforeMount'] + const onBeforeUnmount: (typeof import('vue'))['onBeforeUnmount'] + const onBeforeUpdate: (typeof import('vue'))['onBeforeUpdate'] + const onDeactivated: (typeof import('vue'))['onDeactivated'] + const onErrorCaptured: (typeof import('vue'))['onErrorCaptured'] + const onMounted: (typeof import('vue'))['onMounted'] + const onRenderTracked: (typeof import('vue'))['onRenderTracked'] + const onRenderTriggered: (typeof import('vue'))['onRenderTriggered'] + const onScopeDispose: (typeof import('vue'))['onScopeDispose'] + const onServerPrefetch: (typeof import('vue'))['onServerPrefetch'] + const onUnmounted: (typeof import('vue'))['onUnmounted'] + const onUpdated: (typeof import('vue'))['onUpdated'] + const provide: (typeof import('vue'))['provide'] + const reactive: (typeof import('vue'))['reactive'] + const readonly: (typeof import('vue'))['readonly'] + const ref: (typeof import('vue'))['ref'] + const resolveComponent: (typeof import('vue'))['resolveComponent'] + const shallowReactive: (typeof import('vue'))['shallowReactive'] + const shallowReadonly: (typeof import('vue'))['shallowReadonly'] + const shallowRef: (typeof import('vue'))['shallowRef'] + const toRaw: (typeof import('vue'))['toRaw'] + const toRef: (typeof import('vue'))['toRef'] + const toRefs: (typeof import('vue'))['toRefs'] + const toValue: (typeof import('vue'))['toValue'] + const triggerRef: (typeof import('vue'))['triggerRef'] + const unref: (typeof import('vue'))['unref'] + const useAttrs: (typeof import('vue'))['useAttrs'] + const useCssModule: (typeof import('vue'))['useCssModule'] + const useCssVars: (typeof import('vue'))['useCssVars'] + const useSlots: (typeof import('vue'))['useSlots'] + const watch: (typeof import('vue'))['watch'] + const watchEffect: (typeof import('vue'))['watchEffect'] + const watchPostEffect: (typeof import('vue'))['watchPostEffect'] + const watchSyncEffect: (typeof import('vue'))['watchSyncEffect'] +} +// for type re-export +declare global { + // @ts-ignore + export type { + Component, + ComponentPublicInstance, + ComputedRef, + ExtractDefaultPropTypes, + ExtractPropTypes, + ExtractPublicPropTypes, + InjectionKey, + PropType, + Ref, + VNode, + WritableComputedRef + } from 'vue' +} diff --git a/src/common/composable/index.ts b/src/common/composable/index.ts new file mode 100644 index 0000000..cf5a5a6 --- /dev/null +++ b/src/common/composable/index.ts @@ -0,0 +1,3 @@ +// 鏈枃浠舵斁缃�氱敤 composable (缁勫悎寮忓嚱鏁�), 娉ㄦ剰涓� utils 鍖哄垎 + +export {} diff --git a/src/common/constants/index.ts b/src/common/constants/index.ts new file mode 100644 index 0000000..898de77 --- /dev/null +++ b/src/common/constants/index.ts @@ -0,0 +1,3 @@ +// 鏈枃浠舵斁缃叕鍏卞父閲忓畾涔�/鍏叡閰嶇疆绛� + +export {} diff --git a/src/common/utils/index.ts b/src/common/utils/index.ts new file mode 100644 index 0000000..5a84fb9 --- /dev/null +++ b/src/common/utils/index.ts @@ -0,0 +1,12 @@ +// 鏈枃浠舵斁缃」鐩�氱敤宸ュ叿鍑芥暟, 娉ㄦ剰瑕佷笌 composable 鍖哄垎 +import request from './request' + +function getToken() { + return localStorage.getItem('token') +} + +function setToken(token: string) { + localStorage.setItem('token', token) +} + +export { request, getToken, setToken } diff --git a/src/common/utils/request.ts b/src/common/utils/request.ts new file mode 100644 index 0000000..0522895 --- /dev/null +++ b/src/common/utils/request.ts @@ -0,0 +1,62 @@ +import axios from 'axios' +import { ElMessage } from 'element-plus' +import { getToken } from '@/common/utils/index' + +const Axios = axios.create({ + responseType: 'json', + withCredentials: true // 鍏佽鎼哄甫 cookie +}) + +/** + * 璇锋眰鎷︽埅鍣� + */ +Axios.interceptors.request.use( + (config) => { + // 鑻ユ槸鏈夊仛閴存潈token , 灏辩粰澶撮儴甯︿笂token + const token = getToken() + if (token) { + config.headers.Authorization = 'Bearer ' + token + } + + return config + }, + (error) => { + return Promise.reject(error) + } +) + +/** + * 鍝嶅簲鎷︽埅鍣� + */ +Axios.interceptors.response.use( + (res) => { + if (res.data.code == 200) { + return res.data ?? {} + } else { + ElMessage({ + message: res.data.msg, + type: 'error', + duration: 3 * 1000 + }) + return res.data ?? {} + } + }, + (error) => { + let { message } = error + if (message === 'Network Error') { + message = '鍚庣鎺ュ彛杩炴帴寮傚父' + } else if (message.includes('timeout')) { + message = '绯荤粺鎺ュ彛璇锋眰瓒呮椂' + } else if (message.includes('Request failed with status code')) { + message = '绯荤粺鎺ュ彛' + message.substr(message.length - 3) + '寮傚父' + } + ElMessage({ + message: message, + type: 'error', + duration: 3 * 1000 + }) + return Promise.reject(error) + } +) + +export default Axios diff --git a/src/components.d.ts b/src/components.d.ts new file mode 100644 index 0000000..940978c --- /dev/null +++ b/src/components.d.ts @@ -0,0 +1,16 @@ +/* eslint-disable */ +/* prettier-ignore */ +// @ts-nocheck +// Generated by unplugin-vue-components +// Read more: https://github.com/vuejs/core/pull/3399 +export {} + +declare module 'vue' { + export interface GlobalComponents { + ElButton: (typeof import('element-plus/es'))['ElButton'] + ElIcon: (typeof import('element-plus/es'))['ElIcon'] + HelloWorld: (typeof import('./components/HelloWorld.vue'))['default'] + RouterLink: (typeof import('vue-router'))['RouterLink'] + RouterView: (typeof import('vue-router'))['RouterView'] + } +} diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue index 6255ca9..02e9a2b 100644 --- a/src/components/HelloWorld.vue +++ b/src/components/HelloWorld.vue @@ -29,11 +29,4 @@ .greetings h3 { text-align: center; } - -@media (min-width: 1024px) { - .greetings h1, - .greetings h3 { - text-align: left; - } -} </style> diff --git a/src/main.ts b/src/main.ts index 5dcad83..597d218 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,4 @@ -import './assets/main.css' +import './assets/styles/main.css' import { createApp } from 'vue' import { createPinia } from 'pinia' diff --git a/src/views/AboutView.vue b/src/views/AboutView.vue index 1faeb69..c0bfe81 100644 --- a/src/views/AboutView.vue +++ b/src/views/AboutView.vue @@ -1,22 +1,9 @@ <template> - <div class="about"> - count: {{ counter.count }} - <el-button size="small" @click="counter.increment">鎸夐挳</el-button> + <div class="about-view"> + <h1>About View</h1> </div> </template> -<script setup lang="ts"> -import { useCounterStore } from '@/stores/counter' +<script setup lang="ts"></script> -let counter = useCounterStore() -</script> - -<style lang="scss"> -@media (min-width: 1024px) { - .about { - min-height: 100vh; - display: flex; - align-items: center; - } -} -</style> +<style lang="scss"></style> diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index 79decc3..828ab61 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -1,3 +1,51 @@ -<script setup lang="ts"></script> +<template> + <div class="home-view"> + <h1>Home View</h1> + <h2>pinia 绀轰緥</h2> + <section> + <span> count: {{ counter.count }} </span> + <el-button type="primary" @click="counter.increment">鍔犱竴</el-button> + </section> + <h2>element plus 缁勪欢 icon 绀轰緥</h2> + <section> + <el-button type="primary"> + <el-icon style="vertical-align: middle"> + <Search /> + </el-icon> + <span style="vertical-align: middle"> Search </span> -<template>home</template> + <el-icon class="is-loading"> + <Loading /> + </el-icon> + </el-button> + </section> + <h2>Iconify 鍥炬爣绀轰緥, 鏀寔鑷姩涓嬭浇鑷姩瀵煎叆</h2> + <section> + <p><a href="https://icon-sets.iconify.design/">iconify</a></p> + <p> + iconify 鏈夎澶氬浘鏍囬泦鍚�,鎵�浠ラ厤缃簡鑷姩涓嬭浇鍜岃嚜鍔ㄥ紩鍏�, + 浣嗘槸涓嬭浇鎵�鏈夌殑鍥炬爣闆嗗悎闇�瑕佺害120鍏�,鎵�浠ュ缓璁簨鍏堥�夊畾濂界敤鍝釜鍥炬爣闆�, 鍒贡鍔犲浘鏍囦笉鐒惰涓嬭浇濂藉 + </p> + <p>浣跨敤鏂规硶: <a href="https://github.com/unplugin/unplugin-icons#usage">github.com/unplugin/unplugin-icons</a></p> + <div> + <el-icon size="40" color="red"> + <IconAlert /> + </el-icon> + </div> + </section> + </div> +</template> + +<script setup lang="ts"> +import { useCounterStore } from '@/stores/counter' +import { Loading, Search } from '@element-plus/icons-vue' +import IconAlert from '~icons/mdi/alert' + +const counter = useCounterStore() +</script> + +<style lang="scss" scoped> +section { + margin: 10px 0 40px 0; +} +</style> diff --git a/tsconfig.app.json b/tsconfig.app.json index 3e5b621..a4378fa 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -1,6 +1,6 @@ { "extends": "@vue/tsconfig/tsconfig.dom.json", - "include": ["env.d.ts", "src/**/*", "src/**/*.vue"], + "include": ["env.d.ts", "src/**/*", "src/**/*.vue", "global.d.ts"], "exclude": ["src/**/__tests__/*"], "compilerOptions": { "composite": true, diff --git a/tsconfig.json b/tsconfig.json index 66b5e57..34de3b1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,5 +7,9 @@ { "path": "./tsconfig.app.json" } - ] + ], + "compilerOptions": { + // 淇 Cannot find module '~icons/xxx/xxx' or its corresponding type declarations.ts(2307) + "types": ["unplugin-icons/types/vue"] + } } diff --git a/tsconfig.node.json b/tsconfig.node.json index dee96be..4376177 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -1,12 +1,6 @@ { "extends": "@tsconfig/node18/tsconfig.json", - "include": [ - "vite.config.*", - "vitest.config.*", - "cypress.config.*", - "nightwatch.conf.*", - "playwright.config.*" - ], + "include": ["vite.config.*", "vitest.config.*", "cypress.config.*", "nightwatch.conf.*", "playwright.config.*"], "compilerOptions": { "composite": true, "module": "ESNext", diff --git a/vite.config.ts b/vite.config.ts index 68f2fe2..03be1f2 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,25 +1,51 @@ -import { fileURLToPath, URL } from 'node:url' +import path from 'path' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' +import IconsResolver from 'unplugin-icons/resolver' +import Icons from 'unplugin-icons/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' + +const pathSrc = path.resolve(__dirname, 'src') // https://vitejs.dev/config/ export default defineConfig({ + resolve: { + alias: { + '@': pathSrc + } + }, plugins: [ vue(), // element plus 鑷姩瀵煎叆 AutoImport({ - resolvers: [ElementPlusResolver()] + // 鑷姩瀵煎叆 Vue 鐩稿叧鍑芥暟锛屽锛歳ef, reactive, toRef 绛� + imports: ['vue'], + // 鑷姩瀵煎叆 Element Plus 鐩稿叧鍑芥暟锛屽锛欵lMessage, ElMessageBox... (甯︽牱寮�) + resolvers: [ + ElementPlusResolver(), + // 鑷姩瀵煎叆鍥炬爣缁勪欢 + IconsResolver({ + prefix: 'Icon' + }) + ], + + dts: path.resolve(pathSrc, 'auto-imports.d.ts') }), Components({ - resolvers: [ElementPlusResolver()] + resolvers: [ + // 鑷姩娉ㄥ唽鍥炬爣缁勪欢 + IconsResolver({ + enabledCollections: ['ep'] + }), + // 鑷姩瀵煎叆 Element Plus 缁勪欢 + ElementPlusResolver() + ], + dts: path.resolve(pathSrc, 'components.d.ts') + }), + Icons({ + autoInstall: true }) - ], - resolve: { - alias: { - '@': fileURLToPath(new URL('./src', import.meta.url)) - } - } + ] }) -- Gitblit v1.8.0