引入 unplugin-auto-import 依赖,修改框架部分代码

This commit is contained in:
hooray
2021-09-09 16:45:23 +08:00
parent 2667601de3
commit 95b4781112
34 changed files with 144 additions and 69 deletions
+2 -1
View File
@@ -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: {
+2 -1
View File
@@ -3,4 +3,5 @@ node_modules
dist*
dist-ssr
*.local
src/assets/sprites/*.*
src/assets/sprites/*.*
auto-imports.d.ts
+53
View File
@@ -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'
}
}
+1
View File
@@ -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",
+71 -13
View File
@@ -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
-3
View File
@@ -3,9 +3,6 @@
</template>
<script setup>
import { watch, onMounted } from 'vue'
import { useStore } from 'vuex'
const store = useStore()
watch(() => store.state.settings.mode, () => {
-1
View File
@@ -7,7 +7,6 @@
<script setup>
import { auth } from '@/util'
import { defineProps } from 'vue'
const props = defineProps({
value: {
-1
View File
@@ -7,7 +7,6 @@
<script setup>
import { authAll } from '@/util'
import { defineProps } from 'vue'
const props = defineProps({
value: {
-2
View File
@@ -9,8 +9,6 @@
</template>
<script setup>
import { defineProps, defineEmits, computed } from 'vue'
const props = defineProps({
data: {
type: Array,
-1
View File
@@ -6,7 +6,6 @@
<script setup>
import area from '@/util/area'
import { defineProps, defineEmits, ref, computed } from 'vue'
const props = defineProps({
// 传入数据为中文数组,例如:['河北省', '唐山市', '市辖区']
-2
View File
@@ -28,8 +28,6 @@ import 'tinymce/plugins/wordcount'
import 'tinymce/plugins/code'
import 'tinymce/plugins/searchreplace'
import { defineProps, defineEmits, ref, computed, watch, onMounted } from 'vue'
const props = defineProps({
modelValue: {
type: String,
-2
View File
@@ -25,8 +25,6 @@
</template>
<script setup>
import { defineProps, defineEmits, getCurrentInstance } from 'vue'
const { proxy } = getCurrentInstance()
const props = defineProps({
-2
View File
@@ -5,8 +5,6 @@
</template>
<script setup>
import { ref, onMounted, onUnmounted } from 'vue'
const data = ref({
isBottom: true
})
-2
View File
@@ -9,8 +9,6 @@
</template>
<script setup>
import { defineProps, computed } from 'vue'
const props = defineProps({
src: {
type: String,
-2
View File
@@ -46,8 +46,6 @@
</template>
<script setup>
import { defineProps, defineEmits, ref, getCurrentInstance } from 'vue'
const { proxy } = getCurrentInstance()
const props = defineProps({
-2
View File
@@ -50,8 +50,6 @@
</template>
<script setup>
import { defineProps, defineEmits, ref, getCurrentInstance } from 'vue'
const { proxy } = getCurrentInstance()
const props = defineProps({
-2
View File
@@ -13,8 +13,6 @@
</template>
<script setup>
import { defineProps } from 'vue'
defineProps({
title: {
type: String,
-2
View File
@@ -15,8 +15,6 @@
</template>
<script setup>
import { defineProps, ref } from 'vue'
const props = defineProps({
title: {
type: String,
-2
View File
@@ -21,8 +21,6 @@
</template>
<script setup>
import { defineProps } from 'vue'
defineProps({
type: {
type: String,
-2
View File
@@ -8,8 +8,6 @@
</template>
<script setup>
import { defineProps, defineEmits, ref, watch } from 'vue'
const props = defineProps({
showMore: {
type: Boolean,
-2
View File
@@ -6,8 +6,6 @@
</template>
<script setup>
import { defineProps, computed } from 'vue'
const props = defineProps({
name: {
type: String,
-2
View File
@@ -8,8 +8,6 @@
</template>
<script setup>
import { defineProps, computed } from 'vue'
const props = defineProps({
value: {
type: String,
-1
View File
@@ -23,7 +23,6 @@
<script setup>
import Logo from '../Logo/index.vue'
import UserMenu from '../UserMenu/index.vue'
import { inject } from 'vue'
const switchMenu = inject('switchMenu')
</script>
-2
View File
@@ -7,8 +7,6 @@
<script setup>
import imgLogo from '@/assets/images/logo.png'
import { defineProps, ref, computed } from 'vue'
import { useStore } from 'vuex'
const store = useStore()
@@ -21,7 +21,6 @@
<script setup>
import Logo from '../Logo/index.vue'
import { inject } from 'vue'
const switchMenu = inject('switchMenu')
</script>
-2
View File
@@ -51,8 +51,6 @@
<script setup>
import { deepClone } from '@/util'
import { computed, getCurrentInstance, onMounted, ref, watch } from 'vue'
import { useStore } from 'vuex'
const { proxy } = getCurrentInstance()
const store = useStore()
@@ -29,7 +29,6 @@
<script setup>
import SidebarItem from './index.vue'
import path from 'path-browserify'
import { computed, defineProps } from 'vue'
const props = defineProps({
item: {
@@ -23,7 +23,6 @@
<script setup>
import Logo from '../Logo/index.vue'
import SidebarItem from '../SidebarItem/index.vue'
import { ref } from 'vue'
const sidebarScrollTop = ref(0)
@@ -140,10 +140,6 @@
</template>
<script setup>
import { computed, getCurrentInstance, inject, onMounted, ref } from 'vue'
import { useStore } from 'vuex'
import { useRoute } from 'vue-router'
const { proxy } = getCurrentInstance()
const store = useStore()
const route = useRoute()
-3
View File
@@ -29,9 +29,6 @@
import { compile } from 'path-to-regexp'
import { deepClone } from '@/util'
import UserMenu from '../UserMenu/index.vue'
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { useStore } from 'vuex'
import { useRoute } from 'vue-router'
const store = useStore()
const route = useRoute()
-3
View File
@@ -39,9 +39,6 @@
<script setup>
import screenfull from 'screenfull'
import { computed, inject, onBeforeUnmount, onMounted, ref } from 'vue'
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'
const reload = inject('reload')
const store = useStore()
-4
View File
@@ -37,10 +37,6 @@ import Topbar from './components/Topbar/index.vue'
import Search from './components/Search/index.vue'
import ThemeSetting from './components/ThemeSetting/index.vue'
import { provide, computed, watch, getCurrentInstance, onMounted } from 'vue'
import { useStore } from 'vuex'
import { useRoute, useRouter } from 'vue-router'
const { proxy } = getCurrentInstance()
const store = useStore()
const route = useRoute(), router = useRouter()
+13
View File
@@ -0,0 +1,13 @@
import autoImport from 'unplugin-auto-import/vite'
export default function createAutoImport() {
return autoImport({
imports: [
'vue',
'vue-router',
{
'vuex': ['useStore']
}
]
})
}
+2
View File
@@ -2,6 +2,7 @@ import vue from '@vitejs/plugin-vue'
import createRestart from './restart'
import createHtml from './html'
import createAutoImport from './auto-import'
import createComponents from './components'
import createSvgIcon from './svg-icon'
import createMock from './mock'
@@ -13,6 +14,7 @@ export default function createVitePlugins(viteEnv, isBuild = false) {
const vitePlugins = [vue()]
!isBuild && vitePlugins.push(createRestart())
vitePlugins.push(createHtml(viteEnv, isBuild))
vitePlugins.push(createAutoImport())
vitePlugins.push(createComponents())
vitePlugins.push(createSvgIcon(isBuild))
vitePlugins.push(createMock())