From 95b47811121d5495aa169e2e6b51d8e7da77527e Mon Sep 17 00:00:00 2001 From: hooray <304327508@qq.com> Date: Thu, 9 Sep 2021 16:45:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=95=E5=85=A5=20unplugin-auto-import=20?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E9=83=A8=E5=88=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.js | 3 +- .gitignore | 3 +- auto-import-eslint-config.js | 53 ++++++++++++ package.json | 1 + pnpm-lock.yaml | 84 +++++++++++++++++--- src/App.vue | 3 - src/components/Auth/index.vue | 1 - src/components/AuthAll/index.vue | 1 - src/components/BatchActionBar/index.vue | 2 - src/components/CascaderArea/index.vue | 1 - src/components/Editor/index.vue | 2 - src/components/FileUpload/index.vue | 2 - src/components/FixedActionBar/index.vue | 2 - src/components/ImagePreview/index.vue | 2 - src/components/ImageUpload/index.vue | 2 - src/components/ImagesUpload/index.vue | 2 - src/components/PageHeader/index.vue | 2 - src/components/PageMain/index.vue | 2 - src/components/Result/index.vue | 2 - src/components/SearchBar/index.vue | 2 - src/components/SvgIcon/index.vue | 2 - src/components/Trend/index.vue | 2 - src/layout/components/Header/index.vue | 1 - src/layout/components/Logo/index.vue | 2 - src/layout/components/MainSidebar/index.vue | 1 - src/layout/components/Search/index.vue | 2 - src/layout/components/SidebarItem/index.vue | 1 - src/layout/components/SubSidebar/index.vue | 1 - src/layout/components/ThemeSetting/index.vue | 4 - src/layout/components/Topbar/index.vue | 3 - src/layout/components/UserMenu/index.vue | 3 - src/layout/index.vue | 4 - vite/plugins/auto-import.js | 13 +++ vite/plugins/index.js | 2 + 34 files changed, 144 insertions(+), 69 deletions(-) create mode 100644 auto-import-eslint-config.js create mode 100644 vite/plugins/auto-import.js diff --git a/.eslintrc.js b/.eslintrc.js index 2a2497bb..18c0c7dc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -14,7 +14,8 @@ module.exports = { extends: [ 'plugin:vue/vue3-recommended', 'plugin:vue/vue3-strongly-recommended', - 'eslint:recommended' + 'eslint:recommended', + './auto-import-eslint-config.js' ], parser: 'vue-eslint-parser', rules: { diff --git a/.gitignore b/.gitignore index 7d4c883d..38297f30 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ node_modules dist* dist-ssr *.local -src/assets/sprites/*.* \ No newline at end of file +src/assets/sprites/*.* +auto-imports.d.ts diff --git a/auto-import-eslint-config.js b/auto-import-eslint-config.js new file mode 100644 index 00000000..032562f5 --- /dev/null +++ b/auto-import-eslint-config.js @@ -0,0 +1,53 @@ +module.exports = { + globals: { + // lifecycle + onActivated: 'readonly', + onBeforeMount: 'readonly', + onBeforeUnmount: 'readonly', + onBeforeUpdate: 'readonly', + onDeactivated: 'readonly', + onErrorCaptured: 'readonly', + onMounted: 'readonly', + onServerPrefetch: 'readonly', + onUnmounted: 'readonly', + onUpdated: 'readonly', + // reactivity + computed: 'readonly', + customRef: 'readonly', + isReadonly: 'readonly', + isRef: 'readonly', + markRaw: 'readonly', + reactive: 'readonly', + readonly: 'readonly', + ref: 'readonly', + shallowReactive: 'readonly', + shallowReadonly: 'readonly', + shallowRef: 'readonly', + toRaw: 'readonly', + toRef: 'readonly', + toRefs: 'readonly', + triggerRef: 'readonly', + unref: 'readonly', + watch: 'readonly', + watchEffect: 'readonly', + // component + defineComponent: 'readonly', + defineAsyncComponent: 'readonly', + getCurrentInstance: 'readonly', + h: 'readonly', + inject: 'readonly', + nextTick: 'readonly', + provide: 'readonly', + useCssModule: 'readonly', + // other + defineProps: 'readonly', + defineEmits: 'readonly', + defineExpose: 'readonly', + withDefaults: 'readonly', + // vue-router + useRoute: 'readonly', + useRouter: 'readonly', + // vuex + useStore: 'readonly' + } +} diff --git a/package.json b/package.json index 3f4f01cd..df9b0d9b 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "stylelint-config-standard": "^22.0.0", "stylelint-scss": "^3.20.1", "svgo": "^2.5.0", + "unplugin-auto-import": "^0.4.5", "unplugin-vue-components": "^0.14.11", "vite": "^2.5.3", "vite-plugin-banner": "^0.1.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9784466c..210daf1a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -28,6 +28,7 @@ specifiers: stylelint-scss: ^3.20.1 svgo: ^2.5.0 tinymce: ^5.9.1 + unplugin-auto-import: ^0.4.5 unplugin-vue-components: ^0.14.11 vite: ^2.5.3 vite-plugin-banner: ^0.1.3 @@ -75,6 +76,7 @@ devDependencies: stylelint-config-standard: registry.nlark.com/stylelint-config-standard/22.0.0_stylelint@13.13.1 stylelint-scss: registry.nlark.com/stylelint-scss/3.20.1_stylelint@13.13.1 svgo: registry.nlark.com/svgo/2.5.0 + unplugin-auto-import: registry.nlark.com/unplugin-auto-import/0.4.5_vite@2.5.3 unplugin-vue-components: registry.nlark.com/unplugin-vue-components/0.14.11_vite@2.5.3+vue@3.2.8 vite: registry.nlark.com/vite/2.5.3 vite-plugin-banner: registry.nlark.com/vite-plugin-banner/0.1.3 @@ -968,10 +970,6 @@ packages: resolution: {integrity: sha1-FQStJSMVjKpA20onh8sBQRmU6k8=, tarball: fs.realpath/download/fs.realpath-1.0.0.tgz} dev: true - /function-bind/1.1.1: - resolution: {integrity: sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=, tarball: function-bind/download/function-bind-1.1.1.tgz} - dev: true - /functional-red-black-tree/1.0.1: resolution: {integrity: sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=, tarball: functional-red-black-tree/download/functional-red-black-tree-1.0.1.tgz} dev: true @@ -1137,13 +1135,6 @@ packages: kind-of: 4.0.0 dev: true - /has/1.0.3: - resolution: {integrity: sha1-ci18v8H2qoJB8W3YFOAR4fQeh5Y=, tarball: has/download/has-1.0.3.tgz} - engines: {node: '>= 0.4.0'} - dependencies: - function-bind: 1.1.1 - dev: true - /hash-sum/2.0.0: resolution: {integrity: sha1-gdAbtd6OpKIUrV1urRtSNGCwtFo=, tarball: hash-sum/download/hash-sum-2.0.0.tgz} dev: true @@ -3208,6 +3199,14 @@ packages: resolution: {integrity: sha1-0R1zgf/tFrdC9q97PyI9XNn+mSA=, tarball: zwitch/download/zwitch-1.0.5.tgz} dev: true + registry.nlark.com/@antfu/utils/0.3.0: + resolution: {integrity: sha1-YwbEO1Kog72Olz4+2N1kJIQYvMQ=, registry: https://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' @@ -3731,6 +3730,12 @@ packages: '@types/node': registry.nlark.com/@types/node/16.7.10 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} + name: '@types/throttle-debounce' + version: 2.1.0 + dev: true + registry.nlark.com/@types/through/0.0.30: resolution: {integrity: sha1-4OQs536Je9aurW9upirrE1uKOJU=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/@types/through/download/@types/through-0.0.30.tgz?cache=0&sync_timestamp=1629710122580&other_urls=https%3A%2F%2Fregistry.nlark.com%2F%40types%2Fthrough%2Fdownload%2F%40types%2Fthrough-0.0.30.tgz} name: '@types/through' @@ -4687,6 +4692,12 @@ packages: dev: true optional: true + registry.nlark.com/function-bind/1.1.1: + resolution: {integrity: sha1-pWiZ0+o8m6uHS7l3O3xe3pL0iV0=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/function-bind/download/function-bind-1.1.1.tgz} + name: function-bind + version: 1.1.1 + dev: true + registry.nlark.com/get-pixels/3.3.3: resolution: {integrity: sha1-ceLf1L77gQtUeKYcY1SACXbOAcc=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/get-pixels/download/get-pixels-3.3.3.tgz} name: get-pixels @@ -4833,6 +4844,15 @@ packages: version: 0.0.1 dev: true + registry.nlark.com/has/1.0.3: + resolution: {integrity: sha1-ci18v8H2qoJB8W3YFOAR4fQeh5Y=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/has/download/has-1.0.3.tgz} + name: has + version: 1.0.3 + engines: {node: '>= 0.4.0'} + dependencies: + function-bind: registry.nlark.com/function-bind/1.1.1 + dev: true + registry.nlark.com/he/1.2.0: resolution: {integrity: sha1-hK5l+n6vsWX922FWauFLrwVmTw8=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/he/download/he-1.2.0.tgz} name: he @@ -4967,11 +4987,11 @@ packages: dev: true registry.nlark.com/is-core-module/2.6.0: - resolution: {integrity: sha1-11U7JSb+Wbkro+QMjfdX7Ipwnhk=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/is-core-module/download/is-core-module-2.6.0.tgz} + resolution: {integrity: sha1-11U7JSb+Wbkro+QMjfdX7Ipwnhk=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/is-core-module/download/is-core-module-2.6.0.tgz?cache=0&sync_timestamp=1629224656971&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fis-core-module%2Fdownload%2Fis-core-module-2.6.0.tgz} name: is-core-module version: 2.6.0 dependencies: - has: 1.0.3 + has: registry.nlark.com/has/1.0.3 dev: true registry.nlark.com/is-data-descriptor/0.1.4: @@ -5120,6 +5140,14 @@ packages: p-locate: registry.nlark.com/p-locate/4.1.0 dev: true + registry.nlark.com/magic-string/0.25.7: + resolution: {integrity: sha1-P0l9b9NMZpxnmNy4IfLvMfVEUFE=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/magic-string/download/magic-string-0.25.7.tgz?cache=0&sync_timestamp=1618847046304&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fmagic-string%2Fdownload%2Fmagic-string-0.25.7.tgz} + name: magic-string + version: 0.25.7 + dependencies: + sourcemap-codec: 1.4.8 + dev: true + registry.nlark.com/mdast-util-from-markdown/0.8.5: resolution: {integrity: sha1-0e8spCvDd+ywRjqYeRDa6JvZoow=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/mdast-util-from-markdown/download/mdast-util-from-markdown-0.8.5.tgz} name: mdast-util-from-markdown @@ -5647,6 +5675,15 @@ packages: global-modules: 1.0.0 dev: true + registry.nlark.com/resolve/1.20.0: + resolution: {integrity: sha1-YpoBP7P3B1XW8LeTXMHCxTeLGXU=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/resolve/download/resolve-1.20.0.tgz} + name: resolve + version: 1.20.0 + dependencies: + is-core-module: registry.nlark.com/is-core-module/2.6.0 + path-parse: registry.nlark.com/path-parse/1.0.7 + dev: true + registry.nlark.com/restore-cursor/2.0.0: resolution: {integrity: sha1-n37ih/gv0ybU/RYpI9YhKe7g368=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/restore-cursor/download/restore-cursor-2.0.0.tgz} name: restore-cursor @@ -6151,6 +6188,27 @@ packages: version: 4.1.0 dev: true + registry.nlark.com/unplugin-auto-import/0.4.5_vite@2.5.3: + resolution: {integrity: sha1-JVpSgT8+955Xdb5jD5X2Znz0qFA=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/unplugin-auto-import/download/unplugin-auto-import-0.4.5.tgz} + id: registry.nlark.com/unplugin-auto-import/0.4.5 + name: unplugin-auto-import + version: 0.4.5 + engines: {node: '>=14'} + peerDependencies: + '@vueuse/core': ^6.0.0 + dependencies: + '@antfu/utils': registry.nlark.com/@antfu/utils/0.3.0 + '@rollup/pluginutils': registry.nlark.com/@rollup/pluginutils/4.1.1 + has-pkg: registry.nlark.com/has-pkg/0.0.1 + magic-string: registry.nlark.com/magic-string/0.25.7 + resolve: registry.nlark.com/resolve/1.20.0 + unplugin: registry.nlark.com/unplugin/0.2.7_vite@2.5.3 + transitivePeerDependencies: + - rollup + - vite + - webpack + dev: true + registry.nlark.com/unplugin-vue-components/0.14.11_vite@2.5.3+vue@3.2.8: resolution: {integrity: sha1-rvLASAMW6GRFDLPgt/Y+jxBpUCc=, registry: https://registry.npm.taobao.org/, tarball: https://registry.nlark.com/unplugin-vue-components/download/unplugin-vue-components-0.14.11.tgz} id: registry.nlark.com/unplugin-vue-components/0.14.11 diff --git a/src/App.vue b/src/App.vue index cd581984..71ede115 100644 --- a/src/App.vue +++ b/src/App.vue @@ -3,9 +3,6 @@ diff --git a/src/layout/components/Logo/index.vue b/src/layout/components/Logo/index.vue index 9bf81b81..ce775fef 100644 --- a/src/layout/components/Logo/index.vue +++ b/src/layout/components/Logo/index.vue @@ -7,8 +7,6 @@ diff --git a/src/layout/components/Search/index.vue b/src/layout/components/Search/index.vue index 833711fd..dc483432 100644 --- a/src/layout/components/Search/index.vue +++ b/src/layout/components/Search/index.vue @@ -51,8 +51,6 @@