feat: 集成unplugin-auto-import自动引入

This commit is contained in:
张传龙 2022-06-19 15:22:01 +08:00
parent ac9ccbadf0
commit 3990d4da80
18 changed files with 119 additions and 25 deletions

View File

@ -1,3 +1,4 @@
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import { FileSystemIconLoader } from 'unplugin-icons/loaders'
@ -14,6 +15,9 @@ import { getRootPath } from '../utils'
const customIconPath = getRootPath('src', 'assets/icons')
export default [
AutoImport({
imports: ['vue', 'vue-router'],
}),
Icons({
compiler: 'vue3',
customCollections: {

View File

@ -38,6 +38,7 @@
"rollup-plugin-visualizer": "^5.6.0",
"sass": "^1.49.10",
"unocss": "^0.38.2",
"unplugin-auto-import": "^0.8.8",
"unplugin-icons": "^0.14.1",
"unplugin-vue-components": "^0.17.21",
"vite": "^2.9.9",

113
pnpm-lock.yaml generated
View File

@ -24,6 +24,7 @@ specifiers:
rollup-plugin-visualizer: ^5.6.0
sass: ^1.49.10
unocss: ^0.38.2
unplugin-auto-import: ^0.8.8
unplugin-icons: ^0.14.1
unplugin-vue-components: ^0.17.21
vite: ^2.9.9
@ -61,6 +62,7 @@ devDependencies:
rollup-plugin-visualizer: 5.6.0
sass: 1.49.10
unocss: 0.38.2_vite@2.9.9
unplugin-auto-import: 0.8.8_y44jlmyuqbnkfkqeyjo67naj6e
unplugin-icons: 0.14.1_jyihscimozjyoh3ugo77i7phoi
unplugin-vue-components: 0.17.21_vite@2.9.9+vue@3.2.31
vite: 2.9.9_sass@1.49.10
@ -563,6 +565,12 @@ packages:
hasBin: true
dev: true
/acorn/8.7.1:
resolution: {integrity: sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A==}
engines: {node: '>=0.4.0'}
hasBin: true
dev: true
/ajv/6.12.6:
resolution: {integrity: sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==}
dependencies:
@ -1208,6 +1216,11 @@ packages:
engines: {node: '>=10'}
dev: true
/escape-string-regexp/5.0.0:
resolution: {integrity: sha512-/veY75JbMK4j1yjvuUxuVsiS/hr/4iHs9FTT6cgTexxdE0Ly/glccBAkloH/DofkjRbZU3bnoj38mOmhkZ0lHw==}
engines: {node: '>=12'}
dev: true
/eslint-config-prettier/8.5.0_eslint@8.12.0:
resolution: {integrity: sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==}
hasBin: true
@ -1773,6 +1786,10 @@ packages:
resolution: {integrity: sha1-nbe1lJatPzz+8wp1FC0tkwrXJlE=}
dev: true
/jsonc-parser/3.0.0:
resolution: {integrity: sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==}
dev: true
/jsonfile/6.1.0:
resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==}
dependencies:
@ -1890,6 +1907,17 @@ packages:
brace-expansion: 2.0.1
dev: true
/mlly/0.3.19:
resolution: {integrity: sha512-zMq5n3cOf4fOzA4WoeulxagbAgMChdev3MgP6K51k7M0u2whTXxupfIY4VVzws4vxkiWhwH1rVQcsw7zDGfRhA==}
dev: true
/mlly/0.5.3:
resolution: {integrity: sha512-im69tuLD9EJh9fc9TZRpJEFvsBcGMez7glUCWDcHWWCKzhvPmNvyaYjp/+h0qJJN/Xovrs//GzGjOOKmFw4Gog==}
dependencies:
pathe: 0.2.0
pkg-types: 0.3.2
dev: true
/mockjs/1.1.0:
resolution: {integrity: sha512-eQsKcWzIaZzEZ07NuEyO4Nw65g0hdWAyurVol1IPl1gahRwY+svqzfgfey8U8dahLwG44d6/RwEzuK52rSa/JQ==}
hasBin: true
@ -2136,6 +2164,14 @@ packages:
vue-demi: 0.12.5_vue@3.2.31
dev: false
/pkg-types/0.3.2:
resolution: {integrity: sha512-eBYzX/7NYsQEOR2alWY4rnQB49G62oHzFpoi9Som56aUr8vB8UGcmcIia9v8fpBeuhH3Ltentuk2OGpp4IQV3Q==}
dependencies:
jsonc-parser: 3.0.0
mlly: 0.3.19
pathe: 0.2.0
dev: true
/postcss/8.4.12:
resolution: {integrity: sha512-lg6eITwYe9v6Hr5CncVbK70SoioNQIq81nsaG86ev5hAidQvmOeETBqs7jm43K2F5/Ley3ytDtriImV6TpNiSg==}
engines: {node: ^10 || ^12 || >=14}
@ -2278,6 +2314,10 @@ packages:
source-map-js: 1.0.2
dev: true
/scule/0.2.1:
resolution: {integrity: sha512-M9gnWtn3J0W+UhJOHmBxBTwv8mZCan5i1Himp60t6vvZcor0wr+IM0URKmIglsWJ7bRujNAVVN77fp+uZaWoKg==}
dev: true
/seemly/0.3.4:
resolution: {integrity: sha512-/crL+UfbtYd6NdLdnf58xaABfeSRt5uKE4N1SFQAW7nIznOrJQchAaslJHxV8/iAfV0LWInrmxJBFdDb0c2/sw==}
dependencies:
@ -2378,6 +2418,12 @@ packages:
engines: {node: '>=8'}
dev: true
/strip-literal/0.4.0:
resolution: {integrity: sha512-ql/sBDoJOybTKSIOWrrh8kgUEMjXMwRAkZTD0EwiwxQH/6tTPkZvMIEjp0CRlpi6V5FMiJyvxeRkEi1KrGISoA==}
dependencies:
acorn: 8.7.1
dev: true
/supports-color/7.2.0:
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
engines: {node: '>=8'}
@ -2460,6 +2506,26 @@ packages:
engines: {node: '>=12.18'}
dev: true
/unimport/0.2.9_vite@2.9.9:
resolution: {integrity: sha512-5SLmZZL2rwaNOQa/yTGaG0QI0meRhb6MDdIlS9s1uHPSYO6Gfzr7ugl5Rf35/CJioW6wYiNJsN9dru5JMzaD8w==}
dependencies:
'@rollup/pluginutils': 4.2.1
escape-string-regexp: 5.0.0
fast-glob: 3.2.11
local-pkg: 0.4.1
magic-string: 0.26.2
mlly: 0.5.3
pathe: 0.3.0
scule: 0.2.1
strip-literal: 0.4.0
unplugin: 0.7.0_vite@2.9.9
transitivePeerDependencies:
- esbuild
- rollup
- vite
- webpack
dev: true
/universalify/2.0.0:
resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==}
engines: {node: '>= 10.0.0'}
@ -2499,6 +2565,29 @@ packages:
engines: {node: '>= 0.8'}
dev: true
/unplugin-auto-import/0.8.8_y44jlmyuqbnkfkqeyjo67naj6e:
resolution: {integrity: sha512-cVZ79zMR1v4VCZ9emFTUnltmazCc2B4hObyVrxJdlgJ2sK8qub6JfjFt38rCF6MVEddkHiWCU6wZR1qbdqe+ig==}
engines: {node: '>=14'}
peerDependencies:
'@vueuse/core': '*'
peerDependenciesMeta:
'@vueuse/core':
optional: true
dependencies:
'@antfu/utils': 0.5.2
'@rollup/pluginutils': 4.2.1
'@vueuse/core': 8.4.2_vue@3.2.31
local-pkg: 0.4.1
magic-string: 0.26.2
unimport: 0.2.9_vite@2.9.9
unplugin: 0.7.0_vite@2.9.9
transitivePeerDependencies:
- esbuild
- rollup
- vite
- webpack
dev: true
/unplugin-icons/0.14.1_jyihscimozjyoh3ugo77i7phoi:
resolution: {integrity: sha512-drZFbMctvT3ZJPfdCgBv5+LKO8hGbZApRCoBRAUhQFRJQVNGUhGThrOKs+CvWq3XDBPptGNBmst8WyObbr4xiQ==}
peerDependencies:
@ -2608,6 +2697,30 @@ packages:
webpack-virtual-modules: 0.4.3
dev: true
/unplugin/0.7.0_vite@2.9.9:
resolution: {integrity: sha512-OsiFrgybmqm5bGuaodvbLYhqUrvGuRHRMZDhddKEXTDbuQ1x+hR7M1WpQguXj03whVYjEYChhFo738cZH5RNig==}
peerDependencies:
esbuild: '>=0.13'
rollup: ^2.50.0
vite: ^2.3.0
webpack: 4 || 5
peerDependenciesMeta:
esbuild:
optional: true
rollup:
optional: true
vite:
optional: true
webpack:
optional: true
dependencies:
acorn: 8.7.1
chokidar: 3.5.3
vite: 2.9.9_sass@1.49.10
webpack-sources: 3.2.3
webpack-virtual-modules: 0.4.3
dev: true
/uri-js/4.4.1:
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
dependencies:

View File

@ -17,7 +17,6 @@
</template>
<script setup>
import { watch } from 'vue'
import { useCssVar } from '@vueuse/core'
import MessageContent from './MessageContent.vue'
import DialogContent from './DialogContent.vue'

View File

@ -24,7 +24,6 @@
</template>
<script setup>
import { ref, onMounted } from 'vue'
import { debounce } from '@/utils'
import { isNullOrUndef } from '@/utils/is'

View File

@ -9,8 +9,6 @@
</template>
<script setup>
import { computed } from 'vue'
import { useRouter } from 'vue-router'
import { useAppStore } from '@/store/modules/app'
const appStore = useAppStore()

View File

@ -7,7 +7,6 @@
</template>
<script setup>
import { useRouter, useRoute } from 'vue-router'
const router = useRouter()
const route = useRoute()

View File

@ -12,8 +12,6 @@
</template>
<script setup>
import { useRouter } from 'vue-router'
import { computed } from 'vue'
import { usePermissionStore } from '@/store/modules/permission'
import { isExternal } from '@/utils/is'

View File

@ -11,7 +11,6 @@
</template>
<script setup>
import { computed } from 'vue'
import { useTagsStore } from '@/store/modules/tags'
import { renderIcon } from '@/utils/icon'
import { useAppStore } from '@/store/modules/app'

View File

@ -23,8 +23,6 @@
<script setup name="Tags">
import ContextMenu from './ContextMenu.vue'
import { nextTick, reactive, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { useTagsStore } from '@/store/modules/tags'
import { useThemeStore } from '@/store/modules/theme'
import ScrollX from '@/components/Common/ScrollX.vue'

View File

@ -1,5 +1,4 @@
import { defineStore } from 'pinia'
import { nextTick } from 'vue'
export const useAppStore = defineStore('app', {
state() {

View File

@ -12,7 +12,6 @@
</template>
<script setup>
import { useRouter } from 'vue-router'
const { replace } = useRouter()
</script>

View File

@ -9,9 +9,6 @@
</template>
<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'
import MdEditor from 'md-editor-v3'
import 'md-editor-v3/lib/style.css'

View File

@ -17,8 +17,6 @@
</template>
<script setup>
import { ref, onBeforeMount } from 'vue'
import { useRouter } from 'vue-router'
import { usePostTable } from './usePostTable'
const router = useRouter()

View File

@ -1,4 +1,4 @@
import { h, ref } from 'vue'
import { h } from 'vue'
import { NButton, NSwitch } from 'naive-ui'
import { getPosts } from '@/api/post'
import { formatDateTime } from '@/utils'

View File

@ -40,9 +40,6 @@
</template>
<script setup>
import { ref, unref } from 'vue'
import { useRouter } from 'vue-router'
import { login } from '@/api/auth'
import { createLocalStorage } from '@/utils/cache'
import { setToken } from '@/utils/token'

View File

@ -1,8 +1,6 @@
<template></template>
<script setup>
import { useRouter } from 'vue-router'
const { currentRoute, replace } = useRouter()
const { query } = currentRoute.value

View File

@ -6,8 +6,6 @@
<!--使用keep-alive须设置name注意请与对应的路由的name保持一致方便统一处理-->
<script setup name="TestKeepAlive">
import { onMounted, onActivated, onDeactivated } from 'vue'
onMounted(() => {
$message.success('触发onMounted')
})